diff options
author | Andrew Dolgov <[email protected]> | 2012-08-17 14:20:55 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-17 14:22:33 +0400 |
commit | 369dbc19d6ae35c97a2306ae4821c7812e2f24b2 (patch) | |
tree | fff54920611300f99e0898874e0de04c99ac5586 /classes/auth/remote.php | |
parent | 3d2c9f5adfdc51642143d9fecf31ee353735bb8e (diff) |
rework class system to use subdirectories
add placeholder plugin/hook system
Diffstat (limited to 'classes/auth/remote.php')
-rw-r--r-- | classes/auth/remote.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/classes/auth/remote.php b/classes/auth/remote.php new file mode 100644 index 000000000..6892a3528 --- /dev/null +++ b/classes/auth/remote.php @@ -0,0 +1,61 @@ +<?php +class Auth_Remote extends Auth_Base { + function get_login_by_ssl_certificate() { + $cert_serial = db_escape_string(get_ssl_certificate_id()); + + if ($cert_serial) { + $result = db_query($this->link, "SELECT login FROM ttrss_user_prefs, ttrss_users + WHERE pref_name = 'SSL_CERT_SERIAL' AND value = '$cert_serial' AND + owner_uid = ttrss_users.id"); + + if (db_num_rows($result) != 0) { + return db_escape_string(db_fetch_result($result, 0, "login")); + } + } + + return ""; + } + + + function authenticate($login, $password) { + $try_login = db_escape_string($_SERVER["REMOTE_USER"]); + + if (!$try_login) $try_login = $this->get_login_by_ssl_certificate(); +# if (!$try_login) $try_login = "test_qqq"; + + if ($try_login) { + $user_id = $this->auto_create_user($try_login); + + if ($user_id) { + $_SESSION["fake_login"] = $try_login; + $_SESSION["fake_password"] = "******"; + $_SESSION["hide_hello"] = true; + $_SESSION["hide_logout"] = true; + + // LemonLDAP can send user informations via HTTP HEADER + if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){ + // update user name + $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN']; + if ($fullname){ + $fullname = db_escape_string($fullname); + db_query($this->link, "UPDATE ttrss_users SET full_name = '$fullname' WHERE id = " . + $user_id); + } + // update user mail + $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL']; + if ($email){ + $email = db_escape_string($email); + db_query($this->link, "UPDATE ttrss_users SET email = '$email' WHERE id = " . + $user_id); + } + } + + return $user_id; + } + } + + return false; + } +} + +?> |