tuupola/slim-basic-auth

Can't sign in

miradozk opened this issue · 10 comments

Hello,
I can't connect to my app on remote server. It works on local but not on remote server :

$application->add(new HttpBasicAuthentication([
    'realm' => 'Piso',
    'secure' => true,
    'relaxed' => ['localhost'],
    'users' => [
        'root' => '$2y$10$TJor1LmWl5Vi9Ljrqp5Fr.S5TdIUbleIei9.Ndo0gT1IO0/ELwKyK',
        'test' => 'azerty'
    ]
]));

I use "tuupola/slim-basic-auth": "^3.0" .

Thank you

What does "not working on remote server" mean? Password does not work? Do you get an error, if yes what is the error message?

Password doesn't work. No message error but the browser always asks username and password.

Are you are testing with user test using password azerty or with user root and some other password?

test and azerty as clear password and root with htpasswd -nbBC 10 root [my secret password] . It works perfectly on my localhost with apache but not on my remote server (ovh hosting)

Look at possible error logs. Look at the differences between your dev and live environment. Remove the middleware totally and see if live environment still asks for password. My bet is that there is something else such as an .htaccess file asking for the password.

I remove the middleware and it works (not protected) .

My .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

Look at logs, look for differences such as PHP version or Apache vs Nging between live and dev. Ie the usual debugging stuff. Something is apparently different in your live environment.

If you are using FastCGI this might help:

https://github.com/tuupola/slim-basic-auth#usage-with-fastcgi

Great :)