2 class Auth_Remote extends Plugin implements IAuthModule {
5 /* @var Auth_Base $base */
10 "Authenticates against remote password (e.g. supplied by Apache)",
15 /* @var PluginHost $host */
16 function init($host ) {
18 $this->base = new Auth_Base();
20 $host->add_hook($host::HOOK_AUTH_USER, $this);
23 function get_login_by_ssl_certificate() {
24 $cert_serial = get_ssl_certificate_id();
27 $sth = $this->pdo->prepare("SELECT login FROM ttrss_user_prefs, ttrss_users
28 WHERE pref_name = 'SSL_CERT_SERIAL' AND value = ? AND
29 owner_uid = ttrss_users.id");
30 $sth->execute([$cert_serial]);
32 if ($row = $sth->fetch()) {
41 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
43 function authenticate($login, $password) {
44 $try_login = $_SERVER["REMOTE_USER"];
47 if (!$try_login) $try_login = $_SERVER["REDIRECT_REMOTE_USER"];
48 if (!$try_login) $try_login = $_SERVER["PHP_AUTH_USER"];
50 if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
53 $user_id = $this->base->auto_create_user($try_login, $password);
56 $_SESSION["fake_login"] = $try_login;
57 $_SESSION["fake_password"] = "******";
58 $_SESSION["hide_hello"] = true;
59 $_SESSION["hide_logout"] = true;
61 // LemonLDAP can send user informations via HTTP HEADER
62 if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){
64 $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN'];
66 $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?");
67 $sth->execute([$fullname, $user_id]);
70 $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL'];
72 $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?");
73 $sth->execute([$email, $user_id]);
84 function api_version() {