Skip to content

Use cases ​

Each page below pairs with a runnable example under examples/ in the source repo. Examples build behind the example build tag, so they stay out of go test ./... and out of your go.sum:

sh
(cd examples/01-minimal && GOWORK=off go run -tags example .)

Most pages open with the problem the feature solves, then say when it earns its complexity and when a simpler built-in path is enough.

If you are new to the library, start with Minimal OP and RP pair, then Comprehensive bundle, and only jump to the pages below when your deployment has that specific need. To pick a page by what you want to build rather than by topic, use Start here.

A reading order for these pages
Start from the minimal OP, then branch into whichever of the five areas the deployment actually needs: profile and flow, UI, storage and authentication, advanced grants, or cryptography and operations.Minimal OPget it booting firstProfile and flowFAPI, CIBA, device code, token exchangeUI and SPAcustom screens, the account chooser, step-up MFAStorage and authenticationSQL, DynamoDB, Redis, your own user storeAdvanced grantsgrant management, authorization details, dynamic registrationCryptography and operationsJWE, pairwise subjects, protected-resource metadata
The five rows are independent — take the one that matches what you are building. Only the box on the left has to come first.

The reference application ​

Each numbered example isolates one option in 200–500 lines. sample/ is the other thing: the arc those examples skip, where an account has to come into existence before it can be used. It runs on MySQL plus Redis joined by op/storeadapter/composite, under one docker compose up, and covers:

  • signup owned by the application: account creation itself stays with the application, which plugs into the library's registration seam (LoginFlow.Registration and prompt=create)
  • Argon2id password storage
  • login and consent through an interaction.Driver the application implements itself
  • TOTP enrolment from an account settings page
  • a relying party completing the round-trip
sh
docker compose -f sample/compose.yaml up -d --build

The Compose file publishes the OP and RP only on 127.0.0.1. The sample protects application-owned POST routes with a double-submit CSRF token and an Origin check; password changes and TOTP enrolment confirmation also require the current password, verified with op.VerifyPassword. These protections belong to the application, outside the OP's interaction endpoint.

Its consent page is a worked example of granular per-scope consent, which the bundled HTML driver deliberately does not offer. Treat it as a demonstration rather than a template: the schema is one embedder's model, signing and cookie keys are regenerated on every start, and it is not built to be hosted.

Index ​

Every example folder maps to one of the use-case pages below.

Bootstrap & wiring ​

Use caseExamplePage
Smallest possible OP01-minimalMinimal OP and RP pair
Comprehensive bundle (every option a typical embedder uses)02-bundleComprehensive bundle

Profile & flow ​

Use caseExamplePage
Declare OAuth 2.1 or legacy OIDC posture00-security-profileDeclaring a security profile
Plain OAuth 2.0 alongside OIDC04-oauth2-onlyOAuth 2.0 (no openid)
FAPI 2.0 Baseline (library PAR + JAR + DPoP default)03-fapi2FAPI 2.0 Baseline
FAPI 2.0 Message Signing (signed requests, JARM, signed introspection, DPoP nonce source)54-fapi2-message-signing, and 51-dpop-nonce for the nonce handshakeFAPI 2.0 Message Signing
FAPI 2.0 with certificate-bound tokens behind a TLS-terminating proxy (WithMTLSProxy + WithTrustedProxies)55-mtls-proxyFAPI 2.0 Baseline
Native app: public client, PKCE, loopback 127.0.0.1 redirect38-native-appChoose a configuration
Service-to-service tokens05-client-credentialsclient_credentials
MCP clients that identify themselves by an HTTPS URL, with no pre-registrationnoneMCP authorization server
DPoP server nonce flow51-dpop-nonceDPoP nonce flow
Protect an API with the OP's tokens (op/rs), mounted route by route36-resource-serverProtect an API
Publish protected resource metadata (RFC 9728) for the APIs an OP frontsnoneProtected resource metadata

UI ​

Use caseExamplePage
Built-in HTML login, consent, and chooser19-default-uiChoosing a UI path
Drive UI from a SPA16-custom-interaction, 10-react-login, 17-spa-composite-storeSPA / custom interaction
Custom HTML sign-in page37-custom-login-uiCustom login UI
Custom HTML consent page11-custom-consent-uiCustom consent UI
Custom HTML account chooser12-custom-chooser-uiCustom chooser UI
Multi-account chooser (prompt=select_account)13-multi-accountMulti-account chooser
Cross-origin SPA (CORS)14-cors-spaCORS for SPA
Locale negotiation15-i18n-localei18n / locale

Storage ​

Use caseExamplePage
Persist on a real database06-sql-store, 07-mysql-storePersistent storage (SQL)
Persist on DynamoDB18-dynamodb-storeDynamoDB storage
Rename SQL adapter tables25-byo-table-namesPersistent storage (SQL) § Renaming the tables
Implement a store from scratch26-byo-store-from-scratchBring your own store backend
Hot/cold split (Redis volatile)08-composite-hot-cold, 09-redis-volatileHot/cold + Redis
Choose between SQL, DynamoDB, Redis hot/cold and a custom storenoneChoosing a storage layout

Scopes & claims ​

Use caseExamplePage
Public / internal scope split60-scopes-public-privatePublic / internal scopes
OIDC §5.5 claims request parameter61-claims-requestClaims request
Rich authorization requests (RFC 9396)noneRich authorization requests

Authentication ​

Use caseExamplePage
MFA, captcha, step-up20-mfa-totp, 21-risk-based-mfa, 22-login-captcha, 23-step-upMFA / step-up
Durable MFA factor stores on the core database27-durable-mfa-storeMFA / step-up
Email OTP or recovery codes28-email-otp-recoveryMFA / step-up
Sign in with a passkey instead of a password29-passkeyPasswordless passkey
Bring your own user store24-byo-userstoreBring your own user store
Migrate bcrypt password hashes to argon2id on login53-production-sqlMigrating bcrypt passwords
An account page that requires a recent sign-in (max_age, rs.RequireMaxAge)noneAccount page

Advanced grants ​

Use caseExamplePage
Custom grant_type URN30-custom-grantCustom Grant
Device code (RFC 8628)31-device-code-cliDevice Code
CIBA poll mode32-ciba-posCIBA
Token Exchange (RFC 8693)33-token-exchange-delegationToken Exchange
Exchange a trusted partner's signed assertion for an access token (RFC 7523)noneJWT bearer grant
Identity chaining across organisations: issue or redeem an ID-JAG (experimental)noneID-JAG
Long-lived grants the client can query, merge and revoke by idnoneGrant management

Crypto & subjects ​

Use caseExamplePage
Pairwise subject (OIDC Core §8.1)34-pairwise-saasPairwise subject
Encrypted id_token (JWE)35-encrypted-id-tokenJWE encryption

Governance ​

Use caseExamplePage
First-party consent skip40-first-party-skip-consentFirst-party consent skip
Dynamic Client Registration (RFC 7591)41-dynamic-registrationDynamic Client Registration
Back-Channel Logout 1.042-back-channel-logoutBack-Channel Logout
Register, update and remove RPs: static seeds and code seams53-production-sqlClient onboarding patterns

Operations ​

Use caseExamplePage
Prometheus metrics52-prometheus-metricsPrometheus metrics
FAPI TLS policy and public-JWKS loading50-fapi-tls-jwksFAPI 2.0 Baseline

Numeric inventory ​

The example folders are grouped by topic, not by the order they were written:

BandTopic
00–09bootstrap, core flows, profiles, storage adapters
10–19UI and browser integration (SPA, consent, chooser, CORS, i18n)
20–29MFA, authentication rules, and user-store projection
30–39advanced grants, subject modes, encrypted tokens, federation, resource servers; 37 holds the UI overflow
40–49governance: first-party, DCR, back-channel logout
50–59operations: FAPI helpers, metrics, tracing, DPoP nonce
60–69scopes, claims, and compliance-adjacent examples

The README in the source repo is the authoritative inventory.