Skip to content

Use case — Comprehensive bundle

01-minimal shows the smallest viable OP. 02-bundle shows what a production-shaped OP wiring looks like end-to-end: login flow, MFA, captcha, risk, scope catalogue, trusted proxy normalisation, the recommended logger.

Source: examples/02-bundle/main.go

What it composes

LayerOption / type
Loginop.LoginFlow with op.PrimaryPassword
MFAop.RuleAlways(op.StepTOTP{...})
Captchaop.RuleAfterFailedAttempts(n, op.StepCaptcha{...})
Riskop.RuleRisk(threshold, step) + assessor on LoginFlow.Risk
Clientsop.WithStaticClients(...) (typed seeds)
Scopesop.WithScope(op.PublicScope(...)) / op.WithScope(op.InternalScope(...)) per scope
Profileop.WithProfile(...) (commented out by default — flip on for FAPI)
Proxyop.WithTrustedProxies(cidrs ...)
Loggingop.WithLogger(slog.Logger)

Use it as a checklist

The example is intentionally long — its job is to be the page you copy from and delete the parts you don't need. If you find yourself writing a wiring from scratch, scan 02-bundle first and confirm you didn't miss anything obvious.

sh
go run -tags example ./examples/02-bundle

When to consult it

QuestionLook at
What's the minimum extra surface beyond 01-minimal?The LoginFlow block + WithStaticClients
How do I wire MFA + risk into one flow?The Rules slice
How do I shape the discovery scopes_supported field?The chain of WithScope(PublicScope(...)) calls
What does a recommended slog logger look like?The WithLogger call
How do I turn this into FAPI 2.0?Uncomment the WithProfile line