91432186ce238f061b736c54b84a3b4bea12a675
bernd Login via Client-Zertifikat...

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) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
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) */
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

16) 
17) require_once('inc/security.php');
18) 
Bernd Wurst Cookie-based autologin when...

Bernd Wurst authored 11 years ago

19) function do_ajax_cert_login() {
20)   global $prefix;
Bernd Wurst Nutze zentrales JQuery

Bernd Wurst authored 10 years ago

21)   require_once('inc/jquery.php');
Bernd Wurst Login-Javascript wurde fals...

Bernd Wurst authored 10 years ago

22)   javascript('certlogin.js', 'index');
Bernd Wurst Cookie-based autologin when...

Bernd Wurst authored 11 years ago

23) }
24) 
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

25) function get_logins_by_cert($cert) 
26) {
schokokeks.org web services changes to cert login stuff

schokokeks.org web services authored 6 years ago

27) 	$result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=? ORDER BY type,username", array($cert));
Bernd Wurst Entferne Javascript-Konstru...

Bernd Wurst authored 6 years ago

28) 	if ($result->rowCount() < 1) {
29)         DEBUG("No certlogin found for this cert!");
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

30) 		return NULL;
Bernd Wurst Entferne Javascript-Konstru...

Bernd Wurst authored 6 years ago

31) 	} else {
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

32) 		$ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

33) 		while ($row = $result->fetch()) {
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

34) 			$ret[] = $row;
35) 		}
Bernd Wurst Entferne Javascript-Konstru...

Bernd Wurst authored 6 years ago

36)         DEBUG("Logins for this cert:");
37)         DEBUG($ret);
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

38) 		return $ret;
39) 	}
40) }
41) 
42) function get_cert_by_id($id) 
43) {
44)   $id = (int) $id;
45) 	if ($id == 0)
46) 	  system_failure('no ID');
Bernd Wurst Speichere und zeige Start-...

Bernd Wurst authored 8 years ago

47) 	$result = db_query("SELECT id,dn,issuer,serial,valid_from,valid_until,cert,username,startpage FROM system.clientcert WHERE `id`=?", array($id));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

48) 	if ($result->rowCount() < 1)
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

49) 		return NULL;
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

50) 	$ret = $result->fetch();
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

51)   DEBUG($ret);
52)   return $ret;
53) }
54) 
55) 
56) function get_certs_by_username($username) 
57) {
58) 	if ($username == '')
59) 	  system_failure('empty username');
Bernd Wurst Speichere und zeige Start-...

Bernd Wurst authored 8 years ago

60) 	$result = db_query("SELECT id,dn,issuer,serial,valid_from,valid_until,cert,startpage FROM system.clientcert WHERE `username`=?", array($username));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

61) 	if ($result->rowCount() < 1)
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

62) 		return NULL;
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

63) 	while ($row = $result->fetch()) {
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

64) 	  $ret[] = $row;
65) 	}
66) 	return $ret;
67) }
68) 
69) 
Bernd Wurst Speichere und zeige Start-...

Bernd Wurst authored 8 years ago

70) function add_clientcert($certdata, $dn, $issuer, $serial, $vstart, $vend, $startpage=NULL)
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

71) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

72)   $type = NULL;
73)   $username = NULL;
Bernd Wurst bugfix: (once again) most u...

Bernd Wurst authored 12 years ago

74)   if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

75)     $type = 'user';
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

76)     $username = $_SESSION['userinfo']['username'];
Bernd Wurst bugfix: missing brackets

Bernd Wurst authored 12 years ago

77)     if (isset($_SESSION['subuser'])) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

78)       $username = $_SESSION['subuser'];
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

79)       $type = 'subuser';
Bernd Wurst bugfix: missing brackets

Bernd Wurst authored 12 years ago

80)     }
Bernd Wurst bugfix: (once again) most u...

Bernd Wurst authored 12 years ago

81)   } elseif ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

82)     $type = 'email';
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

83)     $username = $_SESSION['mailaccount'];
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

84)   }
85)   if (! $type || ! $username) {
86)     system_failure('cannot get type or username of login');
87)   }
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

88)   if ($startpage &&  ! check_path($startpage))
89)     system_failure('Startseite kaputt');
bernd Cert-Login geht jetztauch m...

bernd authored 13 years ago

90) 
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

91)   if ($certdata == '')
92)     system_failure('Kein Zertifikat');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

93) 
94)   $args = array(":dn" => $dn,
95)                 ":issuer" => $issuer,
Bernd Wurst Speichere und zeige Serienn...

Bernd Wurst authored 8 years ago

96)                 ":serial" => $serial,
Bernd Wurst Speichere und zeige Start-...

Bernd Wurst authored 8 years ago

97)                 ":vstart" => $vstart,
98)                 ":vend" => $vend,
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

99)                 ":certdata" => $certdata,
100)                 ":type" => $type,
101)                 ":username" => $username,
102)                 ":startpage" => $startpage);
103)   DEBUG($args);
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

104) 
Bernd Wurst Speichere und zeige Start-...

Bernd Wurst authored 8 years ago

105)   db_query("INSERT INTO system.clientcert (`dn`, `issuer`, `serial`, `valid_from`, `valid_until`, `cert`, `type`, `username`, `startpage`) 
106) VALUES (:dn, :issuer, :serial, :vstart, :vend, :certdata, :type, :username, :startpage)", $args);
bernd Login via Client-Zertifikat...

bernd authored 15 years ago

107) 
108) }
109) 
110) 
111) function delete_clientcert($id)
112) {
113)   $id = (int) $id;
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

114)   $type = NULL;
115)   $username = NULL;
Bernd Wurst bugfix: (once again) most u...

Bernd Wurst authored 12 years ago

116)   if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

117)     $type = 'user';
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

118)     $username = $_SESSION['userinfo']['username'];
Bernd Wurst bugfix: missing brackets

Bernd Wurst authored 12 years ago

119)     if (isset($_SESSION['subuser'])) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

120)       $username = $_SESSION['subuser'];
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

121)       $type = 'subuser';
Bernd Wurst bugfix: missing brackets

Bernd Wurst authored 12 years ago

122)     }
Bernd Wurst bugfix: (once again) most u...

Bernd Wurst authored 12 years ago

123)   } elseif ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

124)     $type = 'email';
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

125)     $username = $_SESSION['mailaccount'];
bernd Ermögliche Client-Cert-Logi...

bernd authored 12 years ago

126)   }
127)   if (! $type || ! $username) {
128)     system_failure('cannot get type or username of login');
129)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

130)   db_query("DELETE FROM system.clientcert WHERE id=:id AND type=:type AND username=:username", 
131)            array(":id" => $id, ":type" => $type, ":username" => $username));