Skip to content

feat: validate JWT audience when auth.audience is configured - #7

Merged
HenriBlacksmith merged 1 commit into
mainfrom
feat/jwt-audience-validation
Nov 18, 2026
Merged

HenriBlacksmith merged 1 commit into
mainfrom
feat/jwt-audience-validation

Conversation

@HenriBlacksmith

Copy link
Copy Markdown
Owner

Summary

  • Add optional audience field to AuthenticationSettings (None by default: no audience check, current behavior).
  • get_current_user passes it to jwt.decode: when configured, tokens must carry a matching aud claim (InvalidAudienceError and missing-claim errors map to 401 like other invalid tokens).
  • tests/config.yaml sets audience: model-api; the make_token fixture (and its TokenFactory protocol) accepts an audience parameter, defaulting to the configured value.
  • New parametrized test: a token with a wrong audience gets a 401 problem+json on every protected route.
  • README: move "Validate the access token audience" to Done.

@HenriBlacksmith
HenriBlacksmith merged commit aee4e22 into main Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant