Update of /cvsroot/phpwiki/phpwiki/lib/WikiUser
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24332/WikiUser
Modified Files:
HttpAuth.php
Log Message:
better logout, fake httpauth not yet
Index: HttpAuth.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiUser/HttpAuth.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -2 -b -p -d -r1.1 -r1.2
--- HttpAuth.php 1 Nov 2004 10:43:58 -0000 1.1
+++ HttpAuth.php 17 Dec 2004 12:31:57 -0000 1.2
@@ -31,4 +31,32 @@ extends _PassUser
}
+ // FIXME! This doesn't work yet!
+ // Allow httpauth by other method: Admin for now only
+ function _fake_auth($userid, $passwd) {
+ return false;
+
+ header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"');
+ header("Authorization: Basic ".base64_encode($userid.":".$passwd));
+ if (!isset($_SERVER))
+ $_SERVER =& $GLOBALS['HTTP_SERVER_VARS'];
+ $GLOBALS['REMOTE_USER'] = $userid;
+ $_SERVER['PHP_AUTH_USER'] = $userid;
+ $_SERVER['PHP_AUTH_PW'] = $passwd;
+ //$GLOBALS['request']->setStatus(200);
+ }
+
+ function _logout() {
+ if (!isset($_SERVER))
+ $_SERVER =& $GLOBALS['HTTP_SERVER_VARS'];
+ header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"');
+ if (strstr(php_sapi_name(), 'apache'))
+ header('HTTP/1.0 401 Unauthorized');
+ else
+ header("Status: 401 Access Denied"); //IIS and CGI need that
+ unset($GLOBALS['REMOTE_USER']);
+ unset($_SERVER['PHP_AUTH_USER']);
+ unset($_SERVER['PHP_AUTH_PW']);
+ }
+
function _http_username() {
if (!isset($_SERVER))
@@ -42,15 +70,22 @@ extends _PassUser
if (!empty($GLOBALS['REMOTE_USER']))
return $GLOBALS['REMOTE_USER'];
+ //IIS:
+ if (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
+ list($userid, $passwd) = explode(':',
base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
+ return $userid;
+ }
return '';
}
- //force http auth authorization
+ // force http auth authorization
function userExists() {
- // todo: older php's
$username = $this->_http_username();
if (empty($username) or strtolower($username) !=
strtolower($this->_userid)) {
- header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"');
- header('HTTP/1.0 401 Unauthorized');
- exit;
+ $this->_logout();
+ $user = $GLOBALS['ForbiddenUser'];
+ $user->_userid = $this->_userid = "";
+ $this->_level = WIKIAUTH_FORBIDDEN;
+ return $user;
+ //exit;
}
$this->_userid = $username;
@@ -63,4 +98,5 @@ extends _PassUser
}
+ // ignore password for now, this is checked by apache.
function checkPass($submitted_password) {
return $this->userExists()
@@ -72,16 +108,17 @@ extends _PassUser
return false;
}
-
+/*
// hmm... either the server dialog or our own.
- function PrintLoginForm (&$request, $args, $fail_message = false,
- $seperate_page = true) {
- header('WWW-Authenticate: Basic realm="'.WIKI_NAME.'"');
- header('HTTP/1.0 401 Unauthorized');
- exit;
+ function _disabled_PrintLoginForm (&$request, $args, $fail_message=false,
$seperate_page=true) {
+ $this->_logout();
+ return parent::PrintLoginForm ($request, $args, $fail_message,
$seperate_page);
}
-
+*/
}
// $Log$
+// Revision 1.2 2004/12/17 12:31:57 rurban
+// better logout, fake httpauth not yet
+//
// Revision 1.1 2004/11/01 10:43:58 rurban
// seperate PassUser methods into seperate dir (memory usage)
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
|