-
Notifications
You must be signed in to change notification settings - Fork 13
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
Relax constraints on bearer token format #3111
Conversation
core/src/http.rs
Outdated
let (bearer, token) = authorization | ||
.split_once(char::is_whitespace) | ||
.ok_or_else(|| anyhow!("invalid bearer token"))?; | ||
|
||
if bearer.to_lowercase() != "bearer" { |
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.
nit:
let (bearer, token) = authorization | |
.split_once(char::is_whitespace) | |
.ok_or_else(|| anyhow!("invalid bearer token"))?; | |
if bearer.to_lowercase() != "bearer" { | |
let (auth_scheme, token) = authorization | |
.split_once(char::is_whitespace) | |
.ok_or_else(|| anyhow!("invalid scheme in authorization header"))?; | |
if auth_scheme.to_lowercase() != "bearer" { |
To line up with the credentials = auth-scheme [ 1*SP ( token68 / #auth-param ) ]
in the Backaus-whatever notation.
core/src/http.rs
Outdated
Ok(Some(_)) | ||
); | ||
assert_matches!( | ||
extract_bearer_token( | ||
&TestConn::build("get", "/", "body") | ||
.with_request_header("authorization", "BeArEr gVfRUu9krhxrUgFsEo-P5w"), | ||
), | ||
Ok(Some(_)) |
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.
I think it'd be nice to check the contents of the AuthenticationToken
to make sure nothing bad happens when we call String::trim_start
.
Closes #3107. The
bearer
part is now case insensitive. Add some basic tests.I also allow whitespace between
bearer
and the token. The1*SP
part of the grammar, IIUC, indices one or more whitespace: