-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentification error #89
Comments
If comma separated authorization is allowed by RFC I agree it should be fixed. If not I think it is not this middlewares responsibility to fix broken requests. Need to read about this a bit but for example rfc2616 says: https://www.ietf.org/rfc/rfc2616.txt "Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma." |
Apparently also author of the spec says it is not valid to specify multiple Authorization fields. "You can only use multiple header fields when they are defined using list syntax." I see two options. Basic Auth middleware could use |
I also encountered this bug, but in the context of an nginx reverse proxy Docker container in front of my Slim app. I should note, however, that the bug might be in the echo getallheaders()["authorization"];
// Basic a1b2c3
echo $request->getHeaderLine("Authorization");
// Basic a1b2c3,Basic a1b2c3 A simple and reasonable fix for this is to constrain the expression in the if (preg_match("|^Basic\s+([A-Za-z0-9+/]+={0,2})|i", $request->getHeaderLine("Authorization"), $matches)) { This change swaps out the "lazy" I can make a PR if this looks acceptable to you. |
It seems to be an issue with
|
Hello,
I found a bug in the authentification, it may be complicated to reproduce, but i will try to provides as many details as possible.
I am using this package in a php-slim4 application, the application is hosted on AWS with an ALB (application load balancer) in a very standard format. For strange reasons, the Authorization header is duplicated and
$request->getHeaderLine('Authorization')
returnBasic cm9vdDp0MDBy,Basic cm9vdDp0MDBy
.I use a Psr\Http\Message\MessageInterface and the getHeaderLine() description state:
Retrieves a comma-separated string of the values for a single header.
Here is the function in slim/psr7/message.php
In this (rare) case, the following code doesn't match anything and the authorization fail
I believe i can find a workaround to prevent the duplication of the header, however i think the authorization in the package can be broken because the getHeaderLine can return a coma separated string instead of the header.
The solution can be: explode(",", getHeaderLine('Authorization')) and loop through the result
I have made some research and it seems the RFC (https://tools.ietf.org/html/rfc7235#appendix-C) permit multiple entries in the authorization header, separated by a coma.
If the problem/solution seems relevant, i can make a PR
The text was updated successfully, but these errors were encountered: