354c05a4ddd678c49bcbba458bffa7d13482139a
bernd Login vial Client-Cert über...

bernd authored 15 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

5) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
12) */
bernd Login vial Client-Cert über...

bernd authored 15 years ago

13) 
Bernd Wurst jQuery-based Certlogin, so...

Bernd Wurst authored 11 years ago

14) // Setze das Arbeitsverzeichnis auf das Stammverzeichnis, damit die Voraussetzungen gleich sind wie bei allen anderen Requests
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

15) chdir('..');
16) 
17) require_once('config.php');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

18) global $prefix;
19) $prefix = '../';
20) 
21) // Das Parent-Verzeichnis in den Include-Pfad, da wir uns jetzt in einem anderen Verzeichnis befinden.
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

22) ini_set('include_path', ini_get('include_path') . ':../');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

23) 
24) require_once('session/start.php');
25) require_once('inc/base.php');
26) require_once('inc/debug.php');
27) require_once('inc/error.php');
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

28) require_once('inc/theme.php');
schokokeks.org web services changes to cert login stuff

schokokeks.org web services authored 6 years ago

29) require_once('modules/index/include/x509.php');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

30) 
31) 
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

32) DEBUG('$_SERVER:');
33) DEBUG($_SERVER);
34) 
Bernd Wurst verstehe Umgebungsvariablen...

Bernd Wurst authored 8 years ago

35) $redirect = "";
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

36) if (!isset($_SERVER['SSL_CLIENT_CERT']) && isset($_SERVER['REDIRECT_SSL_CLIENT_CERT'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

37)     $redirect = "REDIRECT_";
Bernd Wurst verstehe Umgebungsvariablen...

Bernd Wurst authored 8 years ago

38) }
bernd Login vial Client-Cert über...

bernd authored 15 years ago

39) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

40) if ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['record']) && isset($_REQUEST['backto']) && check_path($_REQUEST['backto'])) {
41)     DEBUG('recording client-cert');
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

42)     if (isset($_SERVER[$redirect . 'SSL_CLIENT_CERT']) && isset($_SERVER[$redirect . 'SSL_CLIENT_S_DN']) &&
43)       isset($_SERVER[$redirect . 'SSL_CLIENT_I_DN']) && isset($_SERVER[$redirect . 'SSL_CLIENT_M_SERIAL']) &&
44)       isset($_SERVER[$redirect . 'SSL_CLIENT_V_START']) && isset($_SERVER[$redirect . 'SSL_CLIENT_V_END'])
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 1 year ago

45)     ) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

46)         $_SESSION['clientcert_cert'] = $_SERVER[$redirect . 'SSL_CLIENT_CERT'];
47)         $_SESSION['clientcert_dn'] = $_SERVER[$redirect . 'SSL_CLIENT_S_DN'];
48)         $_SESSION['clientcert_issuer'] = $_SERVER[$redirect . 'SSL_CLIENT_I_DN'];
49)         $_SESSION['clientcert_serial'] = $_SERVER[$redirect . 'SSL_CLIENT_M_SERIAL'];
50)         $vstart = new DateTime($_SERVER[$redirect . 'SSL_CLIENT_V_START']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

51)         $_SESSION['clientcert_valid_from'] = date_format($vstart, 'Y-m-d');
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

52)         $vend = new DateTime($_SERVER[$redirect . 'SSL_CLIENT_V_END']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

53)         $_SESSION['clientcert_valid_until'] = date_format($vend, 'Y-m-d');
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

54)         header('Location: ' . $prefix . $_REQUEST['backto'] . encode_querystring(''));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

55)         die();
56)     } else {
57)         warning('Ihr Browser hat kein Client-Zertifikat gesendet');
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

58)         header('Location: ' . $prefix . $_REQUEST['backto'] . encode_querystring(''));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

59)         die();
60)     }
61) } elseif (isset($_REQUEST['type']) && isset($_REQUEST['username'])) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

62)     if (!isset($_SERVER[$redirect . 'SSL_CLIENT_CERT'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

63)         system_failure('Ihr Browser hat kein Client-Zertifikat gesendet');
64)     }
bernd Login vial Client-Cert über...

bernd authored 15 years ago

65) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

66)     $ret = get_logins_by_cert($_SERVER[$redirect . 'SSL_CLIENT_CERT']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

67)     DEBUG($ret);
68)     foreach ($ret as $account) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

69)         DEBUG('/' . $account['type'] . '/' . $_REQUEST['type'] . '/    /' . $account['username'] . '/' . $_REQUEST['username'] . '/    =>');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

70)         if (($account['type'] == urldecode($_REQUEST['type'])) && ($account['username'] == urldecode($_REQUEST['username']))) {
71)             $uid = $account['username'];
72)             $role = find_role($uid, '', true);
73)             setup_session($role, $uid);
74)             $destination = 'go/index/index';
75)             if (check_path($account['startpage'])) {
76)                 $destination = $account['startpage'];
77)             }
78)             if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination'])) {
79)                 $destination = $_REQUEST['destination'];
80)             }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

81)             header('Location: ../' . ltrim($destination, '/'));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

82)             die();
83)         }
bernd Login vial Client-Cert über...

bernd authored 15 years ago

84)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

85)     system_failure('Der angegebene Account kann mit diesem Client-Zertifikat nicht eingeloggt werden.');
Bernd Wurst Warning beim Certlogin verm...

Bernd Wurst authored 5 years ago

86) } elseif ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['destination']) && $_REQUEST['destination'] != '') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

87)     # User hat sich grade eingeloggt
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

88)     header('Location: ../' . ltrim($destination, '/'));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

89) } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

90)     if (isset($_SERVER[$redirect . 'SSL_CLIENT_CERT']) &&
91)       isset($_SERVER[$redirect . 'SSL_CLIENT_S_DN']) && $_SERVER[$redirect . 'SSL_CLIENT_S_DN'] != '' &&
92)       isset($_SERVER[$redirect . 'SSL_CLIENT_I_DN']) && $_SERVER[$redirect . 'SSL_CLIENT_I_DN'] != '' &&
93)       isset($_SERVER[$redirect . 'SSL_CLIENT_M_SERIAL']) && $_SERVER[$redirect . 'SSL_CLIENT_M_SERIAL'] != '') {
94)         $ret = get_logins_by_cert($_SERVER[$redirect . 'SSL_CLIENT_CERT']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

95)         if ($ret === null) {
96)             login_screen('Ihr Browser hat ein Client-Zertifikat gesendet, dieses ist aber noch nicht für den Zugang hinterlegt. Melden Sie sich bitte per Benutzername und Passwort an.');
97)         }
98)         if (count($ret) == 1) {
99)             $uid = $ret[0]['username'];
100)             $role = find_role($uid, '', true);
101)             setup_session($role, $uid);
102)             DEBUG("Set Cookie!");
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

103)             setcookie('CLIENTCERT_AUTOLOGIN', '1', ['expires' => strtotime("+ 1 year"), 'path' => '/', 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

104)             $destination = 'go/index/index';
105)             if (check_path($ret[0]['startpage'])) {
106)                 $destination = $ret[0]['startpage'];
107)             }
108)             if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination'])) {
109)                 $destination = $_REQUEST['destination'];
110)             }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

111)             header('Location: ../' . ltrim($destination, '/'));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

112)             die();
113)         }
114)         output('<p>Ihr Browser hat ein gültiges SSL-Client-Zertifikat gesendet, mit dem Sie sich auf dieser Seite einloggen können. Allerdings haben Sie dieses Client-Zertifikat für mehrere Zugänge hinterlegt. Wählen Sie bitte den Zugang aus, mit dem Sie sich anmelden möchten.</p>
bernd Login vial Client-Cert über...

bernd authored 15 years ago

115)       <ul>');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

116)         foreach ($ret as $account) {
117)             $type = 'System-Account';
118)             if ($account['type'] == 'email') {
119)                 $type = 'E-Mail-Konto';
120)             } elseif ($account['type'] == 'subuser') {
121)                 $type = 'Unter-Nutzer';
122)             } elseif ($account['type'] == 'customer') {
123)                 $type = 'Kundenaccount';
124)             }
125)             $destination = 'go/index/index';
126)             if ($account['startpage'] && check_path($account['startpage'])) {
127)                 $destination = $account['startpage'];
128)             }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

129)             output('<li>' . internal_link('', $type . ': <strong>' . $account['username'] . '</strong>', 'type=' . $account['type'] . '&username=' . urlencode($account['username']) . '&destination=' . urlencode($destination)) . '</li>');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

130)         }
131)         output('</ul>');
132)     } else {
133)         warning('Ihr Browser hat kein Client-Zertifikat gesendet. Eventuell müssen Sie in den Einstellungen des Browsers diese Funktion einschalten.');
134)         redirect('/');
135)         die();
bernd Login vial Client-Cert über...

bernd authored 15 years ago

136)     }
137) }
138)