Skip to content

Use cases

Each card below maps to a runnable example under examples/ in the source repo. Examples build behind the example build tag so they don't bloat your go.sum or get pulled into go test ./...:

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

Most pages start with the same decision shape:

  • What problem this solves. The opening paragraphs explain the pressure that makes the feature useful, not just the option name.
  • When to use it. Advanced pages call out the deployment shape where the feature earns its complexity.
  • When not to use it. If a simpler built-in path is enough, the page points you there before diving into code.

If you are new to the library, start with Minimal OP, then Comprehensive bundle, and only jump to the pages below when your deployment has that specific need.

How to read the use-case pages: start from the minimal OP, then branch into profile, UI, storage, authentication, advanced grants, and operations as the deployment needs them.Minimal OPboot it firstProfile / flowUI / SPAStorage / AuthAdvanced grantsCrypto / operations

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 covers signup owned by the application, Argon2id password storage, login and consent through an interaction.Driver the application implements itself, TOTP enrolment from an account settings page, and a relying party completing the round-trip — on MySQL plus Redis joined by op/storeadapter/composite, under one docker compose up.

sh
docker compose -f sample/compose.yaml up -d --build

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
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 (PAR + JAR + DPoP)03-fapi2FAPI 2.0 Baseline
Service-to-service tokens05-client-credentialsclient_credentials
DPoP server nonce flow51-dpop-nonceDPoP nonce flow

UI

Use caseExamplePage
Drive UI from a SPA16-custom-interaction, 10-react-login, 17-spa-composite-storeSPA / custom interaction
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

Scopes & claims

Use caseExamplePage
Public / internal scope split60-scopes-public-privatePublic / internal scopes
OIDC §5.5 claims request parameter61-claims-requestClaims request

Authentication

Use caseExamplePage
MFA, captcha, step-up20-mfa-totp, 21-risk-based-mfa, 22-login-captcha, 23-step-upMFA / step-up
Email OTP, recovery codes, or passkeys28-email-otp-recovery, 29-passkeyMFA / step-up
Bring your own user store24-byo-userstoreBring your own user store

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

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

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 chronology:

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
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.