cvs: pear /Auth_HTTP Auth_HTTP.php
| From: | Martin Jansen | Date: | Sun, 18 Jan 2004 19:06:09 +0000 |
| Subject: | cvs: pear /Auth_HTTP Auth_HTTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-15767@lists.php.net to get a copy of this message | ||
mj Sun Jan 18 14:06:09 2004 EDT
Modified files:
/pear/Auth_HTTP Auth_HTTP.php
Log:
* Some code simplification
* Try to find the authentication information in $_SERVER['HTTP_AUTHORIZATION'],
which is the place, IIS tends to use in certain situations. More
information about this behaviour can be found in the user contributed
notes on http://www.php.net/manual/en/features.http-auth.php.
This patch has been contributed by Espen Carlsen
<escarls at online dot no>.
Index: pear/Auth_HTTP/Auth_HTTP.php
diff -u pear/Auth_HTTP/Auth_HTTP.php:1.9 pear/Auth_HTTP/Auth_HTTP.php:1.10
--- pear/Auth_HTTP/Auth_HTTP.php:1.9 Sat Jan 4 06:54:44 2003
+++ pear/Auth_HTTP/Auth_HTTP.php Sun Jan 18 14:06:09 2004
@@ -16,7 +16,7 @@
// | Authors: Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Auth_HTTP.php,v 1.9 2003/01/04 11:54:44 mj Exp $
+// $Id: Auth_HTTP.php,v 1.10 2004/01/18 19:06:09 mj Exp $
//
require_once "Auth/Auth.php";
@@ -37,7 +37,7 @@
* @author Martin Jansen <mj@php.net>
* @package Auth_HTTP
* @extends Auth
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
class Auth_HTTP extends Auth
{
@@ -76,14 +76,23 @@
{
$server = &$this->_importGlobalVariable("server");
- if (isset($server['PHP_AUTH_USER']) && $server['PHP_AUTH_USER']
!= "") {
+ if (!empty($server['PHP_AUTH_USER'])) {
$this->username = $server['PHP_AUTH_USER'];
}
- if (isset($server['PHP_AUTH_PW']) && $server['PHP_AUTH_PW'] !=
"") {
+ if (!empty($server['PHP_AUTH_PW'])) {
$this->password = $server['PHP_AUTH_PW'];
}
+ /**
+ * Try to get authentication information from IIS
+ */
+ if (!isset($this->username) && !isset($this->password)) {
+ if (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
+ list($this->username, $this->password) = explode(':',
base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
+ }
+ }
+
if (isset($this->username) && isset($this->password)) {
session_id(md5("Auth_HTTP" . $this->username . $this->password));
}