18 include_once (
'WHAT/Class.Authenticator.php');
27 if (array_key_exists(
'logout', $_COOKIE) && $_COOKIE[
'logout'] ==
"true") {
28 setcookie(
'logout',
'', time() - 3600, null, null, null,
true);
32 if (!array_key_exists(
'PHP_AUTH_USER',
$_SERVER)) {
33 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: undefined _SERVER[PHP_AUTH_USER]");
37 if (!array_key_exists(
'PHP_AUTH_PW',
$_SERVER)) {
38 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: undefined _SERVER[PHP_AUTH_PW] for user " .
$_SERVER[
'PHP_AUTH_USER']);
42 if (!is_callable(array(
46 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error: " . $this->parms{
'type'} . $this->parms{
'provider'} .
"Provider must implement validateCredential()");
50 if (!$this->provider->validateCredential(
$_SERVER[
'PHP_AUTH_USER'],
$_SERVER[
'PHP_AUTH_PW'])) {
61 $session->register(
'username', $this->
getAuthUser());
73 header(
'HTTP/1.1 401 Authentication Required');
74 header(
'WWW-Authenticate: Basic realm="' . $this->parms{
'realm'} .
'"');
75 header(
'Connection: close');
89 public function logout($redir_uri =
'')
91 setcookie(
'logout',
'true', 0, null, null, null,
true);
93 if ($redir_uri ==
'') {
94 $pUri = parse_url(
$_SERVER[
'REQUEST_URI']);
95 if (preg_match(
':(?P<path>.*/)[^/]*$:', $pUri[
'path'], $m)) {
96 $redir_uri = $m[
'path'];
99 header(
'Location: ' . $redir_uri);
106 $session->register($name,
$value);
107 return $session->read($name);
112 return $session->read($name);
119 if (!$this->auth_session) {
122 $this->auth_session->Set();
if(substr($wsh, 0, 1)!= '/') $args
tryInitializeUser($username)
setSessionVar($name, $value)
static freedomUserExists($username)
const basicAuthorizationScheme