Repository navigation
feat(auth): tie service clients to issuers - #376
Conversation
Client IDs are only unique per issuer, so a client of another trusted issuer with the same client ID could act as a service client. Service clients now have an optional issuer, implied with a single trusted issuer and required with several (startup error instead of the previous warning); it must be a trusted issuer. Tokens are service tokens only if their iss claim is the client's issuer. Closes #375 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test that tokens of another issuer than the service client's are user tokens in validate_token(), and that each of several service clients needs an issuer. Resolve the implied issuer once per lookup, and list the conditions of service tokens in the docs. Refs #375 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideService clients are now explicitly tied to trusted token issuers: configuration validates issuer bindings, authentication requires an Sequence diagram for issuer-bound service token recognitionsequenceDiagram
participant Token
participant Auth as get_service_client
participant Config as AuthConfig
participant ServiceClient as ServiceClientConfig
Auth->>Config: get_token_client(claims)
Config-->>Auth: client_id
Auth->>Config: resolve trusted issuers
Auth->>ServiceClient: match client_id
Auth->>Auth: compare claims.iss with client issuer
Auth->>Auth: compare claim_identity with client subject
alt issuer and subject match
Auth-->>Token: return service client
else issuer or subject mismatch
Auth-->>Token: return None as user token
end
Flow diagram for service client issuer validationflowchart TD
A[Load AuthConfig] --> B{Trusted issuers count}
B -->|One| C[Allow omitted service client issuer]
B -->|Several| D{Every service client has issuer?}
D -->|No| E[Configuration validation fails]
D -->|Yes| F{Each issuer is trusted?}
C --> F
F -->|No| E
F -->|Yes| G[Configuration accepted]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #376 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 25 25
Lines 2120 2133 +13
=========================================
+ Hits 2120 2133 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. A token’s issuer now determines whether it receives a service client’s identity and related access-control or on-behalf-of behavior; an incorrect match could grant that treatment to the wrong issuer, or deny it to legitimate service tokens. Reverting restores the old classification, but any access or actions taken while the change was active cannot be undone.
Service clients are tied to issuers since #376, so the claims of the ownership tests name the trusted issuer. Refs #341, #354 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes #375.
Client IDs are only unique per issuer. With several trusted issuers, someone who registers a service client's ID at another trusted issuer could act as that service client, and with
on_behalf_ofcould name any user. Following the maintainer decision in #375:security.auth.service_clients[].issuer.issuerthat is one ofissuers, or FOCA fails to start. This replaces the warning added in feat(auth): support service tokens #371.issequals the client's issuer. Tokens from other issuers with the same client ID and subject are user tokens.client:<id>subjects andclient_mappingkeys are not issuer-scoped.templates/config.yaml, and the 0.16 migration guide.How it was verified
ruff format --checkandruff check foca tests: cleanmypy foca tests(strict): no issuespytest(Python 3.13, with MongoDB): 1406 passed.foca/security/auth.pyandfoca/models/config.pyat 100% coverage.mkdocs build --strict: cleanDeclined review findings
Nonemeaning implied, so the config the user wrote is what gets dumped. The implied issuer is now resolved once per lookup inget_service_client.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Tie service-client recognition to token issuers to prevent cross-issuer client impersonation.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: