#35170 [Csd]: PHP_AUTH_DIGEST differs under Apache 1.x and 2.x
| From: | lacak at users dot sourceforge dot net | Date: | Fri, 25 Nov 2005 05:13:14 +0000 |
| Subject: | #35170 [Csd]: PHP_AUTH_DIGEST differs under Apache 1.x and 2.x | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-88901@lists.php.net to get a copy of this message | ||
ID: 35170
User updated by: lacak at users dot sourceforge dot net
Reported By: lacak at users dot sourceforge dot net
Status: Closed
Bug Type: Apache2 related
Operating System: *
PHP Version: 5.1.0
Assigned To: iliaa
New Comment:
Thank you Iliaa, for fixing bug.
It is hard work to make PHP_AUTH_DIGEST assoc.array as I propose in
this report ?
Previous Comments:
------------------------------------------------------------------------
[2005-11-25 01:02:49] iliaa@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2005-11-24 09:05:53] sesser@php.net
Advertised new features should actually work.
------------------------------------------------------------------------
[2005-11-09 13:20:59] lacak at users dot sourceforge dot net
Description:
------------
PHP_AUTH_DIGEST differs under Apache 1.x and 2.x
Apache 1.x:
_SERVER["PHP_AUTH_DIGEST"]='username="user1",
realm="www.realm.sk-0",
qop="auth", algorithm="MD5", uri="/devel/php_auth.php",
nonce="nonce",
nc=00000001, cnonce="11a85ba98273fe0f5578597b1dbf3082",
opaque="opaque", response="088685b1533e542920e1c47b59696b9c"';
Apache 2.x:
_SERVER["PHP_AUTH_DIGEST"]='Digest username="cd",
realm="www.realm.sk", nonce="nonce", uri="/~cb/php_auth.php",
response="bedf1a35418a3712adc0aea22e94d9f2", opaque="opaque", qop=auth,
nc=00000001, cnonce="082c875dcb2ca740"';
Under Apache 2.x the word "Digest " is at the begining. Under Apache
1.x is not.
Resolution:
1. strip out leading "Digest " from PHP_AUTH_DIGEST in Apache 2.x
2. or add "Digest " at the begining PHP_AUTH_DIGEST in Apache 1.x (but
is redundant)
3. or the best solution is change PHP_AUTH_DIGEST to associative array
(parse string and build array elements from it; similar way how cookies
are parsed) :
(Otherwise this step must be always done in php script)
PHP_AUTH_DIGEST["username"]="user1";
PHP_AUTH_DIGEST["realm"]="www.realm.sk-0";
...
This is example in PHP how to convert PHP_AUTH_DIGEST string to array
:
foreach(explode(", ", $_SERVER["PHP_AUTH_DIGEST"] as $auth1) {
list($authkey,$authvalue)=explode("=",$auth1,2);
if (substr($authvalue,0,1)=='"' &&
substr($authvalue,-1,1)=='"')
$authvalue=substr($authvalue,1,-1); /*strip out double quotes*/
$auth[$authkey]=$authvalue;
}
/* at this point $auth array contains what we need */
Please incorporate this feature to php source code.
Thank you very much for your time and effort.
Laco.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35170&edit=1