-
Notifications
You must be signed in to change notification settings - Fork 15
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 format restrictions on authentication tokens #1978
Conversation
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.
👍. This should also make it a bit easier to generate valid tokens at the shell, i.e. can just do openssl rand 32 | base64
.
core/src/task.rs
Outdated
@@ -632,30 +632,30 @@ pub enum AuthenticationToken { | |||
/// [2]: https://datatracker.ietf.org/doc/html/draft-dcook-ppm-dap-interop-test-design-03#section-4.3.3 | |||
/// [3]: https://datatracker.ietf.org/doc/html/draft-dcook-ppm-dap-interop-test-design-03#section-4.4.2 | |||
/// [4]: https://datatracker.ietf.org/doc/html/draft-ietf-ppm-dap-01#name-https-sender-authentication | |||
DapAuth(TokenInner), | |||
DapAuth(DapAuthTokenInner), |
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.
Consider just having these be BearerToken
and DapAuthToken
. The Inner
suffix suggests that there's some different public opaque outer type, which is not the case here.
9cb2433
to
1d0eab4
Compare
core/src/task.rs
Outdated
/// Base64 alphabet, as specified in [RFC 4648 section 5][1]. The unpadded, URL-safe Base64 string | ||
/// is the canonical form of the token and is used in configuration files, Janus aggregator API | ||
/// requests and HTTP authentication headers. | ||
/// This token is used directly in HTTP request headers without further encoding and so much be a |
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.
/// This token is used directly in HTTP request headers without further encoding and so much be a | |
/// This token is used directly in HTTP request headers without further encoding and so must be a |
1d0eab4
to
4ec61c0
Compare
This relaxes the requirements we place on authentication tokens. The last time we changed this, we required that all
DAP-Auth-Token
andAuthorization: Bearer
values were in unpadded base64url. This causes problems when using the interop test API outside of Janus's integration tests, because it's more restrictive than it used to be. In one case, I was using structured values for these, consisting of a word describing the token's role, a hyphen, and then some random hexadecimal bytes. This failed the base64url check in one case because it had an impossible length. (base64 cannot produce an output with length one more than a multiple of four, ignoring padding)This PR places different, looser, validation requirements on each kind of authentication token. For
DAP-Auth-Token
, we require that the value be a valid HTTP header value. (i.e. we exclude some nonprintable control characters) Unlike in older versions, we also require that the value be valid UTF-8. (this makes implementation simpler, and there's no need to go out of our way supporting invalid UTF-8 inside a HTTP payload) ForAuthorization: Bearer
, we check against the language described in RFC 6750. In addition to unpadded base64url, we will now support other base64 variants, compact JWT, and other formats that fit in the expanded alphabet. For both kinds of authentication tokens, we still generate their values internally by base64url-encoding random bytes.This change ought to go in now, during our pre-release window, because it makes breaking changes to variants of a public
enum
.