Closed Mo0812 closed 3 years ago
It seems this code is somehow failing. Header names are case insensitive. Changing the header to lowercase should not affect anything. I will setup a test case and see what is happening.
This seems to be an issue with slim/psr-7
which creates two Authorization
headers when request has a lowercase header. When using some other PSR-7 implementation such as nyholm/psr7
and nyholm/psr7-server
problem does not exist.
In other words quick workaround at the moment is:
$ composer remove slim/psr7
$ composer require nyholm/psr7
$ composer require nyholm/psr7-server
Thanks for your research, the workaround fixes my problem for now. Do you already have created an issue for this in the slim/psr-7
repo?
I did. It is the https://github.com/slimphp/Slim-Psr7/issues/188.
This has been fixed in https://github.com/slimphp/Slim-Psr7/pull/195
Hey, I work with Slim 4.7 and slim-basic-auth 3.3 and realize a Basic Auth Authentification with a custom authenticator:
middleware.php
authenticator.php
I have the following problem:
When I request a secured endpoint with the HTTP Header "Authentication: Basic ..." the arguments "user" and "password" in the
$arguments
variable of the Authenticator__invoke
method are interpreted and used correctly.When I access the endpoint from a JS frontend with
fetch
, which converts the custom HTTP Headers to lowercase, like "authentication: Basic ...", the request get rejected all the time.I logged the
$arguments
input in the__invoke
method and see a difference:Even without
fetch
and JS the problem can easily reproduced with CURL by changing the spelling of "Authentication" to "authentication" as the HTTP Header field.I am not using multiple users in authentication.
Has anyone an idea where this behavior is coming from or how I can workaround/fix it?
Regards