Bind AWS Cognito token verification to configured app client#3406
Bind AWS Cognito token verification to configured app client#3406
Conversation
🤖 Generated with GPT-5.2-Codex
Test Failure AnalysisSummary: The Root Cause: Suggested Solution: In # In test_token_verifier_defaults_audience_to_client_id
verifier = provider.get_token_verifier()
assert isinstance(verifier, AWSCognitoTokenVerifier)
assert verifier.audience == "test_client"
# In test_token_verifier_supports_audience_override
verifier = provider.get_token_verifier(audience="custom-audience")
assert isinstance(verifier, AWSCognitoTokenVerifier)
assert verifier.audience == "custom-audience"Alternatively, update the return type annotation of Detailed AnalysisFailing check: Error log: Type hierarchy:
Return type: Related Files
🤖 Analysis by marvin (Claude Sonnet 4.6) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a72ec4402d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return AWSCognitoTokenVerifier( | ||
| issuer=str(self.oidc_config.issuer), | ||
| audience=audience, | ||
| audience=audience or self.client_id, |
There was a problem hiding this comment.
Avoid forcing
aud validation on Cognito access tokens
AWSCognitoProvider.get_token_verifier now defaults audience to self.client_id, but this verifier is used against the upstream access token path (OAuthProxy._get_verification_token returns upstream_token_set.access_token) and JWTVerifier.load_access_token validates audience only against the JWT aud claim. Cognito access tokens are client-bound via the client_id claim (and may not carry a matching aud), so this change can reject otherwise valid Cognito tokens by default and break authentication unless callers explicitly override the verifier behavior.
Useful? React with 👍 / 👎.
…fier 🤖 Generated with Claude Code
|
Auto-reviewed and merging on behalf of @jlowin — CI is green (Windows OAuth proxy timeouts are pre-existing flaky tests). |
Motivation
audience, allowing a valid token issued to a different Cognito app client in the same user pool to pass verification and access protected endpoints.Description
client_idonAWSCognitoProviderand pass it as the defaultaudiencetoAWSCognitoTokenVerifier(i.e.audience=audience or self.client_id), and add unit tests to assert the default and override behaviors.Testing
uv syncsuccessfully and ran the provider-focused tests withuv run pytest tests/server/auth/providers/test_aws.py, which passed (5 passed).uv run pytest -n auto, which completed but reported unrelated failures (11 failed, 4679 passed, 2 skipped, 14 xfailed, 1 error); the AWS Cognito provider tests are green.uv run prek run --all-fileswhich failed due to a network error fetching a pre-commit hook mirror (CONNECT tunnel failed, response 403).Codex Task