Repository navigation
v0.2.0-alpha.1
Pre-releaseSecond alpha. Post-audit release: fixes silent-drop bugs from
0.1.0-alpha.1, restores JVM 1.x + JVM 2.0 contract parity where
downstream DSLs depend on it, adds TARA integration coverage, adds
an admin-token gate on state-changing endpoints, and lands a
Postgres session store as an alternative to the default in-memory
one.
Still alpha. Two significant features are spec'd but not
implemented:
mint-jwt-from-session— no endpoint yet for deriving a
TIM-signed service JWT from an OAuth2 session. Downstream
services calling TIM-behind-Ruuter for authorised APIs still
need to hit/auth/session/validateper request or generate
a fresh JWT via the admin gate.- PKCE — the authorization code flow does not send PKCE
parameters. Providers that mandate PKCE (some TARA and Google
client registrations do) will reject the login.
Live-fire testing against real TARA / Google sandboxes has NOT
been done — the TARA integration tests use a mock IdP.
Test coverage at release
96 tests total, --test-threads=1:
| Binary | Count | Purpose |
|---|---|---|
cargo test --lib |
42 | Config validation, crypto primitives, session-store semantics, admin gate, JWKS parsing, ID-token helpers |
it_jwt_lifecycle |
7 | Custom JWT generate → validate → extend → revoke |
it_legacy_compat |
15 | All eight JVM 1.x cookie-borne endpoints end-to-end |
it_oauth2 |
6 | Provider registry, session-auth surfaces, health |
it_oauth2_callback |
3 | End-to-end OAuth2 callback with a mock IdP |
it_oauth2_tara |
7 | TARA-specific claim shape + five rejection paths |
it_regression_findings |
11 | Regression tests for behaviours fixed post-audit |
Fixed — security-relevant
- OIDC ID-token verification is now performed on every callback.
Signature (via the provider's cached JWKS),iss(must match
discovery.issuer),aud(must containclient_id),exp,
nbf,iat(with configurable clock skew), and mandatorynonce
comparison — all constant-time where relevant. Refusesalg=none
and symmetric algorithms outright. The 0.1.0-alpha.1 callback did
not verify the ID token at all. - Mandatory
nonceon ID tokens. A missingnonceclaim is
now a hard rejection; the previous behaviour silently accepted
tokens without a nonce claim. oauth2.session_storeconfig value is enforced. Values other
than"memory"or"postgres"fail at startup.- Session TTL is capped at
min(configured_ttl_seconds, expires_in-from-IdP); oversizedexpires_inno longer
produces an immortal session. POST /jwt/custom/list/mechecks the denylist. Revoked
bearer tokens can no longer enumerate the caller's other
tokens until natural expiry.- Admin-token gate on state-changing custom-JWT endpoints.
/jwt/custom/generate,/revoke,/revoke/bulk,/extend
now requireX-TIM-Admin-Token:orAuthorization: Bearer <admin>.
Configured viasecurity.admin_token_env. Startup refuses
whenrequire_admin_token: true(default) and the env var is
missing.
Fixed — OAuth2 / OIDC
- Callback bubbles IdP
error=responses as structured 400
instead of "missing field code" schema-validation errors. redirect_uriper-provider allow-list via
oauth2.providers.<id>.allowed_redirect_uris. Caller-supplied
URIs must match an entry exactly; falls back to the first
entry when the caller omits.- Discovery documents are validated for required fields plus
grant_types_supported: authorization_codeand
response_types_supported: code. - Discovery fetch retries with exponential backoff on 5xx and
network errors (three attempts). 4xx fails fast. token_validation.clock_skew_seconds/cache_ttl_seconds
are consumed by the ID-token verifier — previously they were
parsed but ignored.auth.oauth_staterows have an age cap enforced in the
DELETE ... RETURNINGclause. Default 300 s (JVM 2.0 parity).
A background sweeper reaps stale rows every
session_sweep_interval_seconds(default 60 s).- Session ID transport moved to headers —
Authorization: Bearer sess_<id>orX-TIM-Session: <id>are the primary
transports. Legacy?session_id=<id>query still accepted for
backward compatibility. server.public_base_urlconfig field replaces the hardcoded
http://localhost:8085callback synthesis. Empty means "caller
must pass?redirect_uri=explicitly."provider.claim_mappingscan now target registered JWT
claims (sub,iss,aud). TARA's personal-code mapping
(personal_code: "sub") works correctly.
Fixed — Custom JWT lifecycle
POST /jwt/custom/revokereturns 409 on idempotent repeat;
matches JVM 2.0's semantics.POST /jwt/custom/validatereturns 401 on invalid/expired/
revoked tokens; the body'svalid/active/reasonfields
still carry the details. Matches JVM 2.0.POST /jwt/custom/generatereturnsstatus: "created";
POST /jwt/custom/extendreturnsstatus: "extended".
Response-shape parity with JVM 2.0.setCookie: truein request body actually emitsSet-Cookie
on the response. Attributes:Path=/; HttpOnly; Secure; SameSite=Lax(addsSecure+SameSitebeyond JVM defaults).token_type: "custom_jwt"claim is signed into every custom
JWT at generate time; extended tokens preserve or backfill it.POST /jwt/custom/extenddefault TTL is 60 minutes when the
caller omitsexpirationInMinutes(JVM 2.0 parity).POST /jwt/custom/list/mepagination accepts JVMpage
semantics (offset= page number,limit= page size, default
20); response carries bothpage/size/total_pagesand
offset/limit(row shape). Opt-inby_row: trueinterprets
offsetas row offset.jwt_namefilter is honoured onPOST /jwt/custom/list/me
(was silently ignored in JVM 2.0).POST /introspectreturns uniform{"active": false}on
every inactive path (unknown, revoked, expired, wrong issuer,
bad signature).POST /introspectaccepts JSON or form even without a
Content-Type header (best-effort parse).
Added — legacy compatibility endpoints
Restored the eight cookie-borne endpoints the original Buerokratt
TIM exposed and JVM 2.0 dropped. These coexist with the modern
header/body shapes — nothing was replaced.
GET /healthz— alias forGET /health.GET /jwt/verification-key— signing public key as PKCS#1 PEM.GET /jwt/userinfo— read JWT from configured cookie name.POST /jwt/custom-jwt-verify— verify JWT from cookie named in body.POST /jwt/custom-jwt-userinfo— read JWT from cookie named in body.POST /jwt/custom-jwt-extend— admin-gated; extend + refresh cookie.GET /jwt/extend-jwt-session— admin-gated; extend default cookie.POST /jwt/custom-jwt-blacklist— admin-gated; body = cookie name.POST /jwt/blacklist— admin-gated; three modes (cookie /
?jwt=<uuid>/?sessionId=<id>). Returns real status codes
(200 / 409 / 404) instead of JVM 1.x's "always 200."
Config knob for the cookie name: jwt.cookie_name (default "jwt";
set to "JWTTOKEN" for JVM 1.x DSL parity).
Added — TARA (Estonian eID) integration
Config-only integration. Full "TARA" section added to the OAuth2
book chapter covering:
- Provider block for
tara-test.ria.eeandtara.ria.ee. - Claim mapping:
personal_code: "sub",first_name: "given_name",
last_name: "family_name",acr,amr,date_of_birth. - Scope semantics (
openid,openid phone,openid idcard,
openid mid). - Test-vs-prod discovery URL swap.
- LoA policy hand-off (target extracts
acr; downstream services
enforce policy).
Integration coverage: 7 test cases exercising personal-code
- Estonian UTF-8 round-trip,
acr/amrarray shape,
issuer/kid/alg=none/expiry rejection paths, and
profile_attributesnot being silently promoted.
Added — HTTP security posture
security.admin_token_env— env var name holding the
privileged-endpoint token. Constant-time comparison.- CORS layer via
security.cors_allowed_origins. - Response-header middleware —
Content-Security-Policy,
Strict-Transport-Security,X-Frame-Options,
X-Content-Type-Options,Referrer-Policy— all configurable,
emitted by default with conservative values. - Boot-time diagnostic pass —
AppConfig::diagnose()logs
every parsed config field at INFO with WARN on non-secure or
operator-attention-required settings. Grep for
tim::config::diagnosein logs.
Added — Postgres session store
oauth2.session_store: "postgres"persists sessions across
process restart and spans replicas. Profile data (which may
contain IdP-derived PII) is AEAD-encrypted at rest via
chacha20poly1305 using a 32-byte key from
oauth2.session_encryption_key_env(default
TIM_SESSION_ENCRYPTION_KEY). Startup refuses if the key env
var is unset or malformed.- Background sweeper deletes expired sessions + stale
oauth_state rows everyoauth2.session_sweep_interval_seconds
(default 60 s). SessionStoretrait withMemoryStoreandPostgresStore
backends. Selected by config at startup.
Added — Config / lifecycle knobs
server.public_base_url— externally-reachable URL used to
synthesise the default OAuth2 callback URL.database.acquire_timeout_seconds/idle_timeout_seconds/
max_lifetime_seconds— pool tuning.test_before_acquire(true)
transparently to PgBouncer bouncing.oauth2.session_ttl_seconds(24 h default),state_max_age_seconds
(5 min default),session_sweep_interval_seconds(60 s default).serde(deny_unknown_fields)onAppConfigand every nested
struct — a typo intim.yamlnow fails at startup rather than
silently defaulting.
Known API-shape changes vs. JVM 2.0
Additive or documented; no field removed. Callers unaffected in the
common case:
GET /jwt/keys/publicreturns a bare RFC 7517 JWKS
({"keys":[…]}), not JVM 2.0's{"jwk": "<stringified JWKS>"}
wrapper. Legacy callers useGET /jwt/verification-keyfor the
PKCS#1 PEM shape instead.- List response carries both pagination shapes
(page/size/total_pagesANDoffset/limit). Set-Cookieattributes addSecureandSameSite=Lax
where JVM 1.x omitted both.