bernd commited on 2009-03-05 09:14:11
Zeige 5 geänderte Dateien mit 107 Einfügungen und 2 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1290 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -0,0 +1,90 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once('../config.php'); |
|
4 |
+global $config; |
|
5 |
+global $prefix; |
|
6 |
+$prefix = '../'; |
|
7 |
+ |
|
8 |
+// Das Parent-Verzeichnis in den Include-Pfad, da wir uns jetzt in einem anderen Verzeichnis befinden. |
|
9 |
+ini_set('include_path', ini_get('include_path').':../'); |
|
10 |
+ |
|
11 |
+require_once('session/start.php'); |
|
12 |
+require_once('inc/base.php'); |
|
13 |
+require_once('inc/debug.php'); |
|
14 |
+require_once('inc/error.php'); |
|
15 |
+ |
|
16 |
+ |
|
17 |
+ |
|
18 |
+ |
|
19 |
+function get_logins_by_cert($cert) |
|
20 |
+{ |
|
21 |
+ $cert = mysql_real_escape_string(str_replace(array('-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----', ' ', "\n"), array(), $cert)); |
|
22 |
+ $query = "SELECT type,username,startpage FROM system.clientcert WHERE cert='{$cert}'"; |
|
23 |
+ $result = db_query($query); |
|
24 |
+ if (mysql_num_rows($result) < 1) |
|
25 |
+ return NULL; |
|
26 |
+ else { |
|
27 |
+ $ret = array(); |
|
28 |
+ while ($row = mysql_fetch_assoc($result)) { |
|
29 |
+ $ret[] = $row; |
|
30 |
+ } |
|
31 |
+ return $ret; |
|
32 |
+ } |
|
33 |
+} |
|
34 |
+ |
|
35 |
+ |
|
36 |
+if (isset($_REQUEST['type']) && isset($_REQUEST['username'])) { |
|
37 |
+ if (!isset($_ENV['REDIRECT_SSL_CLIENT_CERT'])) |
|
38 |
+ system_failure('Ihr Browser hat kein Client-Zertifikat gesendet'); |
|
39 |
+ |
|
40 |
+ $ret = get_logins_by_cert($_ENV['REDIRECT_SSL_CLIENT_CERT']); |
|
41 |
+ foreach ($ret as $account) { |
|
42 |
+ if (($account['type'] == $_REQUEST['type']) && ($account['username'] == $_REQUEST['username'])) { |
|
43 |
+ $uid = $account['username']; |
|
44 |
+ $role = find_role($uid, '', True); |
|
45 |
+ setup_session($role, $uid); |
|
46 |
+ $destination = 'go/index/index'; |
|
47 |
+ if (check_path($account['startpage'])) |
|
48 |
+ $destination = $account['startpage']; |
|
49 |
+ header('Location: ../'.$destination); |
|
50 |
+ die(); |
|
51 |
+ } |
|
52 |
+ } |
|
53 |
+ system_failure('Der angegebene Account kann mit diesem Client-Zertifikat nicht eingeloggt werden.'); |
|
54 |
+} |
|
55 |
+else |
|
56 |
+{ |
|
57 |
+ if (isset($_ENV['REDIRECT_SSL_CLIENT_CERT'])) { |
|
58 |
+ $ret = get_logins_by_cert($_ENV['REDIRECT_SSL_CLIENT_CERT']); |
|
59 |
+ if ($ret === NULL) { |
|
60 |
+ 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.'); |
|
61 |
+ } |
|
62 |
+ if (count($ret) == 1) { |
|
63 |
+ $uid = $ret[0]['username']; |
|
64 |
+ $role = find_role($uid, '', True); |
|
65 |
+ setup_session($role, $uid); |
|
66 |
+ $destination = 'go/index/index'; |
|
67 |
+ if (check_path($ret[0]['startpage'])) |
|
68 |
+ $destination = $ret[0]['startpage']; |
|
69 |
+ header('Location: ../'.$destination); |
|
70 |
+ die(); |
|
71 |
+ } |
|
72 |
+ 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> |
|
73 |
+ <ul>'); |
|
74 |
+ foreach ($ret as $account) { |
|
75 |
+ $type = 'System-Account'; |
|
76 |
+ if ($account['type'] == 'email') { |
|
77 |
+ $type = 'E-Mail-Konto'; |
|
78 |
+ } |
|
79 |
+ elseif ($account['type'] == 'customer') { |
|
80 |
+ $type = 'Kundenaccount'; |
|
81 |
+ } |
|
82 |
+ output('<li>'.internal_link('', $type.': <strong>'.$account['username'].'</strong>', 'type='.$account['type'].'&username='.urlencode($account['username'])).'</li>'); |
|
83 |
+ } |
|
84 |
+ output('</ul>'); |
|
85 |
+ } else { |
|
86 |
+ system_failure('Ihr Browser hat kein Client-Zertifikat gesendet.'); |
|
87 |
+ } |
|
88 |
+} |
|
89 |
+ |
|
90 |
+?> |
... | ... |
@@ -0,0 +1,11 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+$title = 'Login über SSL-Client-Zertifikat'; |
|
4 |
+output('<h3>Login über SSL-Client-Zertfikat</h3>'); |
|
5 |
+output('<p>Sie können Sich an diesem Interface auch per SSL-Client-Zertifikat anmelden. Dazu müssen Sie dieses Zertifikat vorab hinterlegt haben.</p> |
|
6 |
+<p>Um den Login über ein Client-Zertifikat zu nutzen, nutzen Sie bitte diesen Link:</p> |
|
7 |
+<p><strong>'.internal_link('../../certlogin/', 'Login über SSL-Client-Zertifikat').'</strong></p> |
|
8 |
+'); |
|
9 |
+ |
|
10 |
+ |
|
11 |
+ |
... | ... |
@@ -4,6 +4,7 @@ $role = $_SESSION['role']; |
4 | 4 |
|
5 | 5 |
if ($role == ROLE_ANONYMOUS) { |
6 | 6 |
$menu["index_login"] = array("label" => "Login", "file" => "index", "weight" => 0); |
7 |
+ $menu["certlogin"] = array("label" => "Client-Zertifikat", "file" => "certinfo", "weight" => 0); |
|
7 | 8 |
} else { |
8 | 9 |
if ($role & (ROLE_SYSTEMUSER | ROLE_CUSTOMER)) { |
9 | 10 |
$menu["index_chpass"] = array("label" => "Passwort ändern", "file" => "chpass", "weight" => 98); |
10 | 11 |