mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-14 19:08:25 +00:00
fix HTTP Basic Auth on FastCGI PHP
This commit is contained in:
parent
51963ab8fc
commit
41851d60b4
2 changed files with 10 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
|
|
|
@ -82,6 +82,15 @@ class BasicAuthenticate extends BaseAuthenticate {
|
|||
* @return mixed Either false or an array of user information
|
||||
*/
|
||||
public function getUser(CakeRequest $request) {
|
||||
if(!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
if (isset($_SERVER['HTTP_AUTHORIZATION']) && (strlen($_SERVER['HTTP_AUTHORIZATION']) > 0)) {
|
||||
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
|
||||
if( strlen($_SERVER['PHP_AUTH_USER']) == 0 || strlen($_SERVER['PHP_AUTH_PW']) == 0 ) {
|
||||
unset($_SERVER['PHP_AUTH_USER']);
|
||||
unset($_SERVER['PHP_AUTH_PW']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$username = env('PHP_AUTH_USER');
|
||||
$pass = env('PHP_AUTH_PW');
|
||||
|
||||
|
|
Loading…
Reference in a new issue