What a deployment must do before real clients rely on it. Each item
links to the part of GETTING_STARTED.md that
explains it. New refuses many of these mistakes at startup under
production assurance, but not all of them. The items marked (yours)
are things no constructor can check.
-
Config.Assurance = server.AssuranceProduction, withConfig.Deploymentset.AssuranceDevelopmentis not FAPI 2.0 conformant, though its metadata looks the same. Step 2 - Durable stores that declare
storage.StoreAssuranceand pass the contract tests in your own test suite, since the declaration isn't verified:storage.TestClientRepositoryContract,TestTransactionStoreContract,TestGrantStoreContract,TestReplayStoreContract,TestRevocationStoreContract, plusTestAccessTokenStoreContract(opaque access tokens),TestNonceStoreContract(DPoP nonces) andTestBackchannelAuthenticationStoreContract(CIBA). WithDeploymentHorizontallyScaled, every instance must share them. Thesqlstoremodule provides the client repository, transaction, grant, replay, nonce, revocation, opaque access token, CIBA and pairwise subject stores on PostgreSQL (any deployment) or SQLite (DeploymentSingleInstanceonly), already passing those contracts: see Storage withsqlstore. Step 1 - Durable signing keys that declare
keys.KeyCustodyAssurance(keys.NewKeyManagerFromSignerswithkeys.DeclareCustody), and a plan for rotating them. - Client keys from
keys.NewStaticClientKeysorkeys.NewClientJWKSSource. Akeys.ClientKeySourceof your own must passkeys.TestClientKeySourceContract. Step 1 - An audit sink (
Dependencies.Audit),server.SystemClock{}andcrypto/rand.Reader. Auditing is best-effort: an event the sink can't record is lost and the request carries on. If a token must never be issued without a record, have the sink implementserver.FailClosedAuditSink(returning true): token issuance, revocation and a revoking code reuse then fail withserver_errorwhen their event can't be recorded, after the state change, so a spent code orauth_req_idstays spent. Step 4 - A revocation choice: a revocation store the resource servers
share, or
server.NoRevocation{}with short access token lifetimes, knowing that a reused code then revokes its refresh token but not its access tokens, andRevokeGrantrefuses. Step 2 - (yours) A revocation store sized for revoked grants, each
kept at least 400 days, including the grant of every refresh token
revoked at the revocation endpoint or with
RevokeListedGrantorRevokeSubjectGrants, so with clients that revoke their refresh token at every logout, every logout adds records kept that long. With aLimits.RefreshTokenLifetimeover that, withdraw grants withRevokeListedGrant, or through aDependencies.Grantsthat implementsstorage.GrantRefreshTokenRevoker, so their refresh tokens are revoked too, not only refused while the grant's record lasts. sqlstore'sGrants()andBatchingGrants()implement it from v0.10, but can't revoke the refresh tokens stored before its migration 0005, or by a v0.9 instance during the deploy that applies it, this way: they aren't indexed by their grants. Step 5 - A DPoP nonce choice: a nonce store every instance shares
(
Dependencies.Nonces, withLimits.DPoPNonceLifetimeof at most 15 minutes), so a DPoP proof generated ahead of time or captured is refused, at the cost of one extra round trip per client on first use; orserver.NoDPoPNonces{}to decline, as an mTLS-only deployment can. Step 4 - A client certificate trust choice:
NoPKIClientAuthentication{}unless a client usestls_client_auth; otherwiseTrustedClientCAswith revocation checking, orClientCertificateChainVerifiedUpstream{}only when your TLS termination verifies every chain. Step 4 - Client assertion audiences: leave
Config.CIBAEndpointURLAudiencesoff unless CIBA clients you can't change name an endpoint URL asaud: an endpoint URL is what audience injection exploits. CIBA - (yours) Authenticate before redirecting. Before a user has
authenticated, end with
DenyLocally, neverDenyorAuthenticationFailed. Step 5 - (yours) Pass the real authentication time to
server.NewAuthenticationContext: when the user actually authenticated, nottime.Now()when you reuse a session, somax_ageandprompt=loginhold. Step 5 - (yours) Bind the interaction to the browser with
server/interactioncookie(its keys shared by every instance) or the equivalent: a cookie only your server could have set, sealed, MACed or naming a server-side session. Never the raw handle in a plain cookie. Protect the consent form against CSRF. Step 5 - (yours) Wrap
/authorizeand every login, consent and error page inserver.AuthorizationPageHeaders(anti-framing,Referrer-Policy: no-referrer,no-store). Load no third-party scripts or images there, and don't log full/authorizeURLs. The library's results log redacted, and so do its requests when you log the request itself; don't log what bypasses that:Destination(),AuthorizationSession.URL(), a handle's or aRequestURI'sString()(which slog's text handler calls for one in an exported field of your struct),Reveal(), a request's fields, a storage encoding, or a slice or struct holding results through slog's JSON handler. Redirect with 303 after a form POST, and render errors withWriteText/WriteJSON, neverError(). Step 5 - (yours) Rate-limit
/authorize, and size the replay store for it.BeginAuthorizationruns before anyone has authenticated, and counts each interaction it begins inDependencies.Replay: a 32-byte record, keptLimits.PushedRequestLifetimeplus twiceLimits.MaxClockSkew, up to eight perrequest_uri. SetDependencies.PushedRequestLookupto thestorage.PushedRequestLookupbuilt on yourTransactionsstorage, if it has one (sqlstore'sdb.PushedRequestLookup()from sqlstore v0.11.0; one of your own must passstorage.TestPushedRequestLookupContract): arequest_urithat is unknown, expired, already used or presented with anotherclient_idis then refused before anything is written. Without it, every such request leaves a record until it expires. PAR - (yours) The HTTP layer: TLS 1.2 or later with BCP 195 cipher suites (at the proxy, if one terminates TLS), HSTS on browser-facing endpoints, and no CORS on the authorization endpoint. Step 6
- (yours) Client certificates behind a proxy: read a forwarded
certificate with
fapihttp.ForwardedClientCertificate(RFC 9440Client-Cert), passing atrustedcheck such asfapihttp.RemoteAddrInthat accepts only your own proxy, and have the proxy strip any copy of the header a client sent. Step 7 - Subjects: decide between public and pairwise subjects before
clients store any
sub. Pairwise subjects
-
resource.AssuranceProductionwithDeploymentset, and stores that pass the same contract tests as above. Build aConfig -
Config.ResourceURLsset to this API's own external URLs; behind a proxy that rewrites paths, setVerifyRequest.URL. Verify a request - The access token format matches the authorization server's.
JWT:
MaxTokenLifetimeat least the server'sAccessTokenLifetime, andAudienceset. Opaque: the samestorage.AccessTokenStorethe authorization server writes to, since there is no introspection endpoint. WireDependencies - The same revocation store as the authorization server, or
resource.NoRevocationUntilExpiry{MaxTokenLifetime: ...}(at most 15 minutes) to decline checking it; production refusesNoRevocation{}. WireDependencies - A DPoP nonce choice: a nonce store of the resource server's
own (never the authorization server's; with
sqlstore,Nonces()from a DB with aTablePrefixof its own), shared by its instances, withRandomandLimits.DPoPNonceLifetime; orresource.NoDPoPNonces{}to decline.serverresource.NewVerifiertakes it asOptions.Nonces. WireDependencies - (yours) Authorize anything a user owns by
AuthorizationContext.EndUser(), never byInternalSubjectalone (a client credentials token's subject is a client), and useClientSubjectfor anything returned to a client.EndUsertells a client's token apart only for FAPIgo's authorization server, which marks one withgrant_type; behind another, check that it keeps client IDs and user identifiers apart (RFC 9068 §5), or refuse a token whoseInternalSubjectequals itsClientID. Pairwise subjects at a resource server - (yours)
PeerCertificatebehind a proxy: the same rule as the authorization server's, withfapihttp.ForwardedClientCertificate. Verify a request
-
client.AssuranceProduction, withDependencies.HTTPfromfapihttp.NewClientand any client certificate or private roots given when it's built. Step 10 - A durable session store that passes
storage.TestSessionStoreContract(sqlstore'sSessions()does; for a native app withCallbackBindingDeviceLocalStore, on SQLite), and durable keys declaringkeys.KeyCustodyAssurance. - (yours) Bind each authorization to the browser that began it,
against login CSRF, where only your application can have put the
handle:
client/sessioncookie's sealed__Host-cookie, a cookie you MAC, or a server-side record. Never the raw handle in a plain cookie. Step 10 - (yours) Serve the redirect URI with
Referrer-Policy: no-referrer, and no third-party content, and keep callback URLs out of logs, so the authorization code doesn't leak (RFC 9700 §4.2.4): under plainProfileFAPISecuritythe callback URL carries the code andstateunsigned. Step 4 -
RequireAuthorizationResponseIss, andMaxIDTokenLifetimeset to your provider's ID token lifetime if you know it. - (yours) Seal stored tokens with
client.TokenSetSealerif you keep them past the request. Step 10
For a deployment keeping its stores in the
sqlstore module.
Durable storage
- The right database for the deployment: PostgreSQL for
DeploymentHorizontallyScaled; SQLite (WAL mode, a busy timeout) only forDeploymentSingleInstance, on the one host that serves. - The schema migrated before serving:
Migrateat startup as a role that may create tables, or from a deployment step, withCheckSchemaat startup to fail fast when it's behind. -
Sweepon a schedule (every few minutes) with the server's time, or the tables grow without bound. A CIBA request is keptBackchannelExpiredRetention(an hour) past its expiry, so a late poll is toldexpired_token. - One
TablePrefixper role and tenant: the authorization server and the resource servers reading its opaque access tokens or revocations share the server's prefix (andSealer); a resource server's DPoP nonces get a prefix of their own; servers with different issuers never share one. - (yours) A least-privilege database role for each resource
server:
SELECTon the server'saccess_tokens,revocationsandschema_migrations,SELECT/INSERTonreplay, and its own prefix's tables; only the authorization server sweeps the tables they share. - (yours) A sealing key kept outside the database and its
backups (
Options.Sealer,AESGCMSealer), with a rotation plan:RotatingSealer, in three deploys (open with both keys everywhere, then seal with the new one, then drop the old one once its records expire; see sqlstore's Sealing documentation), well before a key's 2^32 seals (weeks, on a busy server). - (yours)
CheckClientRegistrationon every client at startup (Clients().All) and after eachClients().Put. -
ReadUnsealedonly while migrating an existing database to sealing: deploy with it, runSealRecords, then deploy without it. - (yours) Write access to the database as tight as read access: sealing keeps records confidential and bound to their row, but anyone who can write can still delete rows or change lookup columns.