Bind Discord token verification to configured client_id#3405
Merged
Conversation
🤖 Generated with GPT-5.2-Codex
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.
Motivation
/api/oauth2/@meand had the required scopes regardless of which Discord application minted the token, breaking audience/client binding and enabling cross-app authentication bypass.Description
expected_client_idparameter toDiscordTokenVerifierand store it on the verifier.verify_token, compare theapplication.idreturned by Discord withexpected_client_idand reject the token if they do not match.client_idintoDiscordTokenVerifierfromDiscordProviderso provider-based usage enforces the client/audience binding automatically.client_id, add a test that rejects tokens from a different Discord application, and update an existing http-client test to satisfy the new verifier signature.Testing
uv syncsuccessfully.uv run pytest -n auto; the run surfaced unrelated, pre-existing timeouts/failures in this environment (11 failed, 4679 passed, 1 error) so the repository-wide run is not green here but failures are not related to the changes.uv run pytest tests/server/auth/providers/test_discord.py tests/server/auth/providers/test_http_client.py -n autoand both passed (26 passed).uv run prek run --all-fileswhich failed to initialize external prettier hook due to network access to pre-commit mirror (environment restriction), not due to code linting errors.Codex Task