Repository navigation
feat: configure accepted token types - #42
Conversation
LS Login's exchanged tokens, and login tokens of its new proxy, carry `typ: JWT`, which the services refuse. `TESTBED_TOKEN_TYPES` now sets `Settings.token_types` for LS Login: a comma-separated list, compared case-insensitively. Unset keeps the RFC 9068 types; a value that names no type is an error, as it would refuse every token. Document the variable and its trade-off (accepting `JWT` lets ID tokens through, so only `aud` tells them apart), and answer the T1 question on `typ`, noting FOCA's `security.auth.token_types`. Closes #41 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the validator test into accepted types and one that shows the setting replaces the default, test that the mock ignores the variable, and let `TokenValidator` default to `settings.TOKEN_TYPES`. Say in the template that login tokens of the new proxy carry `JWT`, too, and where T1 records the types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideData structuresDefine and share the RFC 9068 token-type defaults used by settings and the validator so they cannot drift.
ImplementationParse configured token types for LS Login, deduplicating case-insensitively and rejecting a configured value that names no type.
ConfigurationSet the documented default token types in the LS Login environment example.
DocumentationDocument the token-type setting and the security trade-off of accepting JWT, including its effect on distinguishing ID tokens.
Record the observed exchanged-token type in the T1 investigation and explain the corresponding FOCA setting.
TestsTest token-type defaults, LS Login list parsing and validation, empty-value errors, and that the mock ignores the setting.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
Linked issuesChecked at commit 4cf3ae3 #41 feat: configure accepted token types · 6 of 6 met
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/testbed/settings.py" line_range="277" />
<code_context>
trusted_issuers=(issuer,),
clients=clients,
algorithms=tuple(env.get("TESTBED_ALGORITHMS", "RS256").split(",")),
+ token_types=_token_types(env),
required_entitlement=env.get("TESTBED_REQUIRED_ENTITLEMENT") or None,
entitlement_claims=_entitlement_claims(env),
</code_context>
<issue_to_address>
**ID tokens authenticate as access tokens**
When an operator enables `JWT` and a user presents a signed ID token whose audience is the service’s client ID, `Service` passes the configured types to `TokenValidator`, which accepts `JWT` before checking the signature, issuer and audience; an ID token issued to that service’s client ID therefore authenticates as a bearer access token, including where no entitlement policy is configured.
Avoid treating generic `JWT` as sufficient evidence of an access token: validate a provider-guaranteed access-token marker or audience distinction, or keep this option disabled for services that cannot make that distinction.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if an operator adds JWT, an ID token from the same issuer addressed to that service’s client ID can pass the type and audience checks as an access token. Removing the setting blocks future acceptance, but does not undo any access or actions already performed using such a token.
Blocking findings: src/testbed/settings.py:277
Summary
On LS Login, exchanged access tokens (and login tokens of its new proxy) carry
typ: JWT, which the services refuse with reasontype(seen on #10). This makes the accepted types configurable:TESTBED_TOKEN_TYPES, read for the LS Login provider intoSettings.token_types: comma-separated, spaces and empty items ignored, repeats removed case-insensitively (services already comparetypcase-insensitively). Unset keeps the RFC 9068 defaultat+jwt,application/at+jwt; a value that names no type (empty, or only commas) is aValueError, as it would refuse every token.docs/setup/configuration.md, with the trade-off (acceptingJWTalso lets ID tokens of the same issuer through, so onlyaudtells them apart), and the variable with the default value inlslogin.env.example.typ,algand keys as login tokens?" is answered fortypwith what was seen, noting that FOCA nodes needsecurity.auth.token_typesset the same way.algand keys stay open.TESTBED_TOKEN_TYPESwithJWTaccepts such tokens in any case, while a list withoutat+jwtrefusesat+jwt(the setting replaces the default; the default's refusal ofJWTwas already tested).TokenValidatornow takes its default fromsettings.TOKEN_TYPES, so it can't drift.FOCA's default and asking LS Login for
at+jwt(#17) stay out of scope, as in the issue.Verification
pytest: 263 passed, coverage 100%.adversarial-reviewerandquality-reviewer, two rounds; round 1's medium (a test mixing two behaviours) and lows fixed in the second commit.mkdocs build --strict: built without warnings.pre-commit run --all-files: all hooks passed exceptactionlint, which couldn't run locally (the machine'sshellcheckshim has no version set); this PR changes no workflow. CI runs it.Declined review findings
Open questions
None.
Closes #41
🤖 Generated with Claude Code
Summary by Sourcery
Configure accepted access-token types so LS Login JWT tokens can pass validation while preserving the RFC 9068 defaults unless overridden.
New Features:
typvalues to be configured throughTESTBED_TOKEN_TYPES, including support for LS Login tokens withtyp: JWT.Bug Fixes:
Enhancements:
Documentation:
Tests: