auth_proxy draft
This commit is contained in:
parent
c925f4e3fd
commit
7e1a483db2
1 changed files with 53 additions and 0 deletions
53
plugins/auth_proxy/init.php
Normal file
53
plugins/auth_proxy/init.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
class Auth_Proxy extends Plugin implements IAuthModule {
|
||||
|
||||
private $host;
|
||||
/* @var Auth_Base $base */
|
||||
private $base;
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"Trust proxy X-Forwarded-User. May be dangerous, see doc",
|
||||
"boyska",
|
||||
true);
|
||||
}
|
||||
|
||||
/* @var PluginHost $host */
|
||||
function init($host ) {
|
||||
$this->host = $host;
|
||||
$this->base = new Auth_Base();
|
||||
|
||||
$host->add_hook($host::HOOK_AUTH_USER, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
function authenticate($login, $password) {
|
||||
// TODO: check source ip!
|
||||
if(!array_key_exists("HTTP_X_FORWARDED_USER", $_SERVER)) {
|
||||
return false;
|
||||
}
|
||||
$try_login = $_SERVER["HTTP_X_FORWARDED_USER"];
|
||||
|
||||
if ($try_login) {
|
||||
$user_id = $this->base->auto_create_user($try_login, $password);
|
||||
|
||||
if ($user_id) {
|
||||
$_SESSION["fake_login"] = $try_login;
|
||||
$_SESSION["fake_password"] = "******";
|
||||
$_SESSION["hide_hello"] = true;
|
||||
$_SESSION["hide_logout"] = true;
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function api_version() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue