feat(auth): migrate FxA token auth from Hawk to prefixed Bearer tokens - #125
Merged
Merged
Conversation
vbudhram
force-pushed
the
update-bearer
branch
2 times, most recently
from
June 25, 2026 18:12
2366762 to
c543d36
Compare
dschom
reviewed
Jul 1, 2026
| are exempt so local development against an http auth-server still works. | ||
| """ | ||
| parsed = urlparse(url) | ||
| if parsed.scheme == "http" and parsed.hostname not in _LOOPBACK_HOSTS: |
Contributor
There was a problem hiding this comment.
Should this error? Seems like a no go to not send these of TLS.
dschom
reviewed
Jul 1, 2026
|
|
||
| class HawkTokenAuth(requests.auth.AuthBase): | ||
| """A requests auth hook implementing token-based hawk auth. | ||
| _LOOPBACK_HOSTS = frozenset(("localhost", "127.0.0.1", "::1")) |
dschom
reviewed
Jul 1, 2026
| def test_emits_prefixed_bearer_header_for_session_token(self): | ||
| auth = FxATokenBearerAuth(SESSION_TOKEN, "sessionToken") | ||
| req = auth(Request()) | ||
| self.assertEqual( |
dschom
reviewed
Jul 1, 2026
| if self.apiclient is not None: | ||
| params["ts"] = str(int(self.apiclient.server_curtime())) | ||
| hawkauthlib.sign_request(req, self.id, self.auth_key, params=params) | ||
| _warn_if_token_sent_insecurely(req.url) |
Contributor
There was a problem hiding this comment.
I think this should be an error not a warning. Someone might upgrade, and this should fail fast, imo.
dschom
requested changes
Jul 1, 2026
dschom
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Looking pretty good. Two small things before approval:
- Fail fast if we aren't TLS (ie https).
- Delete the clock skew stuff. That was hawk specific, so its basically dead code with extra overhead at this point. See APIClient class.
Replace Hawk request-signing with the prefixed-Bearer scheme adopted by the auth-server (ADR-0022/0050): Authorization: Bearer <prefix>_<id>, where <id> is the existing HKDF-derived token id and <prefix> identifies the token kind (fxs/fxk/fxar/fxpf/fxpc). - Rename HawkTokenAuth to FxATokenBearerAuth; keep HawkTokenAuth as a deprecated alias that emits a DeprecationWarning. - Add TOKEN_PREFIXES kept in sync with the auth-server/auth-client tables. - Warn when a token would be sent over non-loopback plaintext HTTP, since the Bearer header is now a replayable credential. - Remove the unused hawkauthlib dependency and orphaned Hawk-only code. - Add unit tests pinning the per-kind wire format and mocked coverage of the migrated core/oauth call sites.
dschom
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace Hawk request-signing with the prefixed-Bearer scheme adopted by the auth-server (ADR-0022/0050): Authorization: Bearer _, where is the existing HKDF-derived token id and identifies the token kind (fxs/fxk/fxar/fxpf/fxpc).