cf54502a10b16c985ea28db17885d377226b6145
Bernd Wurst jQuery-based Certlogin, so...

Bernd Wurst authored 11 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst jQuery-based Certlogin, so...

Bernd Wurst authored 11 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) 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.
15) */
16) 
17) // Setze das Arbeitsverzeichnis auf das Stammverzeichnis, damit die Voraussetzungen gleich sind wie bei allen anderen Requests
18) chdir('..');
19) 
20) require_once('config.php');
21) global $prefix;
22) $prefix = '../';
23) 
24) // Das Parent-Verzeichnis in den Include-Pfad, da wir uns jetzt in einem anderen Verzeichnis befinden.
25) ini_set('include_path', ini_get('include_path').':../');
26) 
27) require_once('session/start.php');
28) require_once('inc/base.php');
29) require_once('inc/debug.php');
30) require_once('inc/error.php');
31) require_once('inc/theme.php');
32) 
33) 
34) function prepare_cert($cert)
35) {
36) 	return str_replace(array('-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----', ' ', "\n"), array(), $cert);
37) }
38) 
39) 
40) function get_logins_by_cert($cert) 
41) {
Bernd Wurst Weitere Prepared-Statements

Bernd Wurst authored 10 years ago

42) 	$cert = prepare_cert($cert);
43) 	$result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=?", array($cert));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

44) 	if ($result->rowCount() < 1)
Bernd Wurst jQuery-based Certlogin, so...

Bernd Wurst authored 11 years ago

45) 		return NULL;
46) 	else {
47) 		$ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

48) 		while ($row = $result->fetch()) {
Bernd Wurst jQuery-based Certlogin, so...

Bernd Wurst authored 11 years ago

49) 			$ret[] = $row;
50) 		}
51) 		return $ret;
52) 	}
53) }
54) 
55) DEBUG('$_SERVER:');
56) DEBUG($_SERVER);
57) 
58) header('Content-type: text/plain');
59) 
60) if (isset($_SERVER['REDIRECT_SSL_CLIENT_CERT']) && 
61)     isset($_SERVER['REDIRECT_SSL_CLIENT_S_DN']) && $_SERVER['REDIRECT_SSL_CLIENT_S_DN'] != '' && 
62)     isset($_SERVER['REDIRECT_SSL_CLIENT_I_DN']) && $_SERVER['REDIRECT_SSL_CLIENT_I_DN'] != '') {
63)   $ret = get_logins_by_cert($_SERVER['REDIRECT_SSL_CLIENT_CERT']);
64)   if ($ret === NULL) {
65)     echo 'error';
66)     die();
67)   }
68)   if (count($ret) == 1) {
69)     $uid = $ret[0]['username'];
70)     $role = find_role($uid, '', True);
71)     setup_session($role, $uid);
Bernd Wurst Cookie-based autologin when...

Bernd Wurst authored 11 years ago

72)     setcookie('CLIENTCERT_AUTOLOGIN', '1', time()+3600*24*365, '/');