Skip to main content
This page documents MobKit v0.8.34 (mirrored from v0.8.34). MobKit authenticates protected console, REST, JSON-RPC, Flow Editor, and SSE requests with JWTs. Signature and claim validation establishes a principal; AuthPolicy then applies provider matching and an exact principal allowlist. The reference HTTP router deliberately leaves only its shells, static assets, and health endpoint public.

Auth providers

These values classify an already validated token; MobKit does not run the provider’s browser OAuth login flow. An absent or unrecognized provider claim maps to GenericOidc. A token with actor_type = "service", or a principal beginning with svc:, maps to ServiceIdentity.

Auth policy

AuthPolicy selects one default user identity provider. Service identities use their own path and do not need to match that default:

JWT validation

MobKit’s low-level JWT implementation supports HS256, RS256, and ES256 with P-256 keys. For a token backed by a parsed JWKS document, use the helpers in this order:
1

Header inspection

Parse the JWT header to extract the signing algorithm (alg) and key ID (kid):
The header parser does not validate the signature. It only returns alg and optional kid for the next steps.
2

Key selection

Select a key by the token’s optional kid and algorithm:
3

Signature verification

Build the algorithm-specific verification key, then validate the signature, issuer, audience, expiry, and not-before claims:
The validated JWT contains the claims (subject, email, issuer, expiration).
validate_jwt_locally is the narrower HS256 convenience helper. It always builds an HMAC key from JwtValidationConfig.shared_secret; it is not the general RS256 or ES256 entry point.

Fixed trusted OIDC snapshot

The reference console auth path reads a fixed, host-trusted snapshot from RuntimeDecisionState.trusted_oidc:
This path parses the issuer and JWKS URI from discovery_json, selects a key from the supplied jwks_json, and requires the configured audience. It does not fetch the JWKS URI, cache remote keys, or refresh on an unknown kid. Rotate keys by replacing the trusted snapshot through the host’s configuration path. Caller-supplied discovery, JWKS, and audience query parameters are ignored.

Refreshable JwksCache

JwksCache is a separate helper for hosts that wrap an Axum router with with_auth_layer:
The cache fetches discovery and JWKS documents on first use, refreshes at its configured interval, and forces one refresh when no key matches the token. It fails closed unless an audience is configured. Expected issuer checking is optional and comes from JwksCacheConfig; it is not implicitly copied from the discovery document. This middleware accepts only an Authorization: Bearer <token> header. It does not implement the console router’s auth_token query parameter.

HS256 shared secrets

For an explicitly trusted HMAC JWK, the extraction helper takes that JWK and returns the decoded secret:
The fixed trusted_oidc console path accepts HS256 only when both the issuer and JWKS URI use a development host (localhost, loopback, or a .localhost name). JwksCache rejects HS256 by default unless the host calls .allow_hs256(true). Prefer RS256 or ES256 for production OIDC.

Console access enforcement

After JWT validation, the provider and allowlist step is enforced by enforce_console_route_access. This function evaluates policy; it does not verify the JWT itself:

Enforcement rules

  1. If console_policy.require_app_auth is false, this provider/allowlist check allows the request; read-only policy and optional ABAC remain separate
  2. ServiceIdentity uses its prefix and allowlist checks without matching the default user provider
  3. Every other request provider must match auth_policy.default_provider
  4. TestProvider is rejected even when it is the configured default
  5. The principal must appear exactly in auth_policy.email_allowlist
Console HTTP routes are designed for explicit bearer-token authentication. If a deployment puts cookie-based auth in front of the console, the deployment must also enforce CSRF/origin checks for mutation routes.

HTTP surface boundary

In the reference app router, these surfaces remain public even when require_app_auth is true:
  • /, /favicon.ico, and /healthz
  • /console, /console/, and /console/assets/*
  • /flow-editor, /flow-editor/, and /flow-editor/assets/*
Console JSON, JSON-RPC, timeline, blob, Flow Editor RPC, and all MobKit SSE surfaces honor require_app_auth. When enabled, they accept either Authorization: Bearer <token> or an exact auth_token query parameter. Query values are percent-decoded, so callers must URL-encode reserved characters. Prefer the header except where a browser or SSE bootstrap requires a query token.

Service identity

Service accounts use the ServiceIdentity provider with emails prefixed by svc::
Service identities are validated separately:
  • The email must start with svc: and have content after the prefix
  • The full svc: identity must appear in the allowlist

Validation errors

See also