Skip to content

Commit 362dbb4

Browse files
authored
Merge pull request phpipam#10 from GOVCERT-LU/dev/kerberos-apache
adding new feature, kerboros login over apache config
2 parents 3c0c177 + 2d4c748 commit 362dbb4

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

db/SCHEMA.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ CREATE TABLE `users` (
130130
`id` int(11) NOT NULL AUTO_INCREMENT,
131131
`username` varchar(25) CHARACTER SET utf8 NOT NULL DEFAULT '',
132132
`real_name` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
133-
`auth_method` set('local','ad') COLLATE utf8_bin NOT NULL DEFAULT 'local',
133+
`auth_method` set('local','ad', 'krb') COLLATE utf8_bin NOT NULL DEFAULT 'local',
134134
`password` char(128) COLLATE utf8_bin DEFAULT NULL,
135135
`role` set('user','operator','administrator') CHARACTER SET utf8 NOT NULL DEFAULT 'user',
136136
`email` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '',

functions/classes/class.User.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ class User extends Common_functions {
131131
* @access public
132132
*/
133133
public function __construct (Database_PDO $database) {
134-
# set result
135-
$this->Result = new Result ();
134+
if (isset( $_SERVER['REMOTE_USER'] )) { $_SESSION['trapusername'] = $_SERVER['REMOTE_USER']; }
135+
# set result
136+
$this->Result = new Result ();
136137
# Save database object
137138
$this->Database = $database;
138139
# register new session
@@ -395,6 +396,30 @@ private function auth_check_local ($username, $password) {
395396
$this->Result->show("danger", _("Invalid username or password"), true);
396397
}
397398
}
399+
400+
/**
401+
* kerberos user authentication method, authenticates users through apache kerberos
402+
* module, if user is set, authentification is ok
403+
*
404+
* @access private
405+
* @param mixed $username
406+
* @return void
407+
*/
408+
private function auth_check_krb ($username, $password) {
409+
# auth ok
410+
if(isset($_SERVER['REMOTE_USER'])) {
411+
# save to session
412+
$this->write_session_parameters ();
413+
# print success
414+
$this->Result->show("success", _("Login successful"));
415+
# write last logintime
416+
$this->update_login_time ();
417+
}
418+
# auth failed
419+
else {
420+
$this->Result->show("danger", _("Invalid username or password"), true);
421+
}
422+
}
398423

399424
/**
400425
* Authenticate against a directory

0 commit comments

Comments
 (0)