#127 feat(oidc): verify assertions against trusted identity providers
Originally created by: bosd
Summary
This adds the shared OIDC trust foundation that both the human SSO login in [#121] and the CI workload login in [#31] need. [#121] notes it "could share the issuer validation and trust-policy work needed for [#31]" — this is that layer, landed on its own so both features build on it instead of duplicating it.
The server gains a trust policy for external OIDC identity providers and a verifier that checks a signed assertion against it before any claim is trusted:
app/src/services/oidc.rs(new) verifies a token: theissmust exactly match a configured issuer, the signature must verify against that provider's published JWKS, the header algorithm must be one the issuer allows (asymmetric only), theaudmust contain a configured audience, andexp(andnbfwhen present) must be current within a 60s skew. The JWKS URI is discovered from/.well-known/openid-configurationwhen not set explicitly, keys are cached (10 minute TTL) and refreshed once when an unknownkey idappears. Rejections return a stableOidcErrorcode and never echo token material.server.tomlaccepts an[oidc]trust policy ([[oidc.issuers]]withissuer,audiences, optionalalgorithmsandjwks_uri). Validation requires absolute URLs over HTTPS (HTTP only for a loopback host) and rejects symmetric algorithms.AppStateholds anOption<OidcVerifier>built at startup when providers are configured.
This PR intentionally ships no login or exchange endpoint: it is the verification core those features consume.
Compatibility
No compatibility impact. [oidc] is optional and defaults to no trusted providers, so existing configurations and behavior are unchanged. Adds one dependency, jsonwebtoken (MIT), which reuses the ring version already in the tree.
Verification
cargo test --manifest-path app/Cargo.toml --all-targets --all-features --no-fail-fast— all targets pass except three pre-existingcommands::export::*tests that needscriptfrom util-linux (not installed here); they fail identically onmainand are unrelated to this change.- New
services::oidctests cover acceptance, untrusted issuer, bad/absent audience, expiry, not-before, broken signature, symmetric algorithm, unknown key with refresh, key caching, rotation, discovery, and provider failure. - New
configtests cover trusting issuers fromserver.toml, default algorithms, loopback HTTP, and rejection of remote HTTP, symmetric algorithms, and blank audiences. cargo fmt --checkandcargo check --all-targets --all-featurespass.
Checklist
- [x] I kept this pull request focused on one problem.
- [x] I added or updated tests for behavior changes, or explained why tests are not needed.
- [x] I updated the documentation and
CHANGELOG.mdwhen public behavior changed, or explained why they are not needed. - [x] I updated relevan documentation inside
/docs
Ticket changed by: dopbase