Released docs. You are viewing the documentation published with v0.49.0. Development docs are available at Latest.
If you operate pages behind an Envoy gateway, use registry-session to hold signed-in people’s tokens on the server.
The gateway attaches the person’s own token when a page calls a product.
The service checks each call and never proxies it.
Before you start
Section titled “Before you start”You need an identity provider and the products your pages call. The service is a relying party, not an identity provider or token issuer. It uses authorisation-code sign-in with PKCE and obtains one token set per distinct audience. The provider must return JWT access tokens with a readable audience, a lifetime and refresh tokens.
Build registry-session from the workspace source with cargo build --locked -p registry-session.
It is held out of numbered releases.
Use registry-session --help for its command tree.
Run one replica. Sessions live only in memory, so a restart requires people to sign in again. Put TLS in front of the public listener. Make the check listener reachable only by the gateway: its answers can carry bearer tokens.
1. Write the runtime file
Section titled “1. Write the runtime file”Save this synthetic example as an absolute path such as /etc/registry-session/runtime.yaml.
Replace its issuer endpoints, client id, scopes and upstream clusters with your deployment’s values.
The example assumes Base Registry Engine (BReg) uses the person audience.
apiVersion: id.registrystack.org/formats/platform/session-runtime/v1alpha1kind: PlatformSessionRuntimeConfiglistener: bind: 127.0.0.1:8120 tlsTermination: operator-controlled-upstreamcheckListener: 127.0.0.1:8121publicOrigin: https://app.example.orgsecretProviders: file: root: /run/secrets/registry-sessionissuer: id: https://id.example.org authorization: https://id.example.org/oauth2/authorize endSession: https://id.example.org/oauth2/logout token: https://id.example.org/oauth2/token revocation: https://id.example.org/oauth2/revoke jwks: https://id.example.org/oauth2/jwks attemptTimeoutMilliseconds: 2000personAudience: https://api.example.org/persongateway: service: host: session.example.org publicPort: 8120 checkPort: 8121 checkTimeoutMilliseconds: 3000 hostFilters: [envoy.filters.http.cors]modules: - id: breg product: breg prefix: /api/registry/ audience: person upstream: cluster: registry prefixRewrite: /pages: - prefix: /apply/ signIn: citizen upstream: cluster: pagessignIns: citizen: clientId: citizen-pages clientSecretRef: secret:file/citizen-client-secret scopes: [registry:read]session: idleLifetimeSeconds: 1800me: claims: [sub, name]audit: hashKeyRef: secret:file/audit-key path: /var/lib/registry-session/audit.jsonllistener.bind serves the public session routes behind your gateway.
checkListener serves the gateway check and must use a different address.
Both inherit the listener’s TLS-termination and network-exposure settings.
Use addresses that your gateway can reach.
The loopback listener addresses in this example require session.example.org to resolve to that same host from the gateway.
publicOrigin is the browser’s origin: lower-case scheme and host, without a path, trailing slash or default port.
issuer.id is the issuer identifier compared exactly.
Every endpoint is explicit, without discovery.
Keep issuer.attemptTimeoutMilliseconds below gateway.checkTimeoutMilliseconds.
The session service defaults to production.
For a local HTTP gateway, pass --posture development or set REGISTRY_STACK_POSTURE=development for each session command.
Set listener.tlsTermination to development-loopback.
The service refuses this setting in production and reports it as a warning in development.
Open the app in Chrome at its http://127.0.0.1:<port> URL.
rstack dev uses this numeric loopback form when it starts a local application.
Set publicOrigin to the exact origin you open.
Use the HTTPS configuration above for a browser that requires TLS for Secure cookies.
Each module names a path prefix and its token audience.
audience: person selects personAudience.
Declare product: breg or product: documents on each member route.
The id remains the route’s own identifier.
To migrate an existing runtime, add product to each person-audience route and give each host-specific route its own absolute audience URI.
A host-specific route can omit product.
A page selects a sign-in kind through signIn.
A module’s optional signIns restricts which kinds reach that route.
Products still decide what the person may read or change.
Module and page prefixes support two forms:
- A prefix ending in
/covers paths starting with that prefix. For example,/api/functions/covers/api/functions/renewbut does not cover/api/functions. - Without a trailing slash, the prefix covers its exact path and descendants at a segment boundary.
For example,
/api/functions/renewcovers that path and/api/functions/renew/x, but not/api/functions/renewal. Envoy matches this form withpath_separated_prefix.
You cannot declare both /a/b and /a/b/: the runtime treats them as one prefix.
Module and page prefixes at /session or beneath it are refused.
A sibling such as /sessions is allowed.
Store the client secret and audit hash key in the files their references name.
Declare the file provider root and keep the files accessible only to the service account.
Startup resolves the references and opens the audit destination before listening.
me.claims selects the verified identity claims returned by GET /session/me.
That route returns no token and does not renew one.
2. Declare the identity application
Section titled “2. Declare the identity application”In your identity deployment file, declare the same personAudience and a session application for each sign-in kind.
For the runtime example, the relevant excerpt is:
personAudience: https://api.example.org/personsessionApps: - id: citizen-pages clientSecretRef: secret:env/CITIZEN_CLIENT_SECRET origin: https://app.example.org redirectUris: [https://app.example.org/session/callback] postLogoutRedirectUris: [https://app.example.org/session/signed-out] products: [breg] tokenAttributes: [registry_actor_kind] grants: - product: breg accessProfiles: [case-read]Use the access-profile names and required claims from your products’ identity facts. The product must admit the session application’s client id. Provision the same client secret for the identity application and the service’s secret reference. The generator configures authorisation-code and refresh-token grants for session applications.
Only breg and documents can share the hosted generator’s person audience.
Each member’s runtime must already declare that audience.
The generator refuses overlapping member scope names and requires reachable interactive profiles to have a scope of their own.
Other products keep separate audiences.
The personAudience member in an rstack dev plan supports BReg membership only.
Generate the identity configuration through Generate ThunderID configuration.
Place the front gateway from front-gateway/envoy.yaml in front of the identity provider.
Route nothing to the provider directly.
When including the Document Store, rstack identity generate thunderid accepts --documents-runtime-config FILE.
It drives documentsctl generate identity-facts against that runtime and its package.
RSTACK_DOCUMENTSCTL_BIN selects an explicit tool binary.
Then check the session file against the generated receipt:
registry-session --runtime-config /etc/registry-session/runtime.yaml check \ --identity-receipt /etc/registry-session/identity-out/identity-receipt.jsonThe command exits 0 when accepted.
It reads no secret and opens no socket.
On a finding, correct the named member and rerun it.
If a value uses an environment expression, add --environment with that variable set before comparing the receipt.
3. Generate and splice the gateway fragments
Section titled “3. Generate and splice the gateway fragments”Generate into a directory you reserve for these files. The command writes or replaces the four fragments there:
registry-session --runtime-config /etc/registry-session/runtime.yaml gateway envoy \ --out /etc/registry-session/envoy-fragmentsSplice the fragments into your static Envoy configuration:
- Put
http-filters.yamlat the head of each public HTTP connection manager’s filter chain. Keep the generated order, ahead of your host filters, with the router last. - Put
routes.yamlfirst in a virtual host whose only domain isapp.example.org. Define theregistryandpagesupstream clusters that the runtime names. - Add
clusters.yamlto the host’s cluster list. - Put both mappers from
local-reply.yamlfirst in the connection manager’slocal_reply_config.mappers. Keep their generated order: failed check first, unreachable/session/route second.
Remove registry-session-answer from responses on every host route outside the generated routes.
Set strip_trailing_host_dot: true.
For this example’s authority without a port, also set strip_matching_host_port: true.
gateway.hostFilters must name every host HTTP filter except the router.
Each module or page can retain named filters through upstream.keepHostFilters.
Every other host filter is switched off on generated routes.
A kept filter runs after the session check and sees the person’s bearer token on a module call.
Keep only filters that preserve the path, route cache and authorisation header.
All host filters are switched off on every /session/ route, including its reserved catch-all.
Use an explicit file log format limited to literals and stream statistics on all public listeners. Apply the access-log example at every scope where you enable logging. This keeps callback query values and credential headers out of the logs.
Verify the result before deploying:
registry-session --runtime-config /etc/registry-session/runtime.yaml gateway envoy \ --check /etc/registry-session/envoy-fragmentsregistry-session --runtime-config /etc/registry-session/runtime.yaml gateway envoy \ --verify-assembled /etc/envoy/envoy.yamlBoth commands exit 0 when accepted. A refusal names the differing file or rejected gateway member. Regenerate and splice again when the runtime changes, then repeat both checks. The assembled verifier supports inline static listeners, routes and filters. It refuses dynamic route delivery, hidden filter configuration and redirects. An HTTP-to-HTTPS redirect must run outside this Envoy.
4. Check the running service
Section titled “4. Check the running service”Start the service with registry-session --runtime-config /etc/registry-session/runtime.yaml.
The operational log reports when both listeners are listening.
Visit https://app.example.org/apply/ through the gateway and complete sign-in.
A request without the page’s required session redirects to /session/sign-in.
A successful sign-in returns to the allowed local page.
GET /session/me returns the sign-in kind and selected claims.
The browser holds the opaque __Host-registry-session cookie.
The gateway strips cookies before forwarding signed-in module calls and attaches the person’s token.
Page upstreams receive neither cookies nor a bearer.
For a write, your page sends Registry-Client: page.
The TypeScript client’s page mode sends this header on every call.
Use createRegistryClient to create a client in page mode.
Add the header to every write you send with a general-purpose HTTP client or platform SDK.
This includes browser fetch and Supabase’s functions.invoke.
The request must also carry an Origin matching publicOrigin and, when present, Sec-Fetch-Site: same-origin.
A module call without a live session answers 401 session.expired.
The session check answers 403 session.refused when it rejects a route or origin.
An unavailable check answers 503 session.unavailable, including the gateway’s local reply when the check cannot be reached.
If the gateway cannot reach the service on a /session/ route, its generated local reply answers the same marked 503 problem.
The generated mappers leave a host route’s 503 untouched.
A page must recognise a session problem by both registry-session-answer: 1 and its type URI.
The URI starts with https://id.registrystack.org/problems/registry-platform/session/ and ends with the problem suffix.
A product answer with the same status is still a product answer.
The generated CSRF filter answers a plain 403 when a write’s Origin names another site or is missing.
That response has neither a registry-session-answer marker nor a problem body.
Treat it as a forged or misrouted request, rather than an expired session to restore.
An invalid return path answers 400 session.return-refused.
Rate limiting answers 429 session.rate-limited.
A full store answers 503 session.busy.
The public listener also has session.not-found (404), session.method-not-allowed (405) and session.internal (500).
The gateway’s reserved /session/ catch-all is an unmarked 404.
Follow the named failure, rather than treating every refusal as expired sign-in.
Sign out through a top-level form post:
<form method="post" action="/session/sign-out"> <button type="submit">Sign out</button></form>The service ends its session and redirects the browser to the declared end-session endpoint.
The provider ends its own session only if it honours that request.
A sign-out sent with fetch cannot perform the required top-level navigation.
Move a module to its own audience
Section titled “Move a module to its own audience”In the session runtime, replace that module’s audience: person with its own absolute audience URI.
Keep the product’s audience and generated identity configuration in agreement, then rerun the receipt and gateway checks.
The route and cookie remain the same.
When that creates another distinct audience, sign-in gains one more top-level hop.
The hop can be silent while the provider’s browser session remains active.
The service does not force silence with prompt=none.
Configure an ordinary Casework route
Section titled “Configure an ordinary Casework route”Give a module declaring product: casework a dedicated audience and list the
sign-in kinds allowed to reach it. Ordinary calls receive the Casework bearer.
Configure access logs
Section titled “Configure access logs”If you enable access logs, give each listener access_log, connection manager access_log, and router upstream_log entry an explicit inline format.
Use an unfiltered envoy.access_loggers.file logger with log_format.json_format or log_format.text_format_source.inline_string.
Keep the format to literals and stream statistics, as in the example below. The assembly verifier refuses credential headers and external text format sources.
- name: envoy.access_loggers.file typed_config: "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog path: /dev/stdout log_format: json_format: protocol: "%PROTOCOL%" status: "%RESPONSE_CODE%" flags: "%RESPONSE_FLAGS%" duration_ms: "%DURATION%"Use that entry under the log list at each scope where you want logging. Omit the list or leave it empty to disable logging at that scope.
Cookies on Registry Stack
We use optional cookies to understand how you use the main Registry Stack website and this documentation. If you contact us, we may link this activity to your enquiry. You can change your choice at any time. Read the privacy policy.
Your browser asks sites not to track you, so optional tracking stays off.
We could not use or save that choice. Optional tracking remains off.