OAuth, OpenID Connect, and MCP
The runtime can act as an OAuth 2.0 authorization server and OpenID provider for your own applications. Your web application signs people in through ordinary OpenID Connect. Your APIs and remote MCP servers accept access tokens that the runtime issues for one resource and one organization. People sign in with the login sources you already run: local accounts, an upstream OIDC provider, or native SAML or an optional broker.
The issuer is optional.
Without an issuer section the runtime serves none of these endpoints, and the other capabilities work as before.
What it implements
| Area | Behavior |
|---|---|
| Flows | Authorization Code with S256 PKCE (a confidential identity-only client may opt out), rotating refresh tokens, and confidential client_credentials with explicit machine bindings. Implicit, hybrid, and password grants are unsupported. |
| Client authentication | none for public clients, and client_secret_basic or client_secret_post for confidential clients. |
| Clients | Clients in the configuration file, clients registered through the operator API, and Client ID Metadata Documents. |
| Resources | A registry of protected resources. Every API or MCP grant names one resource with the RFC 8707 resource parameter. |
| Access tokens | RS256 JWTs with typ: at+jwt (RFC 9068) whose audience is the resource URI. Resource servers also call introspection (RFC 7662) to learn the current state. |
| OpenID Connect | Discovery, ID tokens, UserInfo, nonce, prompt=none, prompt=login, prompt=consent, max_age, public subjects, and RP-initiated logout. |
| Responses | The RFC 9207 iss parameter on every authorization response. |
| Revocation | RFC 7009 token revocation, a connected-applications page for people, organization grant controls, and operator grant controls. |
The MCP profile follows the MCP authorization specification, revision 2026-07-28. The runtime is the authorization server; the MCP server is the protected resource and publishes RFC 9728 protected resource metadata.
Issuer URL and endpoints
issuer.url is the issuer identifier.
Its origin must equal server.public_url, and it can add a path such as https://id.example.com/tenant-a.
Tokens, discovery, and every client store this value.
Changing it changes the trust identifier, so clients and resource servers treat the result as a different issuer.
The runtime serves discovery at both well-known locations. For an issuer with a path, it also serves the OpenID Connect form below the path:
/.well-known/oauth-authorization-server{path}
/.well-known/openid-configuration{path}
{path}/.well-known/openid-configurationThe protocol endpoints sit below the issuer:
| Endpoint | Path |
|---|---|
| Authorization | {issuer}/oauth/authorize |
| Token | {issuer}/oauth/token |
| UserInfo | {issuer}/oauth/userinfo |
| Key set | {issuer}/oauth/jwks |
| Introspection | {issuer}/oauth/introspect |
| Revocation | {issuer}/oauth/revoke |
| Logout | {issuer}/oauth/logout |
| Connected applications (people) | {issuer}/oauth/applications |
| Protected resource metadata | {issuer}/oauth/resources/{id}/metadata |
The sign-in, organization, and approval pages also live below {issuer}/oauth/.
These pages use no scripts and send a strict content security policy.
The token and revocation endpoints accept 600 requests a minute for each client, and introspection accepts 6000 a minute for each resource.
Over the limit they answer 429 with the OAuth error slow_down.
The token, revocation, introspection and AuthZEN endpoints share a network-source limit for previously unverified credentials. A source can make 50 fresh checks in a burst. One slot refills every 18 seconds across all replicas. A fresh check consumes a slot whether its credential succeeds or fails. When the bucket is empty, new candidates receive HTTP 429 immediately. Clients behind a shared proxy share the bucket unless the runtime can resolve their individual addresses through a configured trusted proxy. Embedded routers without a peer address share a single bucket. RFC 6749, section 2.3.1
Once a credential succeeds, its exact type, public ID and secret can be checked on any network or replica while the source bucket is empty. Every request still checks the current registration, expiry and rotation state. The issuer refreshes this record on successful use at most once per hour. A new or rotated credential, or one whose last confirmation was 24 hours ago, needs an available slot. Under sustained traffic on a shared source, another caller may take the next slot. The client can also establish the credential through a source with quota.
OE uses the connection's IPv4 address or IPv6 /64. Configure server.trusted_proxies when a reverse proxy forwards the original address. Embedded HTTP servers should supply Axum's ConnectInfo<SocketAddr>. Requests without a peer address share one budget.
Configure
This example adds the issuer to a deployment that already has local accounts.
deployments/runtime.oauth.yaml is a complete development file.
issuer:
url: https://id.example.com
secret_key_env: ISSUER_SECRET_KEY
previous_secret_key_envs: []
access_token_seconds: 300
id_token_seconds: 300
code_seconds: 60
session_seconds: 28800
refresh_token_seconds: 2592000
refresh_idle_seconds: 604800
offline_access: false
key_publish_seconds: 300
clock_skew_seconds: 60
product_name: Example Studio
client_metadata_documents:
enabled: true
resources: [https://mcp.example.com/mcp]
resources:
- id: projects-api
uri: https://app.example.com/api
name: Projects API
scopes:
- { name: "projects:read", description: "See your projects" }
- { name: "projects:write", description: "Create and delete projects" }
introspection_secret_hash_env: PROJECTS_API_INTROSPECTION_SHA256
clients:
- id: example-web
name: Example Studio
client_type: confidential
secret_hash_env: EXAMPLE_WEB_CLIENT_SECRET_SHA256
redirect_uris: [https://app.example.com/oidc/callback]
post_logout_redirect_uris: [https://app.example.com/oidc/signed-out]
resources: [https://app.example.com/api]
scopes: [openid, profile, email, "projects:read", "projects:write"]secret_key_env names 32 bytes of unpadded base64url that seal the private signing keys in PostgreSQL.
Generate one with enterprise-runtime keygen.
The issuer needs the organizations capability and at least one login source: local_authentication, an OIDC connection, or administration-managed customer SSO.
| Setting | Default | Allowed range |
|---|---|---|
access_token_seconds, id_token_seconds |
300 | 30 to 3600 |
code_seconds |
60 | 10 to 600 |
session_seconds (issuer browser session) |
8 hours | 5 minutes to 7 days |
refresh_token_seconds (absolute grant lifetime) |
30 days | 5 minutes to 365 days |
refresh_idle_seconds |
7 days | 60 seconds up to refresh_token_seconds |
refresh_reuse_grace_seconds |
30 seconds | 0 to 120 seconds |
key_publish_seconds |
300 | at least 60 outside development, at most 1 day |
clock_skew_seconds |
60 | 0 to 300 |
Startup registers configured resources and clients. The management API cannot change or delete them; change the file instead.
Clients
A public client has no secret and uses token_endpoint_auth_method=none.
Use it for native apps, command-line tools, browser apps, and MCP clients.
Endpoint authentication methods
The discovery document lists these authentication methods for each endpoint.
| Endpoint | Advertised authentication methods |
|---|---|
| Token | client_secret_basic, client_secret_post, none |
| Revocation | client_secret_basic, client_secret_post, none |
| Introspection | client_secret_basic |
Public clients use none with their registered client ID. A protected resource authenticates introspection requests with its own credentials.
A confidential client authenticates with client_secret_basic or client_secret_post, one of them per request.
The runtime returns a new secret once and stores only its SHA-256 hash.
Each client registers:
- Exact redirect URIs. HTTPS is required outside
development: true, except for HTTP loopback addresses (127.0.0.1,[::1], orlocalhost) and private-use schemes. A loopback redirect may use any port at request time (RFC 8252, section 7.3); the scheme, host, path, and query must still match. Wildcards and fragments are rejected. - Post-logout redirect URIs, separately and also exact.
- The resources and scopes it may request.
organization_idsto restrict the organizations it may receive grants for. Without it, any organization the person belongs to is allowed.refresh_tokens:disabled,session(the default), oroffline. Session refresh tokens end with the browser session.offlinealso allowsoffline_accessgrants that outlive it, and the client's scopes must includeoffline_access.identity_onlyto allow OpenID Connect sign-in for people who belong to no organization yet.pkce:required(the default) oroptional. Only a confidentialidentity_onlyclient may make it optional, for an OpenID Connect relying party that doesn't send PKCE. Its requests without PKCE must ask foropenid. As OpenID Connect Core allows, they may leave out thenoncetoo, which OpenID certification tests, so the code is then protected by the client secret and the exact redirect URI. Such a code redeems only without acode_verifier, so an attacker can't add PKCE to a stolen code (RFC 9700, section 2.1.1). Requests that do send PKCE are checked as usual.trust:third_party(the default),first_party, orfirst_party_skip_consent. Onlyfirst_party_skip_consentskips the approval page, and each skipped approval writes anoauth.consent.skipped_by_policyaudit record.
Operators manage registered clients through /v1/operator/oauth/clients with the clients:manage operator scope:
| Operation | Request |
|---|---|
| Create | POST /v1/operator/oauth/clients |
| List and inspect | GET /v1/operator/oauth/clients, GET /v1/operator/oauth/clients/{client} |
| Update or disable | PUT /v1/operator/oauth/clients/{client} with enabled: false |
| Delete | DELETE /v1/operator/oauth/clients/{client} |
| Rotate the secret | POST /v1/operator/oauth/clients/{client}/secret |
Disabling or deleting a client ends its grants on their next use. A policy change that matters for security, such as new redirect URIs or broader scopes, raises the client's policy version, and earlier approvals no longer apply. Grants and pending authorization requests retain the client policy version that authorized them. A policy change ends their use, including after an operator restores the earlier policy or re-enables the client.
Client ID Metadata Documents
Client ID Metadata Documents let a client use the HTTPS URL of its metadata document as its client_id, without being registered first.
They are on by default and take effect once client_metadata_documents.resources lists a resource.
Until then, discovery does not advertise them and the runtime fetches no documents.
Set client_metadata_documents.enabled: false to turn them off.
The runtime fetches the document when an authorization starts and checks that its client_id equals the URL, that it uses token_endpoint_auth_method: none, and that its redirect URIs meet the rules above.
Such a client may request only the resources in client_metadata_documents.resources, with any scope those resources define.
Refresh tokens require both the document's grant types and the operator's refresh_tokens policy to permit them.
Omitting grant_types permits only authorization_code; include refresh_token to request refresh tokens (RFC 7591, section 2).
Re-fetching a document updates its grant types and preserves the operator's restrictions.
Fetching uses the runtime's destination controls: HTTPS only, no private or special-use addresses, no redirects, a 5 KiB limit (max_bytes), and a 5-second timeout (timeout_seconds).
The runtime caches a document for its HTTP freshness lifetime, clamped between min_cache_seconds (60) and max_cache_seconds (3600).
When a refresh fails after that time, the client is refused until the document can be fetched again.
development_hosts allows plain HTTP to listed host:port values, and only with development: true.
A fetched document does not make a client trusted. People still approve it, and the approval records the hash of the document's security-relevant fields. A changed redirect URI or other security-relevant change requires new approval, and a code issued before the change cannot be redeemed after it. The approval page marks the client name as unverified and shows the host the document came from.
Anyone can publish a document that lists any redirect URI, so the runtime never redirects to one before the person acts (RFC 9700, section 4.11.2).
An invalid authorization request from such a client shows an error page instead of returning the error to its redirect URI.
A sign-out request with its post_logout_redirect_uri first asks the person to confirm and names the destination host.
Without an issuer session, the sign-out page stays on the runtime.
At startup, the runtime removes resources that client_metadata_documents.resources no longer lists from stored metadata clients and ends their grants for those resources.
With enabled: false or an empty resource list, stored metadata clients stop working at once, even when their cached document is still fresh.
Resources and scopes
A resource is an API or MCP server that accepts the runtime's access tokens.
Its uri is the canonical audience and the value clients send as resource.
Its scopes have a name and a description that the approval page shows.
Operators manage resources through /v1/operator/oauth/resources with the resources:manage scope, and rotate a resource's introspection credential with POST /v1/operator/oauth/resources/{resource}/credential.
Every API or MCP authorization uses exactly one registered resource.
Many MCP clients leave out the RFC 8707 resource parameter, so a client that may use only one resource gets that resource when it sends none.
A client that may use several must name one.
The runtime never fetches a resource URI.
An unknown resource, or one the client may not use, ends the authorization with invalid_target.
Each access token carries one audience, so an MCP token is rejected at the API and an API token is rejected at the MCP server.
Grants, approvals, and pending requests also retain the resource definition version.
Changing that definition requires a new authorization and approval before access resumes.
OpenID Connect sign-in that requests only identity scopes and no resource gets the built-in UserInfo resource, {issuer}/oauth/userinfo.
That token can only read UserInfo with the approved identity scopes.
The identity scopes are openid, profile (name), and email (email and email_verified).
email_verified is true only for an address the runtime verified, or one the upstream provider asserted as verified.
The runtime stores no address that an upstream provider sent unverified, so such a person shares no email at all.
Organizations and approval
Each API or MCP grant belongs to one organization.
The person chooses it on the issuer's organization page from their active memberships that the client may use.
An organization request parameter only preselects a choice; the runtime checks it like any other input.
A grant gives no access across organizations and creates no membership, role, or service authority.
The approval page shows the client, the organization, the resource, and the requested permissions.
Approvals are kept per person, client, organization, resource, and client policy version.
A broader scope, another organization, or another resource needs a new approval, and a denial is returned to the client as access_denied.
An existing sign-in or an upstream provider's consent never approves a new client.
If the approval form is submitted again, after a double click or the back button, the browser follows only the last answer.
While the client has not redeemed the code, each repeat replaces it with a fresh code for the same grant, so the sign-in still finishes.
A replaced code fails with invalid_grant without ending the grant, and PKCE binds the fresh code to the same client.
After the code is redeemed, a repeat sends invalid_request with the client's state.
Two submissions that arrive at the same time issue one grant: the second waits up to five seconds for the first to finish and then answers as a repeat does.
The organization's own gates apply at every step: membership status, directory deactivation, the organization login policy, security signals, and client blocks. A local member of an organization that enforces SSO must sign in through the customer connection before the issuer grants access there. The runtime checks these gates again on each refresh, introspection, and UserInfo request, so a suspended or deactivated person loses access on the next request even while a token's signature and expiry are still valid.
identity_only clients can sign in a person with no membership.
They get an ID token and UserInfo access only.
Tokens
Access tokens
{
"iss": "https://id.example.com",
"sub": "q7Yv2K...",
"aud": "https://mcp.example.com/mcp",
"client_id": "mcp-cli",
"scope": "projects:read",
"organization_id": "org_demo",
"auth_time": 1793600000,
"amr": ["pwd", "otp"],
"acr": "urn:open-enterprise:acr:local:totp",
"iat": 1793600010,
"nbf": 1793600010,
"exp": 1793600310,
"jti": "oat_..."
}A resource server validates the signature with the published keys, the iss, the aud, typ: at+jwt, and the RS256 algorithm.
It then calls introspection with its resource ID and introspection secret (client_secret_basic).
Introspection returns active: false for a revoked, suspended, or blocked grant, and for an active token it adds user_id and grant_id for the resource server's own permission checks.
When introspection fails, the resource server must refuse the request.
The example application answers 503 in that case.
ID tokens and subjects
ID tokens carry iss, sub, aud (the client ID), azp, iat, exp, auth_time, sid, nonce when the request had one, and acr, amr, and organization_id when they apply.
auth_time, acr, and amr describe the actual sign-in, including the upstream login and any local second factor.
The runtime ignores acr or amr values that a client requests.
Upstream connections used by the issuer must supply a signed authentication time.
Forced login and maximum-age requirements reach the upstream authorization request.
An old upstream authentication cannot complete a request that requires a fresh login.
The subject is a random, opaque public identifier that stays the same for one person across every client of the issuer. It does not change with email changes, organization choice, a new linked identity provider, restarts, or key rotation. The runtime never derives it from an email address or an upstream subject.
Refresh tokens
Every refresh returns a new refresh token, and the previous one stops working.
A client that lost the response, for example to a network failure, or two tabs that refresh at once, can present the previous token again within refresh_reuse_grace_seconds (30 seconds by default) and get a new token pair.
That works only while no newer token of the grant has been used.
The refresh token from the earlier response then stops working, so the grant keeps a single chain; its access token works until it expires.
Any other reuse of a used refresh token revokes the whole grant (RFC 9700, section 4.14.2).
Inside the window, a stolen copy used before the client's next refresh also gets new tokens and is not detected as reuse.
Set refresh_reuse_grace_seconds: 0 to revoke on every reuse.
A refresh cannot add scopes, change the resource or organization, or work for a disabled client.
A refused scope or resource change leaves an unused refresh token available for a valid retry.
A refresh token unused for refresh_idle_seconds expires, and a grant ends after refresh_token_seconds in any case.
An ordinary grant ends with the issuer browser session that created it: at logout, at session expiry, or when an administrator ends the session.
With offline_access: true in the issuer section and refresh_tokens: offline on the client, a client that requests the offline_access scope gets a grant that outlives the browser session.
When the deployment or client does not allow offline access, the runtime drops that scope from the request and continues, as OpenID Connect Core section 11 allows.
A refresh is not a sign-in: it keeps the original auth_time and authentication methods.
Revocation
People open {issuer}/oauth/applications to see their connected applications and revoke them for one organization and resource.
Clients revoke their own tokens with RFC 7009 at {issuer}/oauth/revoke.
Organization administrators work through the organization API, using the applications:read and applications:write operations, or the Connected applications page of the administration portal:
| Operation | Request |
|---|---|
| List connected clients | GET /v1/organizations/{organization_id}/oauth/clients |
| List grants | GET /v1/organizations/{organization_id}/oauth/grants |
| Revoke grants | POST /v1/organizations/{organization_id}/oauth/grants/revoke |
| Block or allow a client | PUT /v1/organizations/{organization_id}/oauth/clients/{client} |
The path always sets the organization, so an administrator cannot reach another organization's grants. Blocking a client revokes its grants in that organization and refuses new ones there.
Operators can list and revoke grants across the deployment with /v1/operator/oauth/grants and the grants:manage scope.
Revocation also follows the identity lifecycle. Password resets, factor recovery, account disablement, membership suspension, SCIM deactivation, CAEP session revocation, and SSO enforcement all end the affected grants, and their pending authorization codes cannot be redeemed afterwards. A revocation that commits first wins over a code exchange or refresh that runs at the same time. Disabling local credentials or unlinking an external identity ends the issuer sessions and grants that used that sign-in method. This also applies to identity-only and offline grants. Re-enabling credentials or relinking the identity requires a new sign-in; old cookies, codes, and tokens remain invalid. Sessions and grants from another sign-in method of the same account remain usable.
Logout
Relying parties use RP-initiated logout at {issuer}/oauth/logout, by GET or by form POST.
A form POST keeps the ID token out of URLs and browser history; the example application uses it.
The runtime redirects only to a registered post-logout URI of the client named by client_id or by the ID token, and returns state unchanged.
An unregistered location gets an error page and no redirect.
Logout ends the issuer browser session and its ordinary grants.
Offline grants stay until they are revoked or expire.
A cross-site form POST carries no SameSite=Lax cookie, so a valid id_token_hint alone identifies the session to end.
Front-channel and back-channel logout are not supported.
Signing keys
The runtime creates an RS256 key at first start and stores it in PostgreSQL, sealed with issuer.secret_key_env.
Every replica uses the same key state and reloads it at most two seconds after a change.
The key set publishes public keys only, with kid values computed as RFC 7638 thumbprints.
Rotate the signing key with POST /v1/operator/oauth/keys/rotate (keys:manage scope).
The new key appears in the key set at once and starts signing after key_publish_seconds, so relying parties that cache the key set can fetch it first.
The previous key stays published while tokens it signed can still be valid.
After a key compromise, revoke it with POST /v1/operator/oauth/keys/{kid}/revoke.
The runtime removes it from the key set, and tokens it signed stop validating.
When no other key can sign yet, a replacement signs immediately.
A compromise of ISSUER_SECRET_KEY itself also needs a master-key rotation, described next.
To rotate ISSUER_SECRET_KEY, put the new value in secret_key_env, list the old variable in previous_secret_key_envs, restart, and run enterprise-runtime reencrypt <config>.
When the report shows no value sealed with an earlier key, remove the old variable.
Key creation, rotation, and revocation write oauth.signing_key.created and oauth.signing_key.revoked audit records.
Backup and recovery
The issuer's durable state lives in the runtime database: clients, resources, approvals, subject mappings, grants, code and refresh-token hashes, and sealed signing keys.
Back up ISSUER_SECRET_KEY and every previous issuer key with the other master keys, apart from database backups.
A restored database with its keys keeps every subject, client, approval, and grant.
Tokens issued before the backup validate again only while they have not expired.
A restored database without ISSUER_SECRET_KEY cannot sign.
Revoke the unreadable keys with the operator API; the runtime then creates a new key.
Every relying party must fetch the new key set, and existing access and ID tokens stop validating.
Backup and restore covers the procedure for the whole deployment.
Protect an API or MCP server
A protected resource needs four parts:
- Register it as an issuer resource with its canonical URI and scopes.
- Publish protected resource metadata (RFC 9728) that names the issuer and the scopes.
The runtime serves this document for each registered resource at
{issuer}/oauth/resources/{id}/metadata. Name that URL in theresource_metadataparameter of your 401 response, or serve the same document at your/.well-known/oauth-protected-resourcepath. - Answer requests without a token with 401 and
WWW-Authenticate: Bearer resource_metadata="...", scope="...", and requests that lack a scope with 403insufficient_scope. - Validate each token and introspect it, then check the person's current permissions for the operation.
The example application does this for its projects API at /api and its MCP server at /mcp.
Read examples/fastify-saas/src/resource-server.ts for token checks and examples/fastify-saas/src/mcp.ts for the MCP tools.
Its tools check the same permissions and resource ownership as its web pages, so a token never grants more than the person may do.
Authorize each MCP tool call with AuthZEN
An MCP server or gateway can ask the runtime about every tool call instead of checking permissions in its own code.
Each registered resource is an AuthZEN decision point that follows the COAZ-MCP binding (OpenID AuthZEN, Draft 1, February 2026).
Its metadata is at {issuer}/oauth/resources/{id}/.well-known/authzen-configuration, and it evaluates requests at {issuer}/oauth/resources/{id}/access/v1/evaluation.
Map each tool to the permission it needs in the resource's tool_permissions:
resources:
- id: projects-mcp
uri: https://app.example/mcp
tool_permissions:
list_projects: project:read
delete_project: project:deleteThe MCP server authenticates with the resource's introspection credential, as for introspection, and sends the binding's default request for a tools/call:
{
"subject": { "type": "identity", "id": "<token sub>" },
"action": { "name": "tools/call" },
"resource": { "type": "tool", "id": "delete_project" },
"context": { "agent": "<token client_id>" }
}The runtime finds the person behind sub and the organization they approved the resource for, through the client in context.agent.
It answers {"decision": true} when the person holds the tool's permission there now.
Otherwise it answers {"decision": false, "context": {"reason": "..."}}, and the MCP server returns the binding's JSON-RPC error -32001.
A tool that tool_permissions doesn't list is refused.
When the person approved the resource for more than one organization, add "organization_id": "$token.?organization_id" to the tool's declared mapping, so the request names the token's organization.
A tool's declared mapping (x-authzen-mapping) can name a permission and resource directly, for example project:delete on {"type": "project", "id": "$params.arguments.id"}.
The runtime checks that permission on that resource.
It ignores the rest of the request context, because the binding treats declared attributes as untrusted: only the subject and the approved organization decide whose permissions count.
A tools/list request is permitted while the person holds an active approval for the resource.
The evaluation has no session, so a policy that requires a stronger sign-in method refuses it.
A 503 answer means the runtime couldn't decide, and the MCP server must refuse the call.
Audit and lifecycle events
Security-relevant changes and their audit records commit in one transaction.
Audit actions include oauth.client.created, oauth.client.updated, oauth.client.deleted, oauth.client.secret_rotated, oauth.client.blocked, oauth.client.allowed, oauth.resource.created, oauth.resource.updated, oauth.resource.deleted, oauth.resource.credential_rotated, oauth.consent.granted, oauth.consent.skipped_by_policy, oauth.grant.issued, oauth.grant.revoked, oauth.signing_key.created, and oauth.signing_key.revoked.
The organization's lifecycle stream publishes oauth_grant.created, oauth_grant.revoked, oauth_client.blocked, and oauth_client.allowed.
Lifecycle events describes the payloads.
Grants without an organization publish no events.
Tokens, codes, client secrets, verifiers, and private keys never appear in logs, audit records, events, or API responses other than the one that issues them. The browser suites search the runtime logs for every credential they handle.
Not supported
These optional features are not implemented:
- Dynamic Client Registration (RFC 7591). Use configured clients, the operator API, or Client ID Metadata Documents.
- Pushed authorization requests, request objects (
request,request_uri), and theclaimsparameter. - The implicit and hybrid flows,
response_mode=form_post, and the password grant. private_key_jwtand mutual-TLS client authentication.- Sender-constrained tokens (DPoP, mutual TLS).
- Token exchange (RFC 8693).
- Pairwise subjects, encrypted ID tokens, and signing algorithms other than RS256.
- Front-channel, back-channel, and session-management logout.
Shared mobile devices
The field crew example (examples/mobile-field/login.mjs) signs a public client in with the OS browser, a registered native callback, PKCE, state, and nonce. Register the callback, protected resource and read scope. Enable offline access if the client needs rotating refresh tokens. Supply an OS browser adapter that returns the callback to the initiating app. On handoff the next user authenticates again.
The example keeps tokens in memory. To enable offline reads, supply elapsedRealtime from a native monotonic clock that measures milliseconds across device sleep. The authenticated operator can then read their last result for up to five minutes from the start of the request. Set cacheMillis to change that lifetime. Omitting the clock or setting cacheMillis: 0 selects online-only mode. In that mode, reconnect() returns freshly authorized rows and offlineRecords() returns an empty list.
Reconnect fetches records with cache: "no-store" so each request reaches the protected resource for a fresh access decision. Send Cache-Control: no-store on the resource response as well. The offline cache checks both elapsed and wall time. A network failure preserves its original deadline. Expiry or an observed clock rollback discards the saved records. Sign-out, process exit, or an authorization refusal clears the local data. A response that arrives after handoff or after its offline deadline is discarded. Test these transitions with node --test examples/mobile-field/session.test.mjs.
The sample uses openid-client@6.8.9, Fetch, and Web Crypto. The repository installs the library with npm ci. A host that copies the two modules adds it as an application dependency. A mobile host can wire its sign-in, reconnect, offline view, and handoff buttons directly to the sample. The OS browser adapter accepts an authorization URL and registered callback URI and resolves with the returned URL. Revocation uses the network. Local handoff clears credentials and records immediately, including when the device is offline.
import { fieldClient } from "./login.mjs";
const { login, session } = await fieldClient({
issuer, clientId, redirectUri, audience, recordsUrl, scope: "visits:read", openSystemBrowser, elapsedRealtime,
});
await login();
const visits = await session.reconnect();
const offlineVisits = session.offlineRecords();
await session.signOut();Verification
Three browser suites drive the issuer with real protocol libraries. Each starts from its own Compose deployment:
docker compose -f compose.local.yaml -f deployments/compose.oauth.yaml up -d --build --wait
npm run test:e2e:oauthdocker compose -f compose.yaml -f deployments/compose.migration.yaml -f deployments/compose.oauth-external.yaml up -d --build --wait
npm run test:e2e:oauth:externaldocker compose -f compose.yaml -f deployments/compose.saml.yaml -f deployments/compose.oauth-saml.yaml up -d --build --wait
npm run test:e2e:oauth:samlThe first runs the local-account scenario: MFA sign-in through openid-client, ID token validation with jose, UserInfo, API authorization, MCP discovery from the server URL, a denied mutation, step-up approval, refresh rotation, revocation, and logout.
The second links a Keycloak identity to a local account, enforces SSO for one organization, and checks that the downstream subject stays the same and that suspension ends tokens, pending codes, and refresh while another organization and the recovery owner keep access.
The third provisions a person through SCIM and authorizes the MCP client through a SAML provider behind a Keycloak broker, then deactivates and reactivates the person.
The PostgreSQL suite crates/enterprise-runtime/tests/oauth_issuer.rs covers protocol negatives, code and refresh replay, revocation races across two runtime instances, key rotation and restore, Client ID Metadata Documents, and identity-only sign-in.
It checks tokens with the independent jsonwebtoken library.
bash scripts/test.sh runs it.
| Component | Version |
|---|---|
| MCP authorization profile | 2026-07-28 |
| Negotiated MCP message protocol | 2025-11-25, through the pinned SDK |
@modelcontextprotocol/client |
2.4.0 |
@modelcontextprotocol/server |
2.4.0 |
@modelcontextprotocol/node |
2.1.2 |
openid-client |
6.8.9 |
jose |
6.2.13 |
jsonwebtoken (Rust) |
9.3.1 |
| Playwright | 1.65.0 |
| Keycloak | 26.8.2 |
The MCP SDK client accepts a Client ID Metadata Document only at an HTTPS URL, so the browser suites register the MCP client instead.
The PostgreSQL suite covers metadata documents with a loopback document server under development_hosts.
Machine and operator workflows
See service accounts for scoped machine clients, token claims, and live resource validation.
Client registrations declare their allowed grant_types.
A registration alone gives no machine authority.
The operator opens a one-use console entry with:
enterprise-runtime operator-entry config.yaml --operator operationsThe entry expires after 60 seconds. Its HttpOnly browser session lasts 15 minutes.
The console checks the current operator configuration fingerprint on every request.
Changing the operator key or scopes invalidates existing browser authority.
The backend SDK can also call client.operator.createEntry().
The operator console manages clients, resources, grants, and signing keys. Customer panels can block applications and revoke organization grants within delegated authority. They cannot mutate deployment-wide issuer trust.
Credential rotation accepts overlap_seconds from 0 to 86400 and an optional expires_at within 366 days.
The previous verifier remains usable only through the smaller overlap or original expiration.
A second rotation replaces the previous overlap slot.
Expiration controls client authentication or resource introspection authentication.
Use grant, client, signing-key, or machine credential revocation to end already issued authority immediately.
Browser-created resource introspection secrets stay sealed on the server.
The console shows a one-use delivery ID, valid for ten minutes.
Retrieve it from a trusted backend with client.operator.takeSecret(deliveryId).
A browser operator session cannot call that pickup endpoint.
The root-authenticated resource API retains one-time secret delivery for direct backend integrations.
TypeScript operator methods live under client.operator.oauth.
clientCredentials() provides the server-side machine grant helper.
The API and MCP example retain a typed service-account identity and intersect each operation with its credential restrictions.