|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-14 20:34 UTC] vahan at arminco dot com
Description:
------------
HTTP auth doesn't work because $_SERVER['PHP_AUTH_USER'] is not being set, while $_SERVER['PHP_AUTH_PW'] is there as shown by phpinfo()
to reproduce:
create this file:
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>
access the file, when it gives you the user/pass box, alter the script, adding phpinfo() in the 2nd line, and type something as user and password. phpinfo() shows PHP_AUTH_PW but no PHP_AUTH_USER. all auth fails because of this, tested on windows 2003 professional and windows 2000 sp4 servers as well, with apache 1.3.28 and php-5.0.0 installed as module.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 15:00:01 2025 UTC |
I am having the same problem. I tested using the above code and this code <? if(!isset($_SERVER['PHP_AUTH_PW'])){ header( 'WWW-Authenticate: Basic realm="Test PHP Auth"'); header( 'HTTP/1.0 401 Unauthorized'); exit; } else { phpinfo(); } ?> My server is Red Hat 9.0, Apache 1.3.31 and PHP 5.0.0 compiled with './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-mysql=/usr/' '--with-gd' '--with-mhash' '--with-xml' '--with-t1lib' '--with-ttf' '--with-freetype-dir=/usr/lib' '--with-zlib' '--with-jpeg-dir=/usr/local/lib' '--with-png-dir=/usr/lib' I have also tested it in Apache 2 on Windows XP SP1 with the same results. This is a major problem for me. I cannot upgrade to PHP 5 till this is resolved.