1aaaa700cdfda9c1e0bd92741205d07d8e0132de
bernd Login vial Client-Cert über...

bernd authored 15 years ago

1) <?php
2) 
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

3) chdir('..');
4) 
5) require_once('config.php');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

6) global $prefix;
7) $prefix = '../';
8) 
9) // Das Parent-Verzeichnis in den Include-Pfad, da wir uns jetzt in einem anderen Verzeichnis befinden.
10) ini_set('include_path', ini_get('include_path').':../');
11) 
12) require_once('session/start.php');
13) require_once('inc/base.php');
14) require_once('inc/debug.php');
15) require_once('inc/error.php');
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

16) require_once('inc/theme.php');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

17) 
18) 
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

19) function prepare_cert($cert)
20) {
21) 	return str_replace(array('-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----', ' ', "\n"), array(), $cert);
22) }
bernd Login vial Client-Cert über...

bernd authored 15 years ago

23) 
24) 
25) function get_logins_by_cert($cert) 
26) {
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

27) 	$cert = mysql_real_escape_string(prepare_cert($cert));
bernd Login vial Client-Cert über...

bernd authored 15 years ago

28) 	$query = "SELECT type,username,startpage FROM system.clientcert WHERE cert='{$cert}'";
29) 	$result = db_query($query);
30) 	if (mysql_num_rows($result) < 1)
31) 		return NULL;
32) 	else {
33) 		$ret = array();
34) 		while ($row = mysql_fetch_assoc($result)) {
35) 			$ret[] = $row;
36) 		}
37) 		return $ret;
38) 	}
39) }
40) 
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

41) DEBUG('$_SERVER:');
42) DEBUG($_SERVER);
43) 
bernd Login vial Client-Cert über...

bernd authored 15 years ago

44) 
bernd Ermögliche Angabe einer Red...

bernd authored 14 years ago

45) if ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['record']) && isset($_REQUEST['backto']) && check_path($_REQUEST['backto']))
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

46) {
47)   DEBUG('recording client-cert');
bernd Cert-Login geht jetztauch m...

bernd authored 13 years ago

48)   if (isset($_SERVER['REDIRECT_SSL_CLIENT_CERT']) && isset($_SERVER['REDIRECT_SSL_CLIENT_S_DN']) && isset($_SERVER['REDIRECT_SSL_CLIENT_I_DN']))
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

49)   {
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

50)     $_SESSION['clientcert_cert'] = prepare_cert($_SERVER['REDIRECT_SSL_CLIENT_CERT']);
51)     $_SESSION['clientcert_dn'] = $_SERVER['REDIRECT_SSL_CLIENT_S_DN'];
52)     $_SESSION['clientcert_issuer'] = $_SERVER['REDIRECT_SSL_CLIENT_I_DN'];
bernd Bug im Client-Zertfikat-Man...

bernd authored 14 years ago

53)     header('Location: '.$prefix.$_REQUEST['backto'].encode_querystring(''));
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

54)     die();
55)   }
56)   else
57)   {
58)     system_failure('Ihr Browser hat kein Client-Zertifikat gesendet');
59)   }
60) }
61) elseif (isset($_REQUEST['type']) && isset($_REQUEST['username'])) {
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

62)   if (!isset($_SERVER['REDIRECT_SSL_CLIENT_CERT'])) 
bernd Login vial Client-Cert über...

bernd authored 15 years ago

63)     system_failure('Ihr Browser hat kein Client-Zertifikat gesendet');
64) 
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

65)   $ret = get_logins_by_cert($_SERVER['REDIRECT_SSL_CLIENT_CERT']);
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

66)   DEBUG($ret);
bernd Login vial Client-Cert über...

bernd authored 15 years ago

67)   foreach ($ret as $account) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

68)     DEBUG('/'.$account['type'].'/'.$_REQUEST['type'].'/    /'.$account['username'].'/'.$_REQUEST['username'].'/    =>');
69)     if (($account['type'] == urldecode($_REQUEST['type'])) && ($account['username'] == urldecode($_REQUEST['username']))) {
bernd Login vial Client-Cert über...

bernd authored 15 years ago

70)       $uid = $account['username'];
71)       $role = find_role($uid, '', True);
72)       setup_session($role, $uid);
73)       $destination = 'go/index/index';
74)       if (check_path($account['startpage']))
75)         $destination = $account['startpage'];
bernd Ermögliche Angabe einer Red...

bernd authored 14 years ago

76)       if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination']))
77)         $destination = $_REQUEST['destination'];
bernd Login vial Client-Cert über...

bernd authored 15 years ago

78)       header('Location: ../'.$destination);
79)       die();
80)     }
81)   }
82)   system_failure('Der angegebene Account kann mit diesem Client-Zertifikat nicht eingeloggt werden.');
83) }
84) else
85) {
bernd Freundlichere Fehlermeldung...

bernd authored 12 years ago

86)   if (isset($_SERVER['REDIRECT_SSL_CLIENT_CERT']) && 
87)       isset($_SERVER['REDIRECT_SSL_CLIENT_S_DN']) && $_SERVER['REDIRECT_SSL_CLIENT_S_DN'] != '' && 
88)       isset($_SERVER['REDIRECT_SSL_CLIENT_I_DN']) && $_SERVER['REDIRECT_SSL_CLIENT_I_DN'] != '') {
bernd PHP 5.3: es gibt kein $_ENV...

bernd authored 14 years ago

89)     $ret = get_logins_by_cert($_SERVER['REDIRECT_SSL_CLIENT_CERT']);
bernd Login vial Client-Cert über...

bernd authored 15 years ago

90)     if ($ret === NULL) {
91)       system_failure('Ihr Browser hat ein Client-Zertifikat gesendet, dieses ist aber noch nicht für den Zugang hinterlegt. Gehen Sie bitte zurück und melden Sie sich bitte per Benutzername und Passwort an.');
92)     }
93)     if (count($ret) == 1) {
94)       $uid = $ret[0]['username'];
95)       $role = find_role($uid, '', True);
96)       setup_session($role, $uid);
97)       $destination = 'go/index/index';
98)       if (check_path($ret[0]['startpage']))
99)         $destination = $ret[0]['startpage'];
bernd Ermögliche Angabe einer Red...

bernd authored 14 years ago

100)       if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination']))
101)         $destination = $_REQUEST['destination'];
bernd Login vial Client-Cert über...

bernd authored 15 years ago

102)       header('Location: ../'.$destination);
103)       die();
104)     }
105)     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>
106)       <ul>');
107)     foreach ($ret as $account) {
108)       $type = 'System-Account';
109)       if ($account['type'] == 'email') {
110)         $type = 'E-Mail-Konto';
111)       }
bernd Cert-Login geht jetztauch m...

bernd authored 13 years ago

112)       elseif ($account['type'] == 'subuser') {
113)         $type = 'Unter-Nutzer';
114)       }
bernd Login vial Client-Cert über...

bernd authored 15 years ago

115)       elseif ($account['type'] == 'customer') {
116)         $type = 'Kundenaccount';
117)       }
bernd Situation repaiert, wenn ei...

bernd authored 14 years ago

118)       $destination = 'go/index/index';
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

119)       if ($account['startpage'] && check_path($account['startpage']))
bernd Situation repaiert, wenn ei...

bernd authored 14 years ago

120)         $destination = $account['startpage'];
bernd Ermögliche Angabe einer Red...

bernd authored 14 years ago

121)       output('<li>'.internal_link('', $type.': <strong>'.$account['username'].'</strong>', 'type='.$account['type'].'&username='.urlencode($account['username']).'&destination='.urlencode($destination)).'</li>');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

122)     }
123)     output('</ul>');
124)   } else {
bernd Freundlichere Fehlermeldung...

bernd authored 12 years ago

125)     title('Kein Client-Zertifikat');
126)     output('<p>Ihr Browser hat kein Client-Zertifikat gesendet. Eventuell müssen Sie in den Einstellungen des Browsers diese Funktion einschalten.</p>');
127)     output('<p>Bitte verwenden Sie <a href="/">die reguläre Anmeldung mit Benutzername und Passwort</a>.</p>');
bernd Login vial Client-Cert über...

bernd authored 15 years ago

128)   }
129) }
130) 
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

131) show_page('certlogin');