Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

Finally found the issue and got a workaround.

Apparently my server is eating the HTTP Auth request. I tried using Laravel's recommended .htaccess Rewrite rules, but that never worked for me. I found something on php's HTTP Auth page that really helped me that user gbleyh wrote 6 years ago (http://www.php.net/manual/en/features.http-auth.php#76708)

In my root .htaccess file, I added the following line:

RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]

Which rewrites the auth rule to $_SERVER['REMOTE_USER'] where the cgi server doesn't know to consume it.

After that, I went into the compiled.php file (or the Symfony\Component\HttpFoundation Request.php if you don't have it compiled yet), and added the following lines to the top of my createRequestFromFactory function:

           if (array_key_exists('REDIRECT_REMOTE_USER', $server))
	{
		$userpass = base64_decode(substr($server["REDIRECT_REMOTE_USER"],6)) ;
		$userpass = explode(":", $userpass);
		if (  count($userpass) == 2  ){
			 $server['PHP_AUTH_USER'] = $userpass[0];
			 $server['PHP_AUTH_PW'] = $userpass[1];
		}
	}

This seems like a big hack, and remembering to add this every time I want to update laravel packages is a pain, but hopefully this helps some noobs like me in the future

Last updated 2 years ago.
0

oh yeah! That's was the solution.

Thanks you very much !

Last updated 2 years ago.
0

I just ran into this same problem with 4.1 on a server running PHP 5.3.27 and can confirm the solution does "fix" it.

But I totally agree with Calvin1864 that editing compiled.pphp or some file deep down in the vendor dir is not a great solution.

Would there be another way to fix this? Inside the laravel code base I mean? Or would a pull request to the symfony project be more appropriate?

Last updated 2 years ago.
0

Hi, I just installed Laravel 5 on my webhost and had the same issue: basic auth not accepting my credentials.

Your solution worked, but instead of adding the code to the compiled file or the vendor file, I changed it a little bit and added it to the top of public/index.php:

    if (array_key_exists('REDIRECT_REMOTE_USER', $_SERVER))
    {
        $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6));
        $userpass = explode(":", $userpass);
    
        if (count($userpass) == 2)
        {
            $_SERVER['PHP_AUTH_USER'] = $userpass[0];
            $_SERVER['PHP_AUTH_PW'] = $userpass[1];
        }
    }

It seems to work just fine and you can composer update.

Thanks!

Last updated 9 years ago.
0

I've run into this exact same issue in Laravel 5 and I tried implementing @ivanvermeyen's version of the fix, but it's still not working for me. Any ideas? Am I missing a step?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

calvin1864 calvin1864 Joined 10 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.