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
Require Colon in Basic Auth #1474
Conversation
self.user = user | ||
self.pass = pass | ||
self.hasAuth = true | ||
var header = typeof pass !== 'undefined' ? user + ':' + pass : user | ||
var header = user + ':' + pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could that be
var header = user + ':' + (pass === undefined ? '' : pass)
or if null
is supposed to be a falsy value like it should
var header = user + ':' + (pass || '')
Added a small comment, other than that if the RFC say so, it should be that way 👍 |
@simov Addressed your feedback |
@@ -22,8 +22,6 @@ tape('setup', function(t) { | |||
ok = true | |||
} else if ( req.headers.authorization === 'Basic ' + new Buffer(':pass').toString('base64')) { | |||
ok = true | |||
} else if ( req.headers.authorization === 'Basic ' + new Buffer('user').toString('base64')) { | |||
ok = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep this test and change ok to false, so we'll have a regression test for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these lines gives us the regression test, since the default is ok = false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the explanation.
LGTM 😎 |
Going by RFC 2617, it seems that a colon is required in the base64 encoded user-pass.
https://www.ietf.org/rfc/rfc2617.txt
Some servers handle the case of a missing colon, but others do not. For instance, the standard method in Golang for parsing basic auth requires a colon.
http://golang.org/src/net/http/request.go?s=16575:16641#L518
Rather than force users to specify an empty string, it would be preferable to treat an undefined password as an empty string.