-
-
Notifications
You must be signed in to change notification settings - Fork 112
Handle basic credentials with colon character in the password. #78
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
base: master
Are you sure you want to change the base?
Conversation
Previous implementation: empty user-pass -> error basic realm no " " separator -> error 400 no : separator -> error basic realm empty password -> error basic realm empty username -> error basic realm New implementation: empty user-pass -> error 400 no " " separator -> error 400 no : separator -> error 400 empty password -> success empty username -> success Also fixed passwords containing ':' being truncated. This fixes: - jaredhanson/passport-http#20 - jaredhanson/passport-http#41 - jaredhanson/passport-http#42 - jaredhanson/passport-http#63 - jaredhanson/passport-http#78 The new implemementation complies with https://tools.ietf.org/html/rfc2617#section-2.
Previous implementation: empty user-pass -> error basic realm no " " separator -> error 400 no : separator -> error basic realm empty password -> error basic realm empty username -> error basic realm New implementation: empty user-pass -> error 400 no " " separator -> error 400 no : separator -> error 400 empty password -> success empty username -> success Also fixed passwords containing ':' being truncated. This fixes: - jaredhanson/passport-http#20 - jaredhanson/passport-http#41 - jaredhanson/passport-http#42 - jaredhanson/passport-http#63 - jaredhanson/passport-http#78 The new implemementation complies with https://tools.ietf.org/html/rfc2617#section-2.
Is this ever get merged? |
@jaredhanson ist there anything I can help with to get this MR merged and released to npm? |
@bodo22, I've created a fork in which I fixed some behavior including this issue. See: https://www.npmjs.com/package/passport-http-2. |
Thanks! I've created a fork myself already :). As this project has 50k npm downloads a week it would be really nice to see the changes be applied here. |
Can we know when will this be merged please ? |
Please merge this fix! |
This is mostly the following change: Corrected handling of HTTP Basic edge cases Previous implementation: empty user-pass -> error basic realm no " " separator -> error 400 no : separator -> error basic realm empty password -> error basic realm empty username -> error basic realm New implementation: empty user-pass -> error 400 no " " separator -> error 400 no : separator -> error 400 empty password -> success empty username -> success Also fixed passwords containing ':' being truncated. This fixes: - jaredhanson#20 - jaredhanson#41 - jaredhanson#42 - jaredhanson#63 - jaredhanson#78 The new implemementation complies with https://tools.ietf.org/html/rfc2617#section-2.
Would be awesome to see this merged too, we're going to get a fork for this as well, but thanks to @rudism for having done the work already! |
Per RFC 2617 Section 2: Basic Authentication Scheme, after decoding the basic authentication base64 credentials value, the
userid
is comprised of everything up to but not including the first:
character, and the password is everything after that first:
character. It seems that a strict reading would imply that passwords could themselves contain:
characters as they would be part of the text that follows the first:
character.This patch (which closes issue #20) changes the behavior of the basic authentication strategy to more closely adhere to the RFC quoted above.
Previously it was splitting the base64 decoded string on the
:
character and using the 0th element as the username, the 1st element as the password, and dropping everything else, including part of the password if it contained another:
character. After this patch it will only split the decoded value on the first:
character and include everything afterwards in the password even if it contains additional:
characters.I have added a new test to verify that passwords with
:
characters now authenticate correctly. I have not added any new documentation as this is a pretty minor code change to fix a small problem and does not significantly add to or alter any existing functionality.Checklist
$ make test
) executes successfully.$ make lint
) executes successfully.