@o3co/create-auth-provider 0.16.0 → 0.17.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +66 -21
- package/README.md +76 -31
- package/dist/index.d.mts +33 -10
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +118 -59
- package/dist/internal/template-filter.d.mts +7 -10
- package/dist/internal/template-filter.d.mts.map +1 -1
- package/dist/internal/template-filter.mjs +7 -10
- package/package.json +6 -4
- package/templates/standalone/.dockerignore +15 -2
- package/templates/standalone/.env.example +59 -26
- package/templates/standalone/Dockerfile +6 -2
- package/templates/standalone/README.ja.md +293 -162
- package/templates/standalone/README.md +533 -199
- package/templates/standalone/config/application.conf +196 -341
- package/templates/standalone/config/clients.yaml +2 -0
- package/templates/standalone/config/clients.yaml.example +4 -0
- package/templates/standalone/config/development.conf +13 -4
- package/templates/standalone/config/mailpit.conf +8 -0
- package/templates/standalone/config/production.conf +5 -6
- package/templates/standalone/config/reference.conf +399 -0
- package/templates/standalone/docker-compose.mailpit.yml +36 -0
- package/templates/standalone/docker-compose.production.yml +58 -30
- package/templates/standalone/docker-compose.yml +13 -3
- package/templates/standalone/gitignore +1 -0
- package/templates/standalone/package.json +9 -6
- package/templates/standalone/src/__tests__/access-token-lifetime-alias.test.mts +19 -20
- package/templates/standalone/src/__tests__/adapters.test.mts +358 -0
- package/templates/standalone/src/__tests__/all-modules-composition.fixture.mts +216 -141
- package/templates/standalone/src/__tests__/all-modules-composition.multi.test.mts +48 -33
- package/templates/standalone/src/__tests__/all-modules-composition.test.mts +77 -58
- package/templates/standalone/src/__tests__/audit-sink.test.mts +78 -76
- package/templates/standalone/src/__tests__/configPath.test.mts +13 -11
- package/templates/standalone/src/__tests__/core-federations.test.mts +226 -0
- package/templates/standalone/src/__tests__/core-sections.test.mts +190 -0
- package/templates/standalone/src/__tests__/device-code-store-client-module.test.mts +9 -14
- package/templates/standalone/src/__tests__/documented-env-overrides.test.mts +656 -269
- package/templates/standalone/src/__tests__/federation-grants-composition.test.mts +425 -84
- package/templates/standalone/src/__tests__/federation-grants-survive-logout.test.mts +91 -70
- package/templates/standalone/src/__tests__/federation-token-refresh-outage.test.mts +7 -5
- package/templates/standalone/src/__tests__/google-federation-config-module.test.mts +22 -19
- package/templates/standalone/src/__tests__/google-session.fixture.mts +53 -42
- package/templates/standalone/src/__tests__/host-routes.test.mts +4 -11
- package/templates/standalone/src/__tests__/library-references.fixture.mts +183 -0
- package/templates/standalone/src/__tests__/listen.test.mts +6 -13
- package/templates/standalone/src/__tests__/logger-projection.test.mts +1 -1
- package/templates/standalone/src/__tests__/mail-sender.test.mts +134 -0
- package/templates/standalone/src/__tests__/mailpit-compose.test.mts +328 -0
- package/templates/standalone/src/__tests__/metrics.test.mts +4 -9
- package/templates/standalone/src/__tests__/mfa-switch.redis.test.mts +123 -0
- package/templates/standalone/src/__tests__/mfa-switch.test.mts +780 -0
- package/templates/standalone/src/__tests__/oidc-federation-config-module.test.mts +52 -46
- package/templates/standalone/src/__tests__/own-modules.test.mts +1457 -0
- package/templates/standalone/src/__tests__/post-logout-redirect.test.mts +7 -11
- package/templates/standalone/src/__tests__/redis-connection-error-log.test.mts +1 -5
- package/templates/standalone/src/__tests__/redis-rate-limiter-config-survives.test.mts +112 -81
- package/templates/standalone/src/__tests__/refresh-token-family-client-module.test.mts +25 -31
- package/templates/standalone/src/__tests__/replica-safety.test.mts +153 -142
- package/templates/standalone/src/__tests__/router-error-answers.test.mts +4 -7
- package/templates/standalone/src/__tests__/scaffold-assets.test.mts +275 -95
- package/templates/standalone/src/__tests__/sections.test.mts +480 -0
- package/templates/standalone/src/__tests__/session-logout-invalidates-token.test.mts +67 -55
- package/templates/standalone/src/__tests__/session-requirements.test.mts +299 -0
- package/templates/standalone/src/__tests__/shutdown.test.mts +163 -96
- package/templates/standalone/src/__tests__/smoke.test.mts +179 -252
- package/templates/standalone/src/__tests__/store-credential.test.mts +91 -50
- package/templates/standalone/src/__tests__/supertest-loopback.test.mts +182 -11
- package/templates/standalone/src/__tests__/three-tier-resolution.test.mts +108 -95
- package/templates/standalone/src/__tests__/two-phase-config.test.mts +438 -0
- package/templates/standalone/src/__tests__/upstream-amr.acceptance.test.mts +390 -0
- package/templates/standalone/src/adapters.mts +149 -0
- package/templates/standalone/src/app.mts +64 -79
- package/templates/standalone/src/buildModules.mts +212 -251
- package/templates/standalone/src/configPath.mts +422 -29
- package/templates/standalone/src/listen.mts +12 -18
- package/templates/standalone/src/logger.mts +31 -60
- package/templates/standalone/src/metrics.mts +24 -47
- package/templates/standalone/src/mfaSwitch.mts +262 -0
- package/templates/standalone/src/modules.mts +458 -476
- package/templates/standalone/src/rootRenames.mts +79 -0
- package/templates/standalone/src/routes.mts +8 -14
- package/templates/standalone/src/sections.mts +366 -0
- package/templates/standalone/src/shutdown.mts +45 -123
- package/templates/standalone/tests/index.test.js +2 -2
- package/templates/standalone/tests/package-lock.json +1615 -2223
- package/templates/standalone/tests/package.json +2 -2
- package/templates/standalone/tests/vitest.config.mjs +26 -0
- package/templates/standalone/vitest.config.mts +8 -7
- package/templates/standalone/vitest.supertest-loopback.mts +97 -69
- package/templates/versions.json +18 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @o3co/auth-provider-standalone
|
|
2
2
|
|
|
3
|
-
Last updated: 2026-
|
|
3
|
+
Last updated: 2026-10-03
|
|
4
4
|
|
|
5
5
|
Deployable server template for auth.provider. This is the composition root — it reads config, loads modules, and starts the Express server. Generated by `@o3co/create-auth-provider`.
|
|
6
6
|
|
|
@@ -11,20 +11,27 @@ not a library: nothing imports it. `@o3co/create-auth-provider` copies it into
|
|
|
11
11
|
a new project, and from then on the operator owns and edits the copy. It sits
|
|
12
12
|
on top of the packages: it composes `@o3co/auth-provider-oauth`, `-session`,
|
|
13
13
|
the Google and generic OpenID Connect federation adapters, `-federation-grants`,
|
|
14
|
-
`-redis` and `-
|
|
14
|
+
`-mfa`, `-redis`, `-foundation` and `-standard`'s mail senders over
|
|
15
|
+
`@o3co/auth-provider-core`.
|
|
15
16
|
|
|
16
17
|
**Owns** the choices that are specific to one deployment:
|
|
17
18
|
|
|
18
19
|
- which modules are composed, in what order, and which adapter fills each
|
|
19
20
|
store slot — [`src/buildModules.mts`](src/buildModules.mts) (see
|
|
20
|
-
[Module Composition Order](#module-composition-order))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
[Module Composition Order](#module-composition-order)), the choice read from
|
|
22
|
+
its own keys, the `adapters` section ([`src/adapters.mts`](src/adapters.mts))
|
|
23
|
+
and the MFA switch `mfaMode` ([`src/mfaSwitch.mts`](src/mfaSwitch.mts));
|
|
24
|
+
- the modules only this scaffold has — `logging` and `http` (the host
|
|
25
|
+
process's own settings, with its CORS list, and core's `httpSettings`
|
|
26
|
+
slot), the signing key store, the client and user repositories, the audit
|
|
27
|
+
sink, the one shared
|
|
28
|
+
Redis connection, the in-memory user-session stores, code repository and
|
|
29
|
+
federation token store, and the federation config bridges —
|
|
30
|
+
[`src/modules.mts`](src/modules.mts), with the defaults of the sections they
|
|
31
|
+
own in [`config/reference.conf`](config/reference.conf). They are the
|
|
32
|
+
scaffold's rather than a package's because each builds its component from
|
|
33
|
+
this template's configuration sections; a deployment that wants another
|
|
34
|
+
source wires its own module of the same shape;
|
|
28
35
|
- where configuration comes from and how its layers stack —
|
|
29
36
|
[`src/configPath.mts`](src/configPath.mts) and [`config/`](config/);
|
|
30
37
|
- the host process: the Express app, its security headers and startup —
|
|
@@ -71,7 +78,7 @@ repository.
|
|
|
71
78
|
- **Node.js** `>=22.0.0`
|
|
72
79
|
- **`bcrypt` native binary**: this template depends transitively on `bcrypt@6.x`, which ships **prebuilt N-API binaries** for `darwin-arm64`, `darwin-x64`, `linux-x64` (glibc and musl), `linux-arm64` (glibc and musl), `linux-arm`, `win32-x64`, and `win32-arm64`. On these platforms `pnpm install` succeeds without compiling from source, and no extra toolchain is required (the `darwin-*`, `node:*-alpine`, and `node:*-bookworm` images all match a shipped prebuild). On platforms or libc/arch combinations that have no matching prebuild, `pnpm install` falls back to compiling, which then requires a C++ compiler and Python (the standard Node.js native-addon toolchain): Debian/Ubuntu `apt-get install build-essential python3`, Alpine `apk add make g++ python3`, macOS `xcode-select --install`. The pnpm 10 `onlyBuiltDependencies` allowlist for `bcrypt` lives in `pnpm-workspace.yaml` — pnpm ≥10.29 reads it only from there, in single-package projects too. `create-auth-provider` writes that file into the project it scaffolds (inside this monorepo, the allowlist sits in the workspace root's `pnpm-workspace.yaml`); without it a fresh `pnpm install` silently skips the install hook on those platforms.
|
|
73
80
|
- **Redis 7.2 LTS or later** for any Redis-backed adapter (refresh token family store, code repository, federation token store, session store). The `pExpireGT` flag pair on which several adapters depend was introduced in Redis 7.0+; 7.2 LTS is the tested floor. Tested against AWS ElastiCache for Redis 7.2, Upstash Redis, Redis Cloud 7.2, and self-managed `redis:7.2-alpine`.
|
|
74
|
-
- **ioredis** `^6.0.0` (direct runtime dependency). Every `@o3co/auth-provider-redis` adapter this template wires — refresh-token families, authorization codes, rate-limit counters, the access-token denylist, the replay seen-set, the user-session stores, the federation-token store, the consent stores and the federation-grant stores — runs off the one ioredis connection `standaloneRedisClientsModule` opens per replica. The same module provides the client of every other store the Redis package ships — the device-code store and the WebAuthn challenge store — so a deployment that adds the device grant or WebAuthn to `buildModules.mts` with a Redis store finds its client there. The `redis` npm package (`^6.2.1`) stays a dependency for one thing: `connect-redis` takes a node-redis client, so the `express-session` store behind `
|
|
81
|
+
- **ioredis** `^6.0.0` (direct runtime dependency). Every `@o3co/auth-provider-redis` adapter this template wires — refresh-token families, authorization codes, rate-limit counters, the access-token denylist, the replay seen-set, the user-session stores, the federation-token store, the consent stores and the federation-grant stores — runs off the one ioredis connection `standaloneRedisClientsModule` opens per replica. The same module provides the client of every other store the Redis package ships — the device-code store and the WebAuthn challenge store — so a deployment that adds the device grant or WebAuthn to `buildModules.mts` with a Redis store finds its client there. The `redis` npm package (`^6.2.1`) stays a dependency for one thing: `connect-redis` takes a node-redis client, so the `express-session` store behind `SESSION_STORE_STORAGE_TYPE=redis` is a second, separate connection (the `session-store` probe in `/readyz`).
|
|
75
82
|
|
|
76
83
|
## First-party clients
|
|
77
84
|
|
|
@@ -79,7 +86,7 @@ For a client marked `firstParty: true`, `GET /authorize` mints an authorization
|
|
|
79
86
|
|
|
80
87
|
That is a coherent model for a **first-party** OP — one where every registered client is operated by you — and it is coherent nowhere else. A page you do not control can force a top-level navigation to `/authorize?client_id=X&redirect_uri=...&code_challenge=<theirs>`, a logged-in user's browser mints a code bound to *their* session, it is delivered to X's registered `redirect_uri`, and whoever chose the `code_challenge` redeems it for tokens carrying that user's identity.
|
|
81
88
|
|
|
82
|
-
So the assumption is enforced rather than assumed. Every other client — one with no `firstParty` field and one carrying `false` alike — goes through the consent step: the user is asked on your consent page before a code is minted. That step needs a consent store, and the template ships none (`
|
|
89
|
+
So the assumption is enforced rather than assumed. Every other client — one with no `firstParty` field and one carrying `false` alike — goes through the consent step: the user is asked on your consent page before a code is minted. That step needs a consent store, and the template ships none (`ADAPTERS_CONSENT_STORE=none`), so on the defaults such a client is refused at `/authorize` with `unauthorized_client`; see [Consent Store](#consent-store) to serve it. Mark a client first-party only if you would be comfortable with it receiving a user's identity **without the user being asked**.
|
|
83
90
|
|
|
84
91
|
```yaml
|
|
85
92
|
# config/clients.yaml
|
|
@@ -103,7 +110,7 @@ Nothing secret lives in `clients.yaml` for such a client.
|
|
|
103
110
|
|
|
104
111
|
The [operator runbook](../../docs/operator-runbook.md) covers the operational side end to end — boot refusals, probes, dependency failures, alerts, Redis sizing, key rotation. This section is the multi-replica checklist.
|
|
105
112
|
|
|
106
|
-
When running multiple instances of the standalone server behind a load balancer, point `
|
|
113
|
+
When running multiple instances of the standalone server behind a load balancer, point `REDIS_CLIENTS_URL` at a **shared** Redis 7.2+ instance. Without a shared Redis URL, every replica holds refresh-token families in its own connection (and any local-only Redis), so a refresh request that lands on a replica that did not issue the token returns `invalid_grant` on every other request in a round-robin LB.
|
|
107
114
|
|
|
108
115
|
**Set `HTTP_TRUST_PROXY` to your proxy's address behind a load balancer.** It defaults to `false`, which makes `req.ip` the *load balancer's* address rather than the client's. Every rate limit keyed by IP — the OAuth endpoint limiters and the `POST /session/login` brute-force guard — then shares **one bucket across all users**: the first 20 login attempts from anyone exhaust the window and every subsequent user gets `429`. The failure reads like an attack rather than a misconfiguration, which is what makes it expensive to diagnose at 3am. Set it whenever anything terminates TLS or proxies in front of this service, and make sure that hop is the one setting `X-Forwarded-For`. An audit event with no `ip` means the request's address was not an address — `req.ip` came from an `X-Forwarded-For` that held something else — so check that `HTTP_TRUST_PROXY` trusts only the hop that sets the header.
|
|
109
116
|
|
|
@@ -120,7 +127,7 @@ It takes four shapes, all of them Express's own:
|
|
|
120
127
|
|
|
121
128
|
An allowlist is a network control, not a cryptographic one. The edge must also **strip** inbound `X-Forwarded-*` headers rather than appending to them, and the hop between it and this process must not be reachable by anyone able to spoof a source address.
|
|
122
129
|
|
|
123
|
-
**Point `rateLimiter
|
|
130
|
+
**Point `adapters.rateLimiter` at Redis.** It defaults to `"memory"`, which is per-process: with N replicas every configured limit is effectively N times larger and resets on every deploy. The memory adapter is also **evadable under bucket exhaustion**: it caps itself at 10,000 buckets and, at the cap, admitting a new key evicts the bucket closest to reset — so an attacker who can present many source IPs (and `req.ip` is client-influenced whenever `HTTP_TRUST_PROXY` is broader than your actual hops) can churn the table until a target's counter is evicted and starts over. That is acceptable for one dev process; it is not a production rate limit. The login guard runs on this same shared component, so one setting covers both the OAuth endpoints and `/session/login`. The login window and limit stay configured at `session.rateLimit.login`; the session module contributes them as the `login` budget both adapters read, so there is nothing to restate.
|
|
124
131
|
|
|
125
132
|
**Behind a BFF, raise `limits.token` before you need to.** The OAuth-endpoint
|
|
126
133
|
rate limits key on `req.ip` (`packages/core/src/ratelimit/guard.mts` builds the
|
|
@@ -143,10 +150,11 @@ its address is the honest answer to "who called". There is no per-user identity
|
|
|
143
150
|
in these requests to key on.
|
|
144
151
|
|
|
145
152
|
The knob is the per-endpoint budget. Both limiter adapters take
|
|
146
|
-
`limits { <prefix> { limit, windowSeconds } }
|
|
153
|
+
`limits { <prefix> { limit, windowSeconds } }` in their own sections, keyed by
|
|
154
|
+
the endpoint prefix:
|
|
147
155
|
|
|
148
156
|
```hocon
|
|
149
|
-
|
|
157
|
+
redis-rate-limiter {
|
|
150
158
|
limits {
|
|
151
159
|
token { limit = 600, windowSeconds = 60 }
|
|
152
160
|
introspect { limit = 600, windowSeconds = 60 }
|
|
@@ -154,9 +162,9 @@ redisRateLimiter {
|
|
|
154
162
|
}
|
|
155
163
|
```
|
|
156
164
|
|
|
157
|
-
(`
|
|
165
|
+
(`core-rate-limiter-memory.limits` for the memory adapter, same shape.) Size it from
|
|
158
166
|
your BFF's peak sign-ins and refreshes per minute with headroom, and remember
|
|
159
|
-
that under `rateLimiter
|
|
167
|
+
that under `adapters.rateLimiter = "redis"` the budget is shared across replicas
|
|
160
168
|
— which is what you want here, and what makes the number mean something.
|
|
161
169
|
|
|
162
170
|
The defaults are deliberately left alone: 60/60 s per source IP is a sensible
|
|
@@ -165,21 +173,23 @@ raising it globally to accommodate one topology would weaken it for the other.
|
|
|
165
173
|
Put the throttling that protects the BFF's *own* users in front of the BFF,
|
|
166
174
|
where per-user identity still exists.
|
|
167
175
|
|
|
168
|
-
**Set `
|
|
176
|
+
**Set `CORE_DEPLOYMENT_MODE=multi` once you run more than one replica.** Boot then *fails* if any in-memory store that has to be shared is still wired, naming every offender and what it costs — user sessions forking (back-channel logout reaches one replica, a logged-out session stays valid on the others), rate-limit counters multiplying, access-token revocation not propagating, a single-use client assertion or WebAuthn challenge replayable once per replica. The check reads the declaration each installed module carries on its own manifest rather than a list of library module names, so this template's own in-memory modules — the user-session stores (`ADAPTERS_USER_SESSION_STORES=memory`), the authorization-code repository (`ADAPTERS_CODE_REPOSITORY=memory`) and the federation token store (`ADAPTERS_FEDERATION_TOKEN_STORE=memory`, the default) — are refused by name too. So are express-session's own store under `SESSION_STORE_STORAGE_TYPE=memory` (#474) and the default memory rate limiter (`core-rate-limiter-memory`, `ADAPTERS_RATE_LIMITER=memory`). With the mode unset nothing is refused: every one of them is listed in a single `replica_unsafe_adapters` warning at boot. (The login and WebAuthn-options routes carry per-process fallback limiters that warn on their own, but only in a composition that wires no `rateLimiter` at all, which this template never does; see the operator runbook.) With `CORE_DEPLOYMENT_MODE=single` the check is silent, because you have said there is one replica. This template does not install DPoP; a composition that adds it records every accepted proof in the same replay seen-set as `private_key_jwt` (`ADAPTERS_REPLAY_SEEN_SET`), so it gets the same answer — `memory` is refused under `CORE_DEPLOYMENT_MODE=multi` and listed in the unset-mode warning, and the shipped `redis` shares DPoP's records across replicas — see the dpop package's [operator requirements](../../packages/dpop/README.md#operator-requirements).
|
|
169
177
|
|
|
170
|
-
|
|
178
|
+
The variable sets `core.deployment.mode`. `DEPLOYMENT_MODE`, its old name, refuses boot set alone or beside `CORE_DEPLOYMENT_MODE` at a different value; beside it at the same value, it boots.
|
|
171
179
|
|
|
172
|
-
|
|
180
|
+
Be aware of what this check *cannot* do: if you scale to N replicas without ever setting `CORE_DEPLOYMENT_MODE`, nothing fails. A process holding all its state in its own memory has no shared medium through which to notice peers — the condition is undetectable from inside exactly when it is true. Set the variable as part of scaling, not after something breaks.
|
|
181
|
+
|
|
182
|
+
**Access-token revocation needs a denylist, and the template ships one.** `POST /oauth/revoke` revokes an access token by writing its `jti` to the `accessTokenDenylist`, which token verification and introspection consult. Boot *fails* if the endpoint is mounted with no denylist behind it: RFC 7009 obliges the endpoint to answer `200`, so an unwired denylist would tell you a token is revoked while it keeps working until it expires. `adapters.accessTokenDenylist` defaults to `"redis"` here (`ADAPTERS_ACCESS_TOKEN_DENYLIST=memory` for single-instance local work) and shares the ioredis socket configured by `REDIS_CLIENTS_URL`, so it costs no extra connection. A deployment that genuinely does not revoke access tokens sets `OAUTH_REVOCATION_ACCESS_TOKEN=unsupported` instead; the endpoint then answers `unsupported_token_type` for `token_type_hint=access_token`. **Refresh-token revocation works in either case and never needed a denylist.**
|
|
173
183
|
|
|
174
184
|
Other multi-replica considerations covered by the default modules:
|
|
175
185
|
|
|
176
|
-
- The `express-session` store (`sessionStoreModule`) is its own connection: `
|
|
177
|
-
- The user-session stores switch on `userSessionStores
|
|
178
|
-
- The authorization-code repository switches on `
|
|
179
|
-
- The replay seen-set — the `jti` single-use record behind `private_key_jwt` client authentication (#484) — switches on `replaySeenSet
|
|
180
|
-
- The consent step for clients that are not first-party (#527) switches on `consentStore
|
|
181
|
-
- The federation token store defaults to memory. Set `
|
|
182
|
-
- Federation grants (#593), when enabled, keep two more stores: the grants themselves (`
|
|
186
|
+
- The `express-session` store (`sessionStoreModule`) is its own connection: `SESSION_STORE_STORAGE_TYPE=redis` with `SESSION_STORE_STORAGE_REDIS_URL` (`session-store.storage.redis.url`) pointing at the shared instance.
|
|
187
|
+
- The user-session stores switch on `adapters.userSessionStores = "redis"` (`ADAPTERS_USER_SESSION_STORES`), which wires `redisSessionStoresModule` off the shared ioredis connection — the one `REDIS_CLIENTS_URL` configures.
|
|
188
|
+
- The authorization-code repository switches on `adapters.codeRepository` (`ADAPTERS_CODE_REPOSITORY`); the template ships `"redis"`, on that same connection, so there is one Redis URL for every adapter. The Redis repository's own settings are its section, `redis-code-repository`; the in-process one's, `standalone-in-memory-code-repository` (see [Code Repository](#code-repository)).
|
|
189
|
+
- The replay seen-set — the `jti` single-use record behind `private_key_jwt` client authentication (#484) — switches on `adapters.replaySeenSet` (`ADAPTERS_REPLAY_SEEN_SET`); the template ships `"redis"` on the shared connection, and `memory` is refused under `CORE_DEPLOYMENT_MODE=multi` because a captured client assertion would replay once per replica.
|
|
190
|
+
- The consent step for clients that are not first-party (#527) switches on `adapters.consentStore` (`ADAPTERS_CONSENT_STORE`). It is off (`none`) by default; `memory` is refused under `CORE_DEPLOYMENT_MODE=multi`, because a consent granted on one replica would be asked for again on every other and a consent page's parked request would be unknown to the replica that receives the answer. `redis` (#561) keeps both on the shared connection. See [Consent Store](#consent-store).
|
|
191
|
+
- The federation token store defaults to memory. Set `ADAPTERS_FEDERATION_TOKEN_STORE=redis` (`adapters.federationTokenStore = "redis"`) and supply `REDIS_FEDERATION_TOKEN_STORE_ENCRYPTION_KEY` — 32 bytes, base64-encoded (`openssl rand -base64 32`); the store encrypts the upstream refresh tokens it holds. It shares the ioredis socket configured by `REDIS_CLIENTS_URL`. See [Federation Token Store](#federation-token-store).
|
|
192
|
+
- Federation grants (#593), when enabled, keep two more stores: the grants themselves (`ADAPTERS_FEDERATION_GRANT_STORE`) and acquisition's records (`ADAPTERS_FEDERATION_GRANT_INTENT_STORE`). Both ship `none`, which an enabled feature refuses at boot naming the store: select `redis` (the shared socket) or `memory` for each; `memory` for either is refused under `CORE_DEPLOYMENT_MODE=multi`, and Redis grants beside memory user-session stores are refused on any replica count, because the grants would outlive the boundary that ends them. See [Federation Grants](#federation-grants).
|
|
183
193
|
|
|
184
194
|
## Usage
|
|
185
195
|
|
|
@@ -189,26 +199,37 @@ shell that starts it — and it does not boot until that environment supplies:
|
|
|
189
199
|
|
|
190
200
|
- `OAUTH_JWT_ISSUER` — this server's origin (`http` is accepted for a loopback
|
|
191
201
|
host);
|
|
192
|
-
- a signing key pair, `
|
|
202
|
+
- a signing key pair, `KEY_STORE_LOCAL_PRIVATE_KEY_PATH` / `KEY_STORE_LOCAL_PUBLIC_KEY_PATH`
|
|
193
203
|
(see [OAuth JWT](#oauth-jwt));
|
|
194
|
-
- `
|
|
195
|
-
- `
|
|
204
|
+
- `SESSION_STORE_SECRET`, at least 32 bytes;
|
|
205
|
+
- `REPOSITORIES_USER_HTTP_AUTHENTICATE_URL` and `REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL` —
|
|
196
206
|
your user service ("the Store"), `https`, or `http` on a loopback host. Boot
|
|
197
207
|
checks their form, not that anything answers; logins fail until something
|
|
198
208
|
does (see [User Repository](#user-repository));
|
|
199
209
|
- a Redis it can reach at `redis://localhost:6379`. The shipped configuration
|
|
200
|
-
keeps the browser session store there (`
|
|
201
|
-
opens one shared connection (`
|
|
210
|
+
keeps the browser session store there (`SESSION_STORE_STORAGE_REDIS_URL`), and
|
|
211
|
+
opens one shared connection (`REDIS_CLIENTS_URL`) for the
|
|
202
212
|
refresh-token families, the authorization codes, the access-token denylist
|
|
203
213
|
and the replay seen-set — and for the user-session stores, with the setting
|
|
204
214
|
below.
|
|
205
215
|
|
|
206
|
-
Plain HTTP also needs `
|
|
216
|
+
Plain HTTP also needs `SESSION_STORE_SECURE=false` and a session cookie name without
|
|
207
217
|
the `__Host-` prefix (see [Session](#session)). And set
|
|
208
|
-
`
|
|
218
|
+
`ADAPTERS_USER_SESSION_STORES=redis`: the browser session store is in Redis, the
|
|
209
219
|
user-session stores default to memory, and `tsx watch` restarts the process on
|
|
210
220
|
every save — split, a restart leaves the browser's session pointing at a
|
|
211
221
|
`UserSession` that is gone, and `/authorize` loops (see [Docker](#docker)).
|
|
222
|
+
MFA is on by default, and its two stores default to memory too: set
|
|
223
|
+
`ADAPTERS_MFA_FACTOR_STORE=redis` and `ADAPTERS_MFA_TRANSACTION_STORE=redis`
|
|
224
|
+
for the same reason, or every save empties them while the sessions survive —
|
|
225
|
+
or `MFA_MODE=off` to run without MFA (see
|
|
226
|
+
[Multi-factor authentication](#multi-factor-authentication)).
|
|
227
|
+
|
|
228
|
+
It also reads the client registry, `config/clients.yaml` (`REPOSITORIES_CLIENT_YAML_PATH`). That
|
|
229
|
+
file is per-deployment: the scaffold creates an empty one, and `.gitignore`
|
|
230
|
+
keeps it out of the project's repository, so a fresh clone has none and boot
|
|
231
|
+
fails naming the path until you create it — from `config/clients.yaml.example`,
|
|
232
|
+
or empty for a registry with no clients.
|
|
212
233
|
|
|
213
234
|
The key pair below is generated with Node, which every machine running this
|
|
214
235
|
already has. `openssl genpkey -algorithm ed25519` works too, with OpenSSL 1.1.1
|
|
@@ -229,13 +250,14 @@ docker run -d --name auth-redis -p 127.0.0.1:6379:6379 redis:7.2-alpine
|
|
|
229
250
|
|
|
230
251
|
# What boot requires (replace the user-service URLs with your Store's)
|
|
231
252
|
export OAUTH_JWT_ISSUER=http://localhost:3000 \
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
253
|
+
KEY_STORE_LOCAL_PRIVATE_KEY_PATH=./jwt-private.pem \
|
|
254
|
+
KEY_STORE_LOCAL_PUBLIC_KEY_PATH=./jwt-public.pem \
|
|
255
|
+
SESSION_STORE_SECRET="$(openssl rand -hex 32)" \
|
|
256
|
+
SESSION_STORE_SECURE=false SESSION_STORE_NAME=auth.sid \
|
|
257
|
+
ADAPTERS_USER_SESSION_STORES=redis \
|
|
258
|
+
ADAPTERS_MFA_FACTOR_STORE=redis ADAPTERS_MFA_TRANSACTION_STORE=redis \
|
|
259
|
+
REPOSITORIES_USER_HTTP_AUTHENTICATE_URL=http://localhost:8080/authenticate \
|
|
260
|
+
REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL=http://localhost:8080/authenticate-by-token
|
|
239
261
|
|
|
240
262
|
# Start in development mode (hot reload)
|
|
241
263
|
pnpm run debug
|
|
@@ -256,63 +278,149 @@ image and its compose file are under [Docker](#docker).
|
|
|
256
278
|
|
|
257
279
|
## Configuration
|
|
258
280
|
|
|
259
|
-
Configuration is loaded from `config/application.conf` (HOCON format). Each value can be overridden with the corresponding environment variable.
|
|
281
|
+
Configuration is loaded from `config/application.conf` (HOCON format), over the defaults in the packages' `reference.conf` files and the template's own `config/reference.conf`. Each value can be overridden with the corresponding environment variable.
|
|
260
282
|
|
|
261
283
|
### Environment-specific config overlay
|
|
262
284
|
|
|
263
|
-
`src/app.mts` loads configuration in
|
|
285
|
+
`src/app.mts` loads configuration in layers, highest precedence first:
|
|
264
286
|
|
|
265
287
|
1. **`config/{ENV}.conf`** — overlay for the current environment, where
|
|
266
288
|
`ENV = CONFIG_ENV || NODE_ENV || "development"`.
|
|
267
289
|
2. **`config/application.conf`** — this deployment's settings.
|
|
268
|
-
3.
|
|
269
|
-
resolved from the
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
3. **the `reference.conf` of each package the loaded modules come from**, then
|
|
291
|
+
**`@o3co/auth-provider-core`'s** — the defaults, resolved from the
|
|
292
|
+
installed packages: each module declares its package's file, and core's
|
|
293
|
+
`moduleReferences(modules)` lists them, core's last. The template's own
|
|
294
|
+
modules declare `config/reference.conf`, which holds the defaults of the
|
|
295
|
+
sections they own — `logging`, `http` (with its CORS list,
|
|
296
|
+
`http.cors`), `key-store`, the shared Redis connection's `redis-clients`,
|
|
297
|
+
`repositories`, the in-process code repository's
|
|
298
|
+
`standalone-in-memory-code-repository` and `audit-sink` — and of the
|
|
299
|
+
composition root's own `adapters` and `mfaMode` (below). Set a deployment's own value in
|
|
300
|
+
the two files above, not there. `config/reference.conf` binds each of these
|
|
301
|
+
keys' variables beside its default, so a value either file above sets wins
|
|
302
|
+
over the variable, except for `HTTP_PORT`, `HTTP_TRUST_PROXY`,
|
|
303
|
+
`HTTP_CORS_ALLOWED_ORIGINS` and `REDIS_CLIENTS_URL` /
|
|
304
|
+
`REDIS_CLIENTS_PASSWORD`, which `application.conf` binds again in its last
|
|
305
|
+
lines, so each of those wins over a value that file sets above them. A key
|
|
306
|
+
neither file above sets takes its value from here.
|
|
307
|
+
|
|
308
|
+
It reads the two files above once, under one snapshot of the environment
|
|
309
|
+
(`readOwnLayers`), and builds two phases from that one read
|
|
310
|
+
([#728](https://github.com/o3co/auth.provider/issues/728);
|
|
311
|
+
[`src/configPath.mts`](src/configPath.mts)) — so a file replaced, or a
|
|
312
|
+
variable changed, while the process starts cannot make boot parse something
|
|
313
|
+
other than what the modules were chosen by. First, before it knows its
|
|
314
|
+
modules, it reads the switches `buildModules` chooses them by — the
|
|
315
|
+
federations, the features — and the `sessionRequirements` it derives the
|
|
316
|
+
session requirements it expects from, from the two files above over core's
|
|
317
|
+
`reference.conf` alone (`readSwitches`, with core's transitional reader),
|
|
318
|
+
parsing those paths (`SWITCHES`) and nothing else. It reads `adapters` — which
|
|
319
|
+
adapter fills each slot, the composition root's own section — from the two
|
|
320
|
+
files above over the template's `config/reference.conf`, with the template's
|
|
321
|
+
own schema (`readAdapters`): a selection still written at the path it moved
|
|
322
|
+
from, or a variable renamed with it, is refused there, before any module is
|
|
323
|
+
chosen, naming the new path and variable. It reads the MFA switch `mfaMode`
|
|
324
|
+
(`MFA_MODE`), the composition root's own key, the same way, with the
|
|
325
|
+
template's own schema (`readMfaSwitch`), and beside them the user
|
|
326
|
+
repository's HTTP settings, unparsed, which the Store-backed MFA factor store
|
|
327
|
+
is built over. Boot is not handed `adapters` or `mfaMode`. It sees nothing
|
|
328
|
+
a package's `reference.conf` alone sets — none is layered yet — and a module
|
|
329
|
+
you add to `buildModules` that reads its configuration when it is built adds
|
|
330
|
+
the paths it reads to `SWITCHES`. The log level is read before boot too, as
|
|
331
|
+
the `logging` module's section, with that module's schema, over the template's
|
|
332
|
+
`reference.conf` (`readLogging`): the logger exists before boot, since the
|
|
333
|
+
template logs while it reads its configuration and chooses its modules. Then it hands `createApp` the configuration as resolved over every
|
|
334
|
+
loaded module's `reference.conf` (`resolveForBoot`), unparsed, with the session
|
|
335
|
+
requirements phase one derived written in, and the `mfa` section as the MFA
|
|
336
|
+
switch decides it (see [Multi-factor authentication](#multi-factor-authentication)):
|
|
337
|
+
boot parses it once, with every loaded module's schema. What
|
|
338
|
+
the template reads after boot — the trusted hops, the port, the readiness
|
|
339
|
+
deadline — it reads from the `http` module: core's `httpSettings` slot and the
|
|
340
|
+
template's `httpHostSettings`. A top-level section no
|
|
341
|
+
loaded module owns is kept and logged once at boot as
|
|
342
|
+
`config_sections_ignored`: that is where a misspelt section name shows.
|
|
273
343
|
|
|
274
344
|
Values in the overlay take precedence over `application.conf`. The scaffold
|
|
275
|
-
ships with `development.conf` and `
|
|
345
|
+
ships with `development.conf`, `production.conf` and `mailpit.conf` (the
|
|
346
|
+
development overlay under the name the
|
|
347
|
+
[Mailpit overlay](#mailpit-for-the-smtp-sender-development-only) selects). To add another
|
|
276
348
|
environment (e.g. `staging`), create `config/staging.conf` and set
|
|
277
349
|
`CONFIG_ENV=staging`. A missing `{ENV}.conf` is a boot-time error — typos
|
|
278
350
|
fail fast rather than silently falling back to defaults.
|
|
279
351
|
|
|
352
|
+
### Adapters
|
|
353
|
+
|
|
354
|
+
Which adapter fills each slot is the composition root's own choice, its own
|
|
355
|
+
section `adapters`, read before any module is chosen (above). Each key has its
|
|
356
|
+
variable; a value the template does not know, or a key it does not declare,
|
|
357
|
+
fails before boot, naming it.
|
|
358
|
+
|
|
359
|
+
| Variable | Default | Description |
|
|
360
|
+
|---|---|---|
|
|
361
|
+
| `ADAPTERS_RATE_LIMITER` | `memory` | `adapters.rateLimiter`: `memory` or `redis`. See [Multi-replica deployments](#multi-replica-deployments) |
|
|
362
|
+
| `ADAPTERS_USER_SESSION_STORES` | `memory` | `adapters.userSessionStores`: the user-session stores, `memory` or `redis`. Keep it with `SESSION_STORE_STORAGE_TYPE` (see [Docker](#docker)) |
|
|
363
|
+
| `ADAPTERS_ACCESS_TOKEN_DENYLIST` | `redis` | `adapters.accessTokenDenylist`: `memory` or `redis` |
|
|
364
|
+
| `ADAPTERS_REPLAY_SEEN_SET` | `redis` | `adapters.replaySeenSet`: the replay seen-set behind `private_key_jwt`, `memory` or `redis` |
|
|
365
|
+
| `ADAPTERS_CONSENT_STORE` | `none` | `adapters.consentStore`: `none`, `memory` or `redis`. See [Consent Store](#consent-store) |
|
|
366
|
+
| `ADAPTERS_FEDERATION_TOKEN_STORE` | `memory` | `adapters.federationTokenStore`: `memory` or `redis`. See [Federation Token Store](#federation-token-store) |
|
|
367
|
+
| `ADAPTERS_FEDERATION_GRANT_STORE` | `none` | `adapters.federationGrantStore`: `none`, `memory` or `redis`. See [Federation Grants](#federation-grants) |
|
|
368
|
+
| `ADAPTERS_FEDERATION_GRANT_INTENT_STORE` | `none` | `adapters.federationGrantIntentStore`: `none`, `memory` or `redis`. See [Federation Grants](#federation-grants) |
|
|
369
|
+
| `ADAPTERS_MFA_FACTOR_STORE` | `memory` | `adapters.mfaFactorStore`: `memory` (development and test only), `redis` or `store` (the Store's endpoints), read while `MFA_MODE` installs MFA. See [Multi-factor authentication](#multi-factor-authentication) |
|
|
370
|
+
| `ADAPTERS_MFA_TRANSACTION_STORE` | `memory` | `adapters.mfaTransactionStore`: `memory` (development and test only) or `redis`, read while `MFA_MODE` installs MFA |
|
|
371
|
+
| `ADAPTERS_CODE_REPOSITORY` | `redis` | `adapters.codeRepository`: the authorization-code repository, `memory` or `redis`. See [Code Repository](#code-repository) |
|
|
372
|
+
| `ADAPTERS_CLIENT_REPOSITORY` | `yaml` | `adapters.clientRepository`: `yaml`, or `static` (core's alias of `yaml`). See [Client Repository](#client-repository) |
|
|
373
|
+
| `ADAPTERS_USER_REPOSITORY` | `http` | `adapters.userRepository`: `http`, `yaml` or `static` (core's alias of `yaml`). See [User Repository](#user-repository) |
|
|
374
|
+
| `ADAPTERS_AUDIT_SINK` | `logger` | `adapters.auditSink`: where security events go, `logger` (pino-enveloped NDJSON on stdout) or `console` (bare event JSON). There is no `none`. See [Audit trail](#audit-trail) |
|
|
375
|
+
|
|
376
|
+
A selection still written where it was — `rateLimiter.adapter`,
|
|
377
|
+
`oauth.code.adapter`, `audit.sink.type`, `repositories.user.type` and the
|
|
378
|
+
like — or a variable renamed with it (`RATE_LIMITER_ADAPTER`, `CLIENT_TYPE`,
|
|
379
|
+
…) set alone or to a different value, fails before boot, naming the new path
|
|
380
|
+
and variable; the old variable beside the new one at the same value is
|
|
381
|
+
accepted.
|
|
382
|
+
|
|
280
383
|
### HTTP
|
|
281
384
|
|
|
282
385
|
| Variable | Default | Description |
|
|
283
386
|
|---|---|---|
|
|
284
|
-
| `HTTP_PORT` | `3000` | Port the server listens on |
|
|
387
|
+
| `HTTP_PORT` | `3000` | Port the server listens on, `0` to `65535` in decimal digits; `0` lets the OS choose a free one. Set but empty, it fails boot |
|
|
285
388
|
| `HTTP_TRUST_PROXY` | `false` | Express `trust proxy`: `false`, an address/CIDR list (`10.0.0.0/8,loopback`), a hop count (`1`), or `true`. **Required behind a load balancer** — otherwise every IP-keyed rate limit shares one bucket across all users. Prefer naming the proxy over `true`. See [Multi-replica deployments](#multi-replica-deployments) |
|
|
286
389
|
| `HTTP_READINESS_TIMEOUT_MS` | `1000` | Per-probe deadline for `/readyz` (see [Health endpoints](#health-endpoints)) |
|
|
287
|
-
| `
|
|
288
|
-
| `AUDIT_SINK_TYPE` | `logger` | Where security events go: `logger` (pino-enveloped NDJSON on stdout) or `console` (bare event JSON). There is no `none`. See [Audit trail](#audit-trail) |
|
|
390
|
+
| `LOGGING_LEVEL` | `info` | Minimum level emitted: `trace`\|`debug`\|`info`\|`warn`\|`error`\|`fatal`\|`silent`. Does **not** gate the audit trail — see [Audit trail](#audit-trail) |
|
|
289
391
|
|
|
290
392
|
### OAuth JWT
|
|
291
393
|
|
|
394
|
+
The signing key is the `key-store` module's section: `key-store.provider`
|
|
395
|
+
(`KEY_STORE_PROVIDER`, `local`) and the local key store's `key-store.local`
|
|
396
|
+
(`KEY_STORE_LOCAL_*`). The issuer and the token format stay under `oauth.jwt`.
|
|
397
|
+
|
|
292
398
|
| Variable | Default | Description |
|
|
293
399
|
|---|---|---|
|
|
294
|
-
| `
|
|
295
|
-
| `
|
|
400
|
+
| `KEY_STORE_LOCAL_ALGORITHM` | `EdDSA` | JWT signing algorithm: `EdDSA`, `ES256`, `RS256` or `HS256`. The default is asymmetric so `/.well-known/jwks.json` publishes a real verification key. |
|
|
401
|
+
| `KEY_STORE_LOCAL_SECRET` | — | Signing secret, **HMAC (`HS256`) only**. At least 32 bytes (256 bits) of random material — `openssl rand -hex 32`. Hex/base64 values are measured **decoded**, so a 32-character hex string counts as 16 bytes and is refused. |
|
|
296
402
|
| `OAUTH_JWT_ISSUER` | **(required)** | Canonical issuer URL stamped as `iss` on every token. Must be absolute `https` (`http` only for a loopback host), with no query or fragment. Boot fails when unset — it is never derived from the `Host` header. |
|
|
297
403
|
| `OAUTH_REQUIRE_EMAIL_VERIFIED` | `false` | Refuse to issue tokens for a user until the Store publishes `emailVerified: true`. Enforced at `/authorize` and on the `session` grant. Verification itself is the Store's job — this only reads the result. |
|
|
298
|
-
| `
|
|
299
|
-
| `
|
|
300
|
-
| `
|
|
301
|
-
| `
|
|
302
|
-
| `
|
|
303
|
-
| `
|
|
304
|
-
| `
|
|
305
|
-
| `
|
|
306
|
-
| `
|
|
307
|
-
| `
|
|
308
|
-
| `
|
|
309
|
-
| `
|
|
310
|
-
| `
|
|
311
|
-
| `
|
|
312
|
-
| `
|
|
313
|
-
| `
|
|
314
|
-
| `
|
|
404
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_ENABLED` | `false` | Accept Client ID Metadata Documents (#529): a client whose `client_id` is the `https` URL of its own registration, the model MCP hosts use. Such a client is public, never first-party — it goes through the consent step, so wire `ADAPTERS_CONSENT_STORE`. |
|
|
405
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_ALLOWED_SCOPES` | — | Comma-separated: what any such client may obtain (its document's `scope` is intersected with this). Empty admits none. |
|
|
406
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_ALLOWED_AUDIENCES` | — | Comma-separated: the resource servers it may mint for (RFC 8707 `resource`). Empty admits only its own `client_id`. |
|
|
407
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_ALLOWED_HOSTS` | — | Comma-separated hosts a document may live on: exact, or `.suffix` for a domain and its subdomains. Empty admits any public host. |
|
|
408
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_DENIED_HOSTS` | — | Comma-separated hosts refused even when allowed above. |
|
|
409
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_MAX_BYTES` | `5120` | Byte cap on a document (the draft recommends 5 KB). |
|
|
410
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_TIMEOUT_MS` | `5000` | Fetch timeout. |
|
|
411
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_CACHE_MAX_AGE_MS` | `600000` | Upper bound on how long a valid document is served from cache; `Cache-Control: max-age` may shorten it. |
|
|
412
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_MAX_CACHE_ENTRIES` | `256` | How many documents are remembered at once. The keys are chosen by an unauthenticated caller, so the map is bounded. |
|
|
413
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_STALE_IF_ERROR_MS` | `300000` | How long a registration already validated is still served after a revalidation that failed for a reason that is not the document's (a DNS blip, a 5xx, a timeout) — an outage should not break a working client. A document that was *rejected* is dropped immediately. `0` disables it. |
|
|
414
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_NEGATIVE_CACHE_MS` | `60000` | How long a refusal is remembered, so the same `client_id` is not resolved and fetched again on every request. Short, so a client that fixes its document is not locked out. |
|
|
415
|
+
| `OAUTH_CLIENT_ID_METADATA_DOCUMENTS_MAX_CONCURRENT_FETCHES` | `8` | How many documents may be in flight at once, across every `client_id`. Bounds what an unauthenticated caller can make this server dial. |
|
|
416
|
+
| `KEY_STORE_LOCAL_KID` | `v0` | Key ID included in the JWT header. 1 to 256 characters with no control character; anything else fails boot, including a variable exported but empty (which used to sign under the kid `""`; tokens issued that way are refused once it is corrected, so their users sign in again) |
|
|
417
|
+
| `KEY_STORE_LOCAL_PRIVATE_KEY` | — | PEM-encoded private key (asymmetric algorithms) |
|
|
418
|
+
| `KEY_STORE_LOCAL_PRIVATE_KEY_PATH` | — | Path to PEM private key file |
|
|
419
|
+
| `KEY_STORE_LOCAL_PUBLIC_KEY` | — | PEM-encoded public key |
|
|
420
|
+
| `KEY_STORE_LOCAL_PUBLIC_KEY_PATH` | — | Path to PEM public key file |
|
|
315
421
|
| `OAUTH_JWT_LEGACY_TYP_ACCEPT` | `false` | Accept tokens whose `typ` header is absent. `false` rejects them, treating a typ-less token as the misconfiguration or downgrade attempt it usually is. Set `true` only for a bounded migration window while v0.4.x tokens are still in circulation. |
|
|
422
|
+
| `JWKS_PATH` | `/.well-known/jwks.json` | Where the verification keys are published under the issuer, and what discovery advertises as `jwks_uri` (`jwks.path`). An absolute path with no `//`, dot-segment, query, fragment, backslash, percent-encoding or control character. |
|
|
423
|
+
| `JWKS_CACHE_MAX_AGE` | `300` | The JWKS response's `Cache-Control: public, max-age`, in seconds (`jwks.cacheMaxAge`). Keep it well below the key-overlap window, so a rotated key reaches caching verifiers in time. |
|
|
316
424
|
|
|
317
425
|
**Signing keys are required.** The default algorithm is `EdDSA` and there is no
|
|
318
426
|
key-material default: a deployment that sets none fails at boot naming the keys
|
|
@@ -324,11 +432,11 @@ openssl genpkey -algorithm ed25519 -out jwt-private.pem
|
|
|
324
432
|
openssl pkey -in jwt-private.pem -pubout -out jwt-public.pem
|
|
325
433
|
```
|
|
326
434
|
|
|
327
|
-
then point `
|
|
328
|
-
(or inline the PEMs via `
|
|
435
|
+
then point `KEY_STORE_LOCAL_PRIVATE_KEY_PATH` / `KEY_STORE_LOCAL_PUBLIC_KEY_PATH` at them
|
|
436
|
+
(or inline the PEMs via `KEY_STORE_LOCAL_PRIVATE_KEY` / `KEY_STORE_LOCAL_PUBLIC_KEY`).
|
|
329
437
|
|
|
330
|
-
`HS256` is still selectable (`
|
|
331
|
-
`
|
|
438
|
+
`HS256` is still selectable (`KEY_STORE_LOCAL_ALGORITHM=HS256` plus a ≥32-byte
|
|
439
|
+
`KEY_STORE_LOCAL_SECRET`), but understand what it costs: a symmetric key has no
|
|
332
440
|
public half, so `/.well-known/jwks.json` answers `404 jwks_not_published` and
|
|
333
441
|
every relying party must be handed the shared secret — which also lets it
|
|
334
442
|
**mint** tokens, not merely verify them.
|
|
@@ -342,9 +450,9 @@ every relying party must be handed the shared secret — which also lets it
|
|
|
342
450
|
| `OAUTH_ACCESS_TOKEN_EXPIRES_IN` | — | **Deprecated** alias of `OAUTH_ACCESS_TOKEN_DEFAULT_EXPIRES_IN` (config key `oauth.accessToken.expiresIn`, of `oauth.accessToken.defaultExpiresIn`), read only while the new one is unset; while it still decides the default, boot logs `config_key_deprecated` (warn). Move the value to the new variable. |
|
|
343
451
|
| `OAUTH_REFRESH_TOKEN_EXPIRES_IN` | `86400` | Refresh token lifetime in seconds. Whole positive number, at most one year (`31536000`). |
|
|
344
452
|
|
|
345
|
-
|
|
346
|
-
HOCON resolves `FOO=` to `""
|
|
347
|
-
|
|
453
|
+
Each is read only as decimal digits. Exporting one as an empty string is a
|
|
454
|
+
boot failure, not a fallback (HOCON resolves `FOO=` to `""`), and so is a hex
|
|
455
|
+
(`0x10`), exponent (`1e3`), sign (`+5`) or fraction (`5.0`).
|
|
348
456
|
|
|
349
457
|
Only token exchange (RFC 8693) reads an `expires_in` request parameter; every
|
|
350
458
|
other grant ignores it and mints the default.
|
|
@@ -353,29 +461,48 @@ other grant ignores it and mints the default.
|
|
|
353
461
|
|
|
354
462
|
| Variable | Default | Description |
|
|
355
463
|
|---|---|---|
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
464
|
+
| `OAUTH_SESSION_ENABLED` | `true` | Enable the session grant type |
|
|
465
|
+
| `OAUTH_AUTHORIZATION_GRANTS_AUTHORIZATION_CODE_ENABLED` | `true` | Enable the authorization code grant type |
|
|
466
|
+
| `OAUTH_AUTHORIZATION_GRANTS_REFRESH_TOKEN_ENABLED` | `true` | Enable the refresh token grant type |
|
|
467
|
+
| `OAUTH_AUTHORIZATION_GRANTS_CLIENT_CREDENTIALS_ENABLED` | `false` | Enable the client credentials grant type |
|
|
468
|
+
| `OAUTH_AUTHORIZATION_GRANTS_JWT_BEARER_ENABLED` | `false` | Enable the jwt-bearer grant type (RFC 7523) |
|
|
469
|
+
|
|
470
|
+
Each switch is its module's key — `oauth-session.enabled`, and
|
|
471
|
+
`oauth-authorization.grants.<grant>.enabled` for the others — which the
|
|
472
|
+
template reads before boot, from its own files and the environment, to choose
|
|
473
|
+
the modules. `OAUTH_GRANTS_<GRANT>_ENABLED`, the old names, refuse boot set
|
|
474
|
+
alone or beside the new name at a different value; beside it at the same value,
|
|
475
|
+
they boot.
|
|
359
476
|
|
|
360
477
|
### Session
|
|
361
478
|
|
|
362
479
|
| Variable | Default | Description |
|
|
363
480
|
|---|---|---|
|
|
364
|
-
| `
|
|
365
|
-
| `
|
|
366
|
-
| `
|
|
367
|
-
| `
|
|
368
|
-
| `
|
|
369
|
-
| `
|
|
370
|
-
| `SESSION_CSRF_TTL_SECONDS` | `7200` | Lifetime of an issued CSRF token, in seconds.
|
|
371
|
-
| `
|
|
372
|
-
| `
|
|
373
|
-
| `
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
`
|
|
378
|
-
|
|
481
|
+
| `SESSION_STORE_SECRET` | — | **Required.** Signs the cookie that *is* the authenticated session, so guessing it forges logins. At least 32 bytes (256 bits) — `openssl rand -hex 32`. Measured **decoded**, same rule as `KEY_STORE_LOCAL_SECRET`. |
|
|
482
|
+
| `SESSION_STORE_NAME` | `__Host-auth.session` | Session cookie name. The default uses the `__Host-` prefix and therefore requires `SESSION_STORE_SECURE=true` and no `SESSION_STORE_DOMAIN`. |
|
|
483
|
+
| `SESSION_STORE_MAX_AGE` | `3600000` | Session cookie max age in milliseconds. Whole positive number, at most one year (`31536000000`). |
|
|
484
|
+
| `SESSION_STORE_SECURE` | `true` | Set `Secure` flag on session cookie |
|
|
485
|
+
| `SESSION_STORE_SAME_SITE` | `lax` | `SameSite` attribute (`lax`, `strict`, `none`). `none` **requires** `SESSION_STORE_SECURE=true` — browsers drop a `SameSite=None` cookie that is not `Secure`, so boot refuses the combination rather than letting every login fail silently in the client. |
|
|
486
|
+
| `SESSION_STORE_DOMAIN` | — | Cookie domain (unset by default) |
|
|
487
|
+
| `SESSION_CSRF_TTL_SECONDS` | `7200` | Lifetime of an issued CSRF token, in seconds. Whole number in decimal digits, 1–86400; boot fails otherwise, an *empty* or blank value included. |
|
|
488
|
+
| `SESSION_STORE_STORAGE_TYPE` | `redis` | Session store backend: `redis` or `memory`. `memory` is per process and is refused under `CORE_DEPLOYMENT_MODE=multi` like the other in-memory stores (#474) |
|
|
489
|
+
| `SESSION_STORE_STORAGE_REDIS_URL` | `redis://localhost:6379` | Redis connection URL for session storage |
|
|
490
|
+
| `SESSION_STORE_STORAGE_REDIS_PASSWORD` | — | Redis password for session storage |
|
|
491
|
+
|
|
492
|
+
The cookie and its store are the session store's section, `session-store`; the
|
|
493
|
+
CSRF token's lifetime, the login page and the login's budget are the session
|
|
494
|
+
module's, `session`. `SESSION_<KEY>`, the old names of the `SESSION_STORE_*`
|
|
495
|
+
variables, refuse boot set alone or beside the new name at a different value;
|
|
496
|
+
beside it at the same value, they boot.
|
|
497
|
+
|
|
498
|
+
If you set `SESSION_STORE_SECURE=false` for local HTTP development or set `SESSION_STORE_DOMAIN`
|
|
499
|
+
for shared-domain cookies, also set `SESSION_STORE_NAME` to a non-`__Host-` value such as
|
|
500
|
+
`auth.sid` — with `SESSION_STORE_SECURE=false`, one with no prefix: a `__Secure-` name
|
|
501
|
+
needs `SESSION_STORE_SECURE=true` too. The server fails fast when a `__Host-` or
|
|
502
|
+
`__Secure-` cookie name is combined with attributes that browsers reject for that
|
|
503
|
+
prefix (in any case), on a `SESSION_STORE_NAME` that is not a cookie name (an RFC 6265
|
|
504
|
+
token: no space, `;` or other separator), and on a `SESSION_STORE_DOMAIN` that is not a
|
|
505
|
+
host name (a scheme, a port or a path).
|
|
379
506
|
|
|
380
507
|
#### CSRF on `/session/login` and `/session/logout`
|
|
381
508
|
|
|
@@ -383,7 +510,7 @@ Both routes accept a request carrying **either** a same-origin (or trusted)
|
|
|
383
510
|
`Origin` / `Referer`, **or** a valid double-submit CSRF token, and reject one
|
|
384
511
|
carrying neither (#272). Browsers satisfy this automatically; a scripted client
|
|
385
512
|
calls `GET /session/csrf` first and sends the returned `csrf_token` back as
|
|
386
|
-
both the `<
|
|
513
|
+
both the `<SESSION_STORE_NAME>.csrf` cookie and an `x-csrf-token` header (or a
|
|
387
514
|
`csrf_token` form field).
|
|
388
515
|
|
|
389
516
|
Two configuration notes:
|
|
@@ -394,19 +521,21 @@ Two configuration notes:
|
|
|
394
521
|
request.
|
|
395
522
|
- If your login UI is served from a **different origin** than the provider,
|
|
396
523
|
list that origin under `session.csrf.trustedOrigins` in your HOCON config.
|
|
397
|
-
|
|
524
|
+
A listed origin can also answer federation-grant consents and device
|
|
525
|
+
verification, so a client's origin is never listed (the federation-grants
|
|
526
|
+
ADR's D7). `http.cors.allowedOrigins` does not confer CSRF trust — see
|
|
398
527
|
[CORS](#cors) for what it does confer.
|
|
399
528
|
|
|
400
529
|
### CORS
|
|
401
530
|
|
|
402
531
|
| Variable | Default | Description |
|
|
403
532
|
|---|---|---|
|
|
404
|
-
| `
|
|
533
|
+
| `HTTP_CORS_ALLOWED_ORIGINS` | *(empty — CORS off)* | Comma-separated list of browser origins allowed to read the token, userinfo, revocation and discovery/JWKS responses |
|
|
405
534
|
|
|
406
535
|
A browser app served from a different origin than this provider — an SPA on
|
|
407
536
|
`https://app.example.com` against a provider on `https://auth.example.com` —
|
|
408
537
|
cannot call the token endpoint at all unless that origin is on
|
|
409
|
-
`cors.allowedOrigins`. Set it and the provider answers preflights and stamps
|
|
538
|
+
`http.cors.allowedOrigins`. Set it and the provider answers preflights and stamps
|
|
410
539
|
`Access-Control-Allow-Origin` on the five endpoints a browser has a legitimate
|
|
411
540
|
reason to call cross-origin:
|
|
412
541
|
|
|
@@ -416,7 +545,7 @@ reason to call cross-origin:
|
|
|
416
545
|
| `/oauth/userinfo` | `GET`, `POST` | OIDC Core §5.3 defines both |
|
|
417
546
|
| `/oauth/revoke` | `POST` | RFC 7009 §2.1 — a public client revoking its own tokens on sign-out |
|
|
418
547
|
| `/.well-known/openid-configuration` | `GET` | Discovery, fetched by browser client libraries |
|
|
419
|
-
| `/.well-known/jwks.json` | `GET` | Same; follows `
|
|
548
|
+
| `/.well-known/jwks.json` | `GET` | Same; follows `jwks.path` when you override it |
|
|
420
549
|
|
|
421
550
|
`/oauth/introspect` and `/oauth/authorize` are deliberately **not** included.
|
|
422
551
|
Introspection is server-to-server and already refuses public clients, so no
|
|
@@ -424,12 +553,21 @@ browser could use it; `/authorize` is a top-level navigation rather than a
|
|
|
424
553
|
`fetch`, and CORS has no say over where a browser may navigate.
|
|
425
554
|
|
|
426
555
|
```hocon
|
|
427
|
-
cors {
|
|
556
|
+
http.cors {
|
|
428
557
|
allowedOrigins = ["https://app.example.com", "http://localhost:5173"]
|
|
429
558
|
}
|
|
430
559
|
```
|
|
431
560
|
|
|
432
|
-
or `
|
|
561
|
+
or `HTTP_CORS_ALLOWED_ORIGINS=https://app.example.com,http://localhost:5173`.
|
|
562
|
+
Those are the two spellings; a value that is neither — a number, an
|
|
563
|
+
object, a boolean, which only a configuration file can write — fails boot
|
|
564
|
+
naming `http.cors.allowedOrigins` rather than reading as no origins.
|
|
565
|
+
|
|
566
|
+
The list is part of the `http` module's section, with its default in
|
|
567
|
+
`config/reference.conf`. The `http` module hands it to core's CORS middleware
|
|
568
|
+
in the `httpSettings` slot, beside the trusted hops, and core reads the slot,
|
|
569
|
+
not the configuration: a composition with no `httpSettings` provider mounts
|
|
570
|
+
no CORS.
|
|
433
571
|
|
|
434
572
|
**Matching is exact string equality against the `Origin` header**, and every
|
|
435
573
|
shape that could not match fails at boot naming its index rather than sitting
|
|
@@ -455,17 +593,25 @@ all — no headers, no `Vary`, nothing changed.
|
|
|
455
593
|
|
|
456
594
|
### Google Federation
|
|
457
595
|
|
|
596
|
+
The federations are core's: `core.federations`, one map keyed by the name
|
|
597
|
+
each is reached at (`/session/oauth/federation/<name>`). A key of one is bound
|
|
598
|
+
to the variable named after its path, `CORE_FEDERATIONS_<NAME>_<KEY>`. The map
|
|
599
|
+
written at the top level (`federations { ... }`) refuses boot, naming each
|
|
600
|
+
key's path under `core.federations`; a `FEDERATIONS_GOOGLE_*` or
|
|
601
|
+
`FEDERATIONS_OIDC_*` variable set alone, or beside its new name at a different
|
|
602
|
+
value, is refused before any module is chosen.
|
|
603
|
+
|
|
458
604
|
| Variable | Default | Description |
|
|
459
605
|
|---|---|---|
|
|
460
|
-
| `
|
|
461
|
-
| `
|
|
462
|
-
| `
|
|
463
|
-
| `
|
|
464
|
-
| `
|
|
606
|
+
| `CORE_FEDERATIONS_GOOGLE_ENABLED` | `false` | Enable Google OAuth federation |
|
|
607
|
+
| `CORE_FEDERATIONS_GOOGLE_CLIENT_ID` | — | Google OAuth client ID |
|
|
608
|
+
| `CORE_FEDERATIONS_GOOGLE_CLIENT_SECRET` | — | Google OAuth client secret |
|
|
609
|
+
| `CORE_FEDERATIONS_GOOGLE_CALLBACK_URL` | `http://localhost:3000/session/oauth/federation/google/callback` | Google OAuth callback URL |
|
|
610
|
+
| `CORE_FEDERATIONS_GOOGLE_ACCESS_TYPE` | unset (`offline`) | `offline`: every sign-in shows Google's consent screen and every session gets a refresh token. `online`: consent on the first sign-in only, and no refresh token at all. See [federation-google](../../packages/federation-google/README.md#refresh-tokens-and-the-consent-screen) |
|
|
465
611
|
|
|
466
612
|
### OIDC Federation (any OpenID Connect provider)
|
|
467
613
|
|
|
468
|
-
One instance ships in `config/application.conf` under `federations.oidc`
|
|
614
|
+
One instance ships in `config/application.conf` under `core.federations.oidc`
|
|
469
615
|
(`@o3co/auth-provider-federation-oidc`, #524): Okta, Entra ID, Auth0, Keycloak
|
|
470
616
|
or your own tenant, selected by issuer. Discovery runs at boot and a failure
|
|
471
617
|
refuses boot. The identity handed to the Store is `oidc:<sub>`; an identity
|
|
@@ -473,16 +619,16 @@ the Store does not know is refused with 401 — nothing is provisioned.
|
|
|
473
619
|
|
|
474
620
|
| Variable | Default | Description |
|
|
475
621
|
|---|---|---|
|
|
476
|
-
| `
|
|
477
|
-
| `
|
|
478
|
-
| `
|
|
479
|
-
| `
|
|
480
|
-
| `
|
|
622
|
+
| `CORE_FEDERATIONS_OIDC_ENABLED` | `false` | Enable the OIDC federation |
|
|
623
|
+
| `CORE_FEDERATIONS_OIDC_ISSUER` | — | Issuer identifier (https), exactly as the IdP writes `iss` |
|
|
624
|
+
| `CORE_FEDERATIONS_OIDC_CLIENT_ID` | — | Client ID registered at the IdP |
|
|
625
|
+
| `CORE_FEDERATIONS_OIDC_CLIENT_SECRET` | — | Client secret (`client_secret_basic`); set `privateKey` in the config file for `private_key_jwt` instead |
|
|
626
|
+
| `CORE_FEDERATIONS_OIDC_CALLBACK_URL` | `http://localhost:3000/session/oauth/federation/oidc/callback` | Where the IdP sends the browser back |
|
|
481
627
|
|
|
482
628
|
A second IdP is another section with `type = "oidc"` and its own callback:
|
|
483
629
|
|
|
484
630
|
```hocon
|
|
485
|
-
federations {
|
|
631
|
+
core.federations {
|
|
486
632
|
okta {
|
|
487
633
|
enabled = true
|
|
488
634
|
type = "oidc"
|
|
@@ -495,7 +641,7 @@ federations {
|
|
|
495
641
|
}
|
|
496
642
|
```
|
|
497
643
|
|
|
498
|
-
The
|
|
644
|
+
The entry's `type` names the implementation. `core.federations.google` without a
|
|
499
645
|
`type` is the built-in Google federation; with `type = "oidc"` it is a generic
|
|
500
646
|
OIDC instance named `google`, and the built-in module is not composed.
|
|
501
647
|
|
|
@@ -507,21 +653,27 @@ is documented in [its README](../../packages/federation-oidc/README.md).
|
|
|
507
653
|
|
|
508
654
|
| Variable | Default | Description |
|
|
509
655
|
|---|---|---|
|
|
510
|
-
| `
|
|
511
|
-
| `
|
|
656
|
+
| `ADAPTERS_CLIENT_REPOSITORY` | `yaml` | Client store backend: `yaml`, or `static`, core's alias of `yaml`, which reads `repositories.client.static.path` (no default) |
|
|
657
|
+
| `REPOSITORIES_CLIENT_YAML_PATH` | `./config/clients.yaml` | Path to the YAML client registry |
|
|
658
|
+
|
|
659
|
+
The registry is per-deployment configuration: `.gitignore` keeps
|
|
660
|
+
`config/clients.yaml` out of git and `.dockerignore` keeps it out of the image,
|
|
661
|
+
and the production compose file mounts it (see [Docker](#docker)).
|
|
512
662
|
|
|
513
663
|
### User Repository
|
|
514
664
|
|
|
515
665
|
| Variable | Default | Description |
|
|
516
666
|
|---|---|---|
|
|
517
|
-
| `
|
|
518
|
-
| `
|
|
519
|
-
| `
|
|
520
|
-
| `
|
|
521
|
-
| `
|
|
522
|
-
| `
|
|
523
|
-
| `
|
|
524
|
-
| `
|
|
667
|
+
| `ADAPTERS_USER_REPOSITORY` | `http` | User repository backend: `http`, or `yaml` for local work (`static`, core's alias of `yaml`, reads `repositories.user.static.path`, with no default) |
|
|
668
|
+
| `REPOSITORIES_USER_YAML_PATH` | `./config/users.yaml` | The YAML user file the `yaml` backend reads |
|
|
669
|
+
| `REPOSITORIES_USER_HTTP_AUTHENTICATE_URL` | — | URL for password-based user authentication. **https required** (see below) |
|
|
670
|
+
| `REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL` | — | URL for token-based user authentication. **https required** (see below) |
|
|
671
|
+
| `REPOSITORIES_USER_HTTP_LINK_FEDERATED_IDENTITY_URL` | — | Optional. URL the Store links a federated identity at (#482); enables `?link=1` on the federation start route. **https required** |
|
|
672
|
+
| `REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL` | — | Optional. URL the Store answers who holds an upstream identity at (#613, federation grants' check 5). With it, declare what the Store covers in `repositories.user.http.federatedIdentityLookupCoverage` (HOCON). **https required** |
|
|
673
|
+
| `REPOSITORIES_USER_HTTP_MARK_MFA_ENROLLED_URL` | — | Optional. URL the Store keeps the MFA enrollment witness at (the MFA ADR's D12): with it, a lost factor store cannot open a first binding. The Store must then answer `mfaEnrolled` on both authenticate URLs. Unset, a boot with MFA on warns (`mfa_enrollment_witness_unwritable`). **https required** |
|
|
674
|
+
| `REPOSITORIES_USER_HTTP_BEARER_TOKEN` | — | Optional. The credential this server presents to the Store: every Store request carries `Authorization: Bearer <token>`. A bare token (no `Bearer ` prefix) of at least 32 bytes — `openssl rand -hex 32`. Unset, no `Authorization` header is sent (see below) |
|
|
675
|
+
| `REPOSITORIES_USER_HTTP_TIMEOUT` | `5000` | HTTP request timeout in milliseconds. Positive integer ≤ `2147483647` |
|
|
676
|
+
| `REPOSITORIES_USER_HTTP_MAX_RESPONSE_BYTES` | `1048576` | Largest upstream response body accepted, in bytes |
|
|
525
677
|
|
|
526
678
|
Both user-authentication URLs carry **plaintext user credentials** to the
|
|
527
679
|
upstream store, so both must be absolute `https://` URLs. `http://` is accepted
|
|
@@ -539,13 +691,13 @@ follows a `3xx`, so a URL that redirects fails every call — see
|
|
|
539
691
|
**Who may call the Store.** What the token-based login and account linking
|
|
540
692
|
send is an identifier, not a secret, so a Store that answers any caller
|
|
541
693
|
resolves a known identity to its user — or links one to any account — for
|
|
542
|
-
anyone who can reach it. Set `
|
|
694
|
+
anyone who can reach it. Set `REPOSITORIES_USER_HTTP_BEARER_TOKEN` and have the Store
|
|
543
695
|
answer every request whose `Authorization` is not exactly `Bearer <that token>`
|
|
544
696
|
with `401` and `WWW-Authenticate: Bearer error="invalid_token"` (or `403` and
|
|
545
697
|
`error="insufficient_scope"`). The one token goes to every Store URL above, so
|
|
546
|
-
those endpoints must be one trust domain. With `
|
|
698
|
+
those endpoints must be one trust domain. With `ADAPTERS_USER_REPOSITORY=http` — this
|
|
547
699
|
template's default — boot fails if the token is weaker than 32 bytes
|
|
548
|
-
(measured like `
|
|
700
|
+
(measured like `SESSION_STORE_SECRET`), malformed, or exported but empty; it appears
|
|
549
701
|
in no error this server throws. With that challenge, a token the Store does not
|
|
550
702
|
accept is an outage on every Store call: logins answer
|
|
551
703
|
`503 temporarily_unavailable` and log an error naming the refused credential,
|
|
@@ -565,29 +717,38 @@ what the Store checks are in the same foundation README section.
|
|
|
565
717
|
|
|
566
718
|
### Code Repository
|
|
567
719
|
|
|
720
|
+
`adapters.codeRepository` (`ADAPTERS_CODE_REPOSITORY`) chooses the
|
|
721
|
+
repository; each reads its own section. The Redis one runs on the shared
|
|
722
|
+
connection `REDIS_CLIENTS_URL` configures, so it takes no URL or password of
|
|
723
|
+
its own.
|
|
724
|
+
|
|
568
725
|
| Variable | Default | Description |
|
|
569
726
|
|---|---|---|
|
|
570
|
-
| `
|
|
571
|
-
| `
|
|
572
|
-
| `
|
|
573
|
-
|
|
727
|
+
| `REDIS_CODE_REPOSITORY_DEFAULT_EXPIRES_IN` | `600` | `redis-code-repository.defaultExpiresIn`: the Redis repository's default authorization-code lifetime, in seconds |
|
|
728
|
+
| `REDIS_CODE_REPOSITORY_KEY_PREFIX` | `oauth:code:` | `redis-code-repository.keyPrefix`: the Redis repository's key namespace (see [Redis Namespacing](#redis-namespacing)) |
|
|
729
|
+
| `STANDALONE_IN_MEMORY_CODE_REPOSITORY_DEFAULT_EXPIRES_IN` | `600` | `standalone-in-memory-code-repository.defaultExpiresIn`: the in-process repository's, a positive whole number of seconds |
|
|
730
|
+
|
|
731
|
+
`CLIENT_CODE_DEFAULT_EXPIRES_IN` and `CLIENT_CODE_KEY_PREFIX` were renamed
|
|
732
|
+
with them, and `CLIENT_CODE_ENDPOINT_URI` and `CLIENT_CODE_PASSWORD` removed. A
|
|
733
|
+
renamed one set alone, or beside its new name at a different value, and a
|
|
734
|
+
removed one set at all, fails boot naming what to set instead.
|
|
574
735
|
|
|
575
736
|
### Federation Token Store
|
|
576
737
|
|
|
577
738
|
The upstream IdP tokens (a Google refresh token, say) held on behalf of a
|
|
578
739
|
session. Memory by default, which forks per replica and is refused under
|
|
579
|
-
`
|
|
580
|
-
`
|
|
740
|
+
`CORE_DEPLOYMENT_MODE=multi`; the Redis store shares the socket configured by
|
|
741
|
+
`REDIS_CLIENTS_URL` and encrypts records at rest, so it
|
|
581
742
|
needs a key.
|
|
582
743
|
|
|
583
744
|
| Variable | Default | Description |
|
|
584
745
|
|---|---|---|
|
|
585
|
-
| `
|
|
746
|
+
| `ADAPTERS_FEDERATION_TOKEN_STORE` | `memory` | Federation token store backend: `memory` or `redis` |
|
|
586
747
|
| `REDIS_FEDERATION_TOKEN_STORE_ENCRYPTION_KEY` | — | AES-256-GCM key for records at rest: 32 bytes, base64-encoded (`openssl rand -base64 32`). **Required** with `redis` unless the mode below is `allow-plaintext` |
|
|
587
|
-
| `REDIS_FEDERATION_TOKEN_STORE_ENCRYPTION_MODE` | `required` | `required` or `allow-plaintext`. Plaintext is refused when the config was selected by a production/staging environment (`CONFIG_ENV` or `NODE_ENV`) and under `
|
|
748
|
+
| `REDIS_FEDERATION_TOKEN_STORE_ENCRYPTION_MODE` | `required` | `required` or `allow-plaintext`. Plaintext is refused when the config was selected by a production/staging environment (`CONFIG_ENV` or `NODE_ENV`) and under `CORE_DEPLOYMENT_MODE=multi` in any environment, unless `FEDERATION_TOKENS_ALLOW_INSECURE=1` is also set — development only |
|
|
588
749
|
|
|
589
750
|
`ttl` (seconds; keep it above the upstream refresh-token lifetime) and the #291
|
|
590
|
-
`scanFallback` migration flag live under `
|
|
751
|
+
`scanFallback` migration flag live under `redis-federation-token-store` in a
|
|
591
752
|
config layer rather than behind an environment variable.
|
|
592
753
|
|
|
593
754
|
### Consent Store
|
|
@@ -596,12 +757,87 @@ Where an end-user's consent to a client that is not first-party is recorded,
|
|
|
596
757
|
together with the `/authorize` request parked while the consent page asks
|
|
597
758
|
(#527, #552). One switch wires both. `none` by default: such clients are
|
|
598
759
|
refused and only first-party clients are served. `memory` forks per replica and
|
|
599
|
-
is refused under `
|
|
600
|
-
socket configured by `
|
|
760
|
+
is refused under `CORE_DEPLOYMENT_MODE=multi`; `redis` (#561) shares both over the
|
|
761
|
+
socket configured by `REDIS_CLIENTS_URL`.
|
|
762
|
+
|
|
763
|
+
| Variable | Default | Description |
|
|
764
|
+
|---|---|---|
|
|
765
|
+
| `ADAPTERS_CONSENT_STORE` | `none` | Consent store for clients that are not first-party (#527): `none` (such clients are refused), `memory` (single replica) or `redis` (shared, #561) |
|
|
766
|
+
|
|
767
|
+
### Multi-factor authentication
|
|
768
|
+
|
|
769
|
+
A second factor after a password login, and a step-up when a relying party
|
|
770
|
+
asks for one at `/authorize` — the [MFA package](../../packages/mfa/README.md).
|
|
771
|
+
`MFA_MODE` is the template's own switch, `mfaMode`
|
|
772
|
+
([`config/reference.conf`](config/reference.conf)): `required`, the default
|
|
773
|
+
(every password login has a second factor), and `optional` (a user with a
|
|
774
|
+
factor is challenged, nobody is forced) install the MFA module, the TOTP, recovery-code and email factors (email off
|
|
775
|
+
unless `MFA_EMAIL_FACTOR_ENABLED`), the operator reset
|
|
776
|
+
(`handle.components.mfaReset`), the session package's login completion and
|
|
777
|
+
the two MFA stores `adapters` selects. The template then adds `mfa` to
|
|
778
|
+
`core.sessionRequirements.expected`, names it
|
|
779
|
+
`core.sessionRequirements.secondFactorAuthority` and writes `mfa.mode` from
|
|
780
|
+
the switch, so
|
|
781
|
+
a composition that asks for a second factor and cannot enforce one is refused
|
|
782
|
+
at boot rather than let a password alone sign in; `off` installs nothing of
|
|
783
|
+
MFA. A value that is none of the three is refused before boot, naming
|
|
784
|
+
`mfaMode` and `MFA_MODE`.
|
|
785
|
+
|
|
786
|
+
**On by default.** In development (`make dev`) MFA needs nothing more: the
|
|
787
|
+
sample key in `config/development.conf`, the sender that logs each code, and
|
|
788
|
+
`docker-compose.yml`'s Redis for the two stores. Outside development a
|
|
789
|
+
deployment either sets what MFA needs — the two stores on `redis` (or the
|
|
790
|
+
factors in the `store`), `MFA_ENCRYPTION_KEY` and the SMTP relay
|
|
791
|
+
(`STANDARD_SMTP_MAIL_SENDER_HOST` and `_FROM`, or a sender of its own through
|
|
792
|
+
`buildModules`' `mailSenderModules`) — or sets `MFA_MODE=off`. Until it
|
|
793
|
+
decides, the boot is refused before the app is created: the stores' refusal
|
|
794
|
+
comes first, naming each of those and `MFA_MODE=off`. The MFA page is never
|
|
795
|
+
refused: `MFA_PAGE_URL` defaults to `/mfa`, which the deployment must serve,
|
|
796
|
+
in development too, or every password login stops there.
|
|
601
797
|
|
|
602
798
|
| Variable | Default | Description |
|
|
603
799
|
|---|---|---|
|
|
604
|
-
| `
|
|
800
|
+
| `MFA_MODE` | `required` | `mfaMode`: `required`, `optional` or `off` |
|
|
801
|
+
| `MFA_ENCRYPTION_KEY` | — | The MFA key ring's first key, which seals every factor's data: canonical base64 of 32 bytes (`openssl rand -base64 32`). Required with MFA on. Under `CONFIG_ENV=development`, `config/development.conf` puts the MFA package's published sample key in its place: write your own key there instead, since this variable set beside that ring refuses the boot. The sample key is refused under `CONFIG_ENV` or `NODE_ENV` `production` or `staging` and under `CORE_DEPLOYMENT_MODE=multi` |
|
|
802
|
+
| `MFA_PAGE_URL` | `/mfa` | The deployment's MFA page, where a login's second factor and a step-up start. The template ships no page: the page contract is the [MFA package's](../../packages/mfa/README.md#the-routes) |
|
|
803
|
+
| `MFA_STORE_TIMEOUT_MS` | `5000` | `mfa.storeTimeoutMs`, one Store call's time: at least every store's own per-call timeout. Below `REPOSITORIES_USER_HTTP_TIMEOUT` where the Store is called (`ADAPTERS_USER_REPOSITORY=http`, or the factors in the Store) the boot is refused, so raise the two together; above 37500 ms it is refused too |
|
|
804
|
+
| `STANDARD_SMTP_MAIL_SENDER_HOST` | — | The SMTP relay outside development, where MFA mails the account-email proof and the email factor's codes. With MFA on, the boot needs it and `STANDARD_SMTP_MAIL_SENDER_FROM` |
|
|
805
|
+
| `STANDARD_SMTP_MAIL_SENDER_FROM` | — | The one sender address of that mail |
|
|
806
|
+
| `STANDARD_SMTP_MAIL_SENDER_PORT` | `587` | The relay's port |
|
|
807
|
+
| `STANDARD_SMTP_MAIL_SENDER_SECURE` | `starttls` | `starttls`, `tls`, or `none` to a loopback relay only |
|
|
808
|
+
| `STANDARD_SMTP_MAIL_SENDER_USER` | — | The relay account, with `STANDARD_SMTP_MAIL_SENDER_PASSWORD` |
|
|
809
|
+
| `STANDARD_SMTP_MAIL_SENDER_PASSWORD` | — | That account's password |
|
|
810
|
+
|
|
811
|
+
The rest of the MFA settings — each factor's, the lock, a transaction's life
|
|
812
|
+
— are the MFA package's, with their variables, in its
|
|
813
|
+
[README](../../packages/mfa/README.md#configuration). A few things to know:
|
|
814
|
+
|
|
815
|
+
- **The stores.** `memory`, the shipped selection, is for development and
|
|
816
|
+
test alone: a restart loses every factor, lock and recorded email proof,
|
|
817
|
+
after which whoever holds a password can bind a factor of their own. With
|
|
818
|
+
MFA on it is refused before boot unless the configuration's name, and
|
|
819
|
+
`CONFIG_ENV` and `NODE_ENV` wherever set, each say `development` or
|
|
820
|
+
`test`, and core refuses it under `CORE_DEPLOYMENT_MODE=multi`. Production
|
|
821
|
+
needs `redis` for both, or `store` for the factors: `redis` shares the
|
|
822
|
+
socket `REDIS_CLIENTS_URL` opens; `store` (factors only) keeps them behind the Store's four endpoints
|
|
823
|
+
(`FOUNDATION_MFA_FACTOR_STORE_*`,
|
|
824
|
+
[foundation's README](../../packages/foundation/README.md)), sent the same
|
|
825
|
+
bearer token as the user repository.
|
|
826
|
+
- **The enrollment witness.** With `ADAPTERS_USER_REPOSITORY=http`, set
|
|
827
|
+
`REPOSITORIES_USER_HTTP_MARK_MFA_ENROLLED_URL` ([User Repository](#user-repository));
|
|
828
|
+
without it, boot warns once (`mfa_enrollment_witness_unwritable`).
|
|
829
|
+
- **`acr`.** With MFA on, the template adds `"urn:o3co:acr:mfa" = ["mfa"]`
|
|
830
|
+
to `oauth.authorize.acrValues`, unless your configuration writes that
|
|
831
|
+
entry, and discovery advertises it. With MFA off it adds nothing: the acr
|
|
832
|
+
table and discovery are what they are without MFA.
|
|
833
|
+
- **The mail in development.** Under `CONFIG_ENV=development` the template's
|
|
834
|
+
sender logs each code (`mail_code_issued`) and sends nothing. To run the
|
|
835
|
+
SMTP sender and read what it sends, use the
|
|
836
|
+
[Mailpit overlay](#mailpit-for-the-smtp-sender-development-only).
|
|
837
|
+
- **One switch.** A file that writes `mfaMode` while `MFA_MODE` is set to
|
|
838
|
+
something else, and a configuration that writes `mfa.mode` other than
|
|
839
|
+
what the switch says, are refused before boot, naming the keys. While MFA
|
|
840
|
+
is off, nothing the configuration writes under `mfa` is handed to boot.
|
|
605
841
|
|
|
606
842
|
### Federation Grants
|
|
607
843
|
|
|
@@ -617,29 +853,35 @@ needs before it issues a refresh token is in
|
|
|
617
853
|
|
|
618
854
|
| Variable | Default | Description |
|
|
619
855
|
|---|---|---|
|
|
620
|
-
| `FEDERATION_GRANTS_ENABLED` | `false` | Installs the routes, the two stores below and the subject-revocation service |
|
|
856
|
+
| `FEDERATION_GRANTS_ENABLED` | `false` | Installs the routes, the two stores selected below (none until selected) and the subject-revocation service |
|
|
621
857
|
| `FEDERATION_GRANTS_CONSENT_URL` | — | The deployment's consent page for grants: a path, or an absolute URL on the provider's origin. No default — enabling grants is a statement that the page exists, and boot refuses without it |
|
|
622
858
|
| `FEDERATION_GRANTS_IDENTITY_LOOKUP` | `required` | Whether the connect callback refuses an upstream account already linked to another local user. `required` needs a user repository that covers every connection's registration (below); `unsupported` records that the check is not made |
|
|
623
|
-
| `
|
|
624
|
-
| `
|
|
625
|
-
| `
|
|
859
|
+
| `ADAPTERS_FEDERATION_GRANT_STORE` | `none` | Where grants live: `none` (no store; an enabled feature refuses boot naming it), `memory` (one replica; lost on restart, every user reconnects) or `redis` (the shared socket) |
|
|
860
|
+
| `ADAPTERS_FEDERATION_GRANT_INTENT_STORE` | `none` | Where acquisition's records live — the intent a backend lodged, the consent challenge, the connect transaction: `none` (no store; an enabled feature refuses boot naming it), `memory` (one replica; a restart loses flows in progress and nothing else) or `redis` |
|
|
861
|
+
| `REDIS_FEDERATION_GRANT_STORE_ENCRYPTION_MODE` | `required` | `required` or `allow-plaintext`. Plaintext is refused in production/staging and under `CORE_DEPLOYMENT_MODE=multi` unless `FEDERATION_TOKENS_ALLOW_INSECURE=1` |
|
|
626
862
|
| `FEDERATION_GRANTS_ALLOW_KEEP_ON_SUBJECT_REVOCATION` | `false` | Whether a subject-wide revocation may be *asked* to leave established grants standing. An allowance, not an instruction |
|
|
627
863
|
| `REDIS_FEDERATION_GRANT_STORE_KEY_PREFIX` | `fg:` | Key namespace of the Redis grant store |
|
|
864
|
+
| `REDIS_FEDERATION_GRANT_INTENT_STORE_KEY_PREFIX` | `fg:` | Key namespace of the Redis intent store; set it with the grant store's — the template refuses to boot with the grant store's set and this one left at its default |
|
|
628
865
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
866
|
+
The feature's own settings are the `federation-grants {}` section; the Redis
|
|
867
|
+
grant store's — its key ring, its encryption mode, its prefix — are
|
|
868
|
+
`redis-federation-grant-store {}`. **Two things have no environment form**,
|
|
869
|
+
because a list is HOCON's: the connections, and the encryption key ring.
|
|
870
|
+
Write them in a deployment-owned layer — `config/production.conf`, say:
|
|
632
871
|
|
|
633
872
|
```hocon
|
|
634
|
-
|
|
873
|
+
redis-federation-grant-store {
|
|
635
874
|
encryptionKeys = [
|
|
636
875
|
# The first key seals; every listed key opens. GRANT_KEY_2026_09 is a name
|
|
637
876
|
# you choose (openssl rand -base64 32), not a template override.
|
|
638
877
|
{ id = "2026-09", key = ${GRANT_KEY_2026_09} }
|
|
639
878
|
]
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
federation-grants {
|
|
640
882
|
connections {
|
|
641
883
|
files {
|
|
642
|
-
federation = "entra-files" # an enabled federations.<name> of type "oidc", with an app registration of its own
|
|
884
|
+
federation = "entra-files" # an enabled core.federations.<name> of type "oidc", with an app registration of its own
|
|
643
885
|
scopes = ["openid", "profile", "offline_access", "Files.Read"]
|
|
644
886
|
boundary = "production"
|
|
645
887
|
maxAccessTokenLifetime = 3600
|
|
@@ -659,15 +901,15 @@ enabled, or on one whose adapter lacks the delegated capability — only the
|
|
|
659
901
|
generic OIDC adapter has it, so a Google connection is a `type = "oidc"`
|
|
660
902
|
federation; `required` with a user repository that does not cover a
|
|
661
903
|
connection's registration; Redis grants beside memory user-session stores
|
|
662
|
-
(`
|
|
904
|
+
(`ADAPTERS_USER_SESSION_STORES=memory` — the grants would outlive the boundary
|
|
663
905
|
that ends them; both compose files set `redis`); the Redis grant store under
|
|
664
906
|
`encryptionMode = "required"` with no key in the ring (the memory store seals
|
|
665
|
-
nothing and needs none); `memory` for either store under `
|
|
907
|
+
nothing and needs none); `memory` for either store under `CORE_DEPLOYMENT_MODE=multi`.
|
|
666
908
|
|
|
667
909
|
**The user repository.** Under `required`, boot asks the repository whether it
|
|
668
910
|
covers each connection's registration, and the connect callback asks it who
|
|
669
911
|
holds the upstream account. The template's `http` repository asks your Store
|
|
670
|
-
(#613): set `
|
|
912
|
+
(#613): set `REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL` to the
|
|
671
913
|
endpoint, and declare what that endpoint covers — one entry per registration,
|
|
672
914
|
with the claims the Store's strategy needs — in a HOCON layer:
|
|
673
915
|
|
|
@@ -718,9 +960,21 @@ is `/oauth/consent`'s, so one page can serve both. `GET
|
|
|
718
960
|
duration after approval, not a date), `continues_after_logout` (which the page
|
|
719
961
|
must show), and `expires_in` (what is left of the flow). `POST` with
|
|
720
962
|
`challenge` and `decision` (`accept` | `deny`) answers `303` — to the upstream,
|
|
721
|
-
or back to the client. Every acquisition and renewal goes through it.
|
|
722
|
-
|
|
723
|
-
|
|
963
|
+
or back to the client. Every acquisition and renewal goes through it. The
|
|
964
|
+
answer is held to the session module's CSRF policy: post it as a form from the
|
|
965
|
+
page, and serve the page with `Referrer-Policy: same-origin` — not
|
|
966
|
+
`no-referrer`, whether by the header, `<meta name="referrer">` or
|
|
967
|
+
`rel="noreferrer"` on the form, under which the browser sends `Origin: null`
|
|
968
|
+
and the answer is refused. This app's `helmet()` sends `no-referrer` on every
|
|
969
|
+
response, so a page it serves sets `Referrer-Policy: same-origin` on its own
|
|
970
|
+
route. Behind a proxy, `HTTP_TRUST_PROXY` names it, and it forwards
|
|
971
|
+
`X-Forwarded-Proto` and `X-Forwarded-Host` (or keeps the browser's `Host`). A
|
|
972
|
+
user agent that sends neither `Origin` nor `Referer` echoes the token
|
|
973
|
+
`GET /session/csrf` hands out, as for `POST /session/login`; a page may always
|
|
974
|
+
include it, since it counts only when neither is sent. The package README has
|
|
975
|
+
the rule.
|
|
976
|
+
|
|
977
|
+
**The login page** is the one `SESSION_LOGIN_PAGE_URL` names, reached with
|
|
724
978
|
`redirect_to=<the connect link>`; it signs the user in and navigates back to
|
|
725
979
|
that link unchanged, as it does for `/oauth/authorize`. Do not submit the link
|
|
726
980
|
to `POST /session/login` as its `redirect_to`: that route's exact-match
|
|
@@ -744,10 +998,10 @@ auth.provider instances cannot collide in the same database:
|
|
|
744
998
|
| Variable | Default | Description |
|
|
745
999
|
|---|---|---|
|
|
746
1000
|
| `REDIS_SESSION_STORES_KEY_PREFIX` | `ss:` | Outer prefix for user sessions, RP registry, session-family index, and session-federation index. |
|
|
747
|
-
| `
|
|
748
|
-
| `
|
|
1001
|
+
| `REDIS_REFRESH_TOKEN_FAMILY_STORE_KEY_PREFIX` | `rtfam:` | Prefix for refresh-token family records. |
|
|
1002
|
+
| `REDIS_CODE_REPOSITORY_KEY_PREFIX` | `oauth:code:` | Prefix for OAuth authorization codes. |
|
|
749
1003
|
| `REDIS_FEDERATION_TOKEN_STORE_KEY_PREFIX` | `ft:` | Prefix for federation token records, their per-session index and their lock keys. |
|
|
750
|
-
| `REDIS_CONSENT_STORE_KEY_PREFIX` | `consent:` | Prefix for consent records and for parked consent requests with their per-session index (`
|
|
1004
|
+
| `REDIS_CONSENT_STORE_KEY_PREFIX` | `consent:` | Prefix for consent records and for parked consent requests with their per-session index (`ADAPTERS_CONSENT_STORE=redis`, #561). |
|
|
751
1005
|
|
|
752
1006
|
Use values that include the deployment name, for example `tenant-a:ss:`,
|
|
753
1007
|
`tenant-a:rtfam:`, `tenant-a:code:`, `tenant-a:ft:`, and `tenant-a:consent:`.
|
|
@@ -756,22 +1010,24 @@ Use values that include the deployment name, for example `tenant-a:ss:`,
|
|
|
756
1010
|
|
|
757
1011
|
| Variable | Default | Description |
|
|
758
1012
|
|---|---|---|
|
|
759
|
-
| `
|
|
760
|
-
| `
|
|
1013
|
+
| `SESSION_LOGIN_PAGE_URL` | `/login` | URL of the login page (for redirects) |
|
|
1014
|
+
| `OAUTH_CONSENT_PAGE_URL` | `/consent` | URL of the consent page a client that is not first-party is routed through, with `?challenge=<id>` (#527) |
|
|
761
1015
|
|
|
762
1016
|
There is no deployment-wide client or callback URL: federation callback URLs
|
|
763
|
-
are configured per federation (`
|
|
764
|
-
`
|
|
1017
|
+
are configured per federation (`CORE_FEDERATIONS_GOOGLE_CALLBACK_URL`,
|
|
1018
|
+
`CORE_FEDERATIONS_OIDC_CALLBACK_URL`).
|
|
765
1019
|
|
|
766
1020
|
## Module Composition Order
|
|
767
1021
|
|
|
768
1022
|
[`src/buildModules.mts`](src/buildModules.mts) is the single source of truth for which modules are composed and in what order — read it rather than a copy of it. The boot planner resolves `requires` / `provides` topologically, but it mounts routes and middleware in list order unless a module declares `before` / `after` — so position matters for anything that mounts. These are the rules to keep when you edit the list:
|
|
769
1023
|
|
|
770
|
-
1. **`sessionStoreModuleFor(config)` stays first.** It mounts the `express-session` middleware and declares no `before` / `after`, so its position in the list is what puts it ahead of every route that reads `req.session`. It is built from `config` so that `session.storage.type = "memory"` declares itself replica-unsafe.
|
|
1024
|
+
1. **`sessionStoreModuleFor(config)` stays first.** It mounts the `express-session` middleware and declares no `before` / `after`, so its position in the list is what puts it ahead of every route that reads `req.session`. It is built from `config` so that `session-store.storage.type = "memory"` declares itself replica-unsafe.
|
|
771
1025
|
2. **Under `/oauth`, the order does not matter.** `federationGrantsModules` (while federation grants are enabled), `oauthModule` and any module of your own may all mount routes under `/oauth`. `oauthModule`'s router parses the bodies of its own routes only, so each module's requests reach its own parsers whatever the list order — provided every module under `/oauth` parses its own body and scopes its parsers to exactly its own paths, as the shipped ones do — a route (`router.all(path, parser)` or the route's own handler list), not `router.use(path, parser)`, which matches every path beneath `path` as well. The federation grants browser half orders itself after the session middleware with its own `after`.
|
|
772
|
-
3. **One module per store slot.** Each adapter switch — `federationTokenStore
|
|
773
|
-
4. **The shared Redis connection comes with the first Redis-backed module.** `standaloneRedisClientsModule` opens the one ioredis connection every Redis adapter here uses, and is added whenever a composed module needs one. The refresh-token family store is on Redis in the shipped composition, so a deployment always has it; the in-memory family store is a test override (`overrides.refreshTokenFamilyModules`).
|
|
774
|
-
5. **
|
|
1026
|
+
3. **One module per store slot.** Each adapter switch — `adapters.federationTokenStore`, `adapters.userSessionStores`, `adapters.rateLimiter`, `adapters.codeRepository`, `adapters.accessTokenDenylist`, `adapters.replaySeenSet`, `adapters.consentStore`, the two federation-grant store switches and the two MFA store switches — picks one of a memory / Redis pair (or, for the MFA factors, the Store). Both provide the same slot, so wiring both is a boot-time slot collision. `adapters.consentStore = "none"` wires neither, the federation-grant stores are wired only while the feature is enabled, and the MFA stores only while `MFA_MODE` installs MFA.
|
|
1027
|
+
4. **The shared Redis connection comes with the first Redis-backed module.** `standaloneRedisClientsModule` opens the one ioredis connection every Redis adapter here uses, from its own section (`redis-clients`), and is added whenever a composed module needs one. The refresh-token family store is on Redis in the shipped composition, so a deployment always has it; the in-memory family store is a test override (`overrides.refreshTokenFamilyModules`).
|
|
1028
|
+
5. **The template's own settings modules are always composed.** `loggingModule` and `httpModule` own `logging {}` and `http {}`, the CORS list among `http`'s keys (`http.cors.allowedOrigins`). `httpModule` provides core's `httpSettings`, which is authoritative, so no `overrideComponents` entry replaces it while the module is loaded; it also provides the template's `httpHostSettings`, which `app.mts` reads after boot for the port and the readiness deadline. The logger is built before boot from the `logging` section (`readLogging`), not by a module, and handed to boot as the `logger` component.
|
|
1029
|
+
6. **A federation adapter comes with its config bridge.** `googleFederationModule` with `googleFederationConfigModule` — only for an enabled `core.federations.google` entry whose `type` is `google`, so a `type = "oidc"` section named `google` is not composed twice — and one `oidcFederationModule(name)` per enabled `type = "oidc"` section, with the one `oidcFederationConfigModule` they share. A bridge's provider throws when its section is absent, so the pair is included at composition time rather than gated inside it.
|
|
1030
|
+
7. **The mail sender follows the environment.** `@o3co/auth-provider-standard`'s development sender, which logs each code, where the configuration was selected as `development`; its module installs only where that name, and `CONFIG_ENV` and `NODE_ENV` wherever they are set, each read `development` or `test`, and refuses the boot otherwise, or where `core.deployment.mode` is `multi`. Under any other name, the SMTP sender's module, whose section is `standard-smtp-mail-sender` ([the package's README](../../packages/standard/README.md)); its sender is built only where something reads the `mailSender` slot, and there the boot needs `STANDARD_SMTP_MAIL_SENDER_HOST` and `STANDARD_SMTP_MAIL_SENDER_FROM`. While `MFA_MODE` is `off` nothing reads the slot, so the template boots without them; with MFA on, the MFA module and the operator reset read it. A sender of your own replaces this choice: pass its module where [`src/app.mts`](src/app.mts) calls `buildModules`, as `buildModules(switches, { environment: env, logger, mailSenderModules: [mySenderModule] })`. Given, `mailSenderModules` is installed under every environment name and the bundled sender is not, so the two never both provide the slot; an empty list installs no sender, and a module that needs one (the MFA email factor, or the MFA module with `requireEmailProof = "always"`) then refuses the boot.
|
|
775
1031
|
|
|
776
1032
|
`jwksModule` (from core) is always composed: a provider that signs tokens publishes its verification keys whether or not an issuer is configured. What each route module mounts is in its package's README. One behaviour to know when composing: `sessionModule`'s `POST /session/logout` deletes the `UserSession` record (so `/oauth/introspect` and `/oauth/userinfo` stop honouring tokens minted from that session), the subject index and the federation entries — but it does **not** revoke refresh-token families; `POST /oauth/logout` is the endpoint that runs the full cascade. See [Which logout endpoint invalidates what](../../docs/operator-runbook.md#which-logout-endpoint-invalidates-what).
|
|
777
1033
|
|
|
@@ -809,11 +1065,13 @@ make test
|
|
|
809
1065
|
The `docker-compose.yml` starts the auth server together with a Redis container. Configure environment variables in `.env`.
|
|
810
1066
|
|
|
811
1067
|
`docker-compose.yml` is a **development** file: it builds the `develop` target and bind-mounts `./src` and `./config`, so deploying it ships a hot-reload server running your working tree. The deployable shape is
|
|
812
|
-
[`docker-compose.production.yml`](docker-compose.production.yml) — `runtime` target, no source mounts, restart policies, a network-internal persistent Redis, and a **required** `.env` (a boot without a real `
|
|
1068
|
+
[`docker-compose.production.yml`](docker-compose.production.yml) — `runtime` target, no source mounts, restart policies, a network-internal persistent Redis, and a **required** `.env` (a boot without a real `SESSION_STORE_SECRET` must fail loudly). Its header comments state what it deliberately leaves to you: TLS termination in front, and the [multi-replica](#multi-replica-deployments) steps before any `--scale`.
|
|
813
1069
|
|
|
814
1070
|
`HTTP_TRUST_PROXY` is an explicit `${HTTP_TRUST_PROXY:?…}` entry there, so `docker compose up` **refuses to start** until you name the hop in `.env`. That is deliberate: there is no address the file could default to that would not silently trust a hop you never chose, and without the variable the Secure cookie the file pins is never set, the CSRF origin check 403s every browser POST, and every IP-keyed rate limit shares one bucket.
|
|
815
1071
|
|
|
816
|
-
Every store whose records must outlive one process is named in that file's `environment:` block rather than inherited — including `
|
|
1072
|
+
Every store whose records must outlive one process is named in that file's `environment:` block rather than inherited — including `ADAPTERS_USER_SESSION_STORES=redis`, which has to travel with `SESSION_STORE_STORAGE_TYPE=redis`. `CORE_DEPLOYMENT_MODE=single` will not tell you when it does not: the replica guard answers "can these stores be shared", not "do these two stores have the same lifetime". Split them and a restart leaves every browser holding a surviving express-session that still reads `isAuthenticated` with no `UserSession` behind it — `/authorize` bounces to login, the cookie bounces it back, and the loop clears only when the user deletes the cookie.
|
|
1073
|
+
|
|
1074
|
+
The two MFA stores are the exception, since MFA is on by default and whether to keep it is the deployment's decision: the production file leaves them at `memory`, which the template refuses in production before boot, naming the stores, `MFA_ENCRYPTION_KEY`, the SMTP relay, `MFA_PAGE_URL` and `MFA_MODE=off`. Set them in `.env` — `ADAPTERS_MFA_FACTOR_STORE=redis` and `ADAPTERS_MFA_TRANSACTION_STORE=redis`, on the file's persistent Redis, with the rest of [Multi-factor authentication](#multi-factor-authentication) — or set `MFA_MODE=off`. `docker-compose.yml` keeps both on its Redis, so that a hot reload does not empty them while the sessions survive.
|
|
817
1075
|
|
|
818
1076
|
```bash
|
|
819
1077
|
# The signing keys are a required input: EdDSA is the default and there is no
|
|
@@ -822,19 +1080,32 @@ openssl genpkey -algorithm ed25519 -out jwt-private.pem
|
|
|
822
1080
|
openssl pkey -in jwt-private.pem -pubout -out jwt-public.pem
|
|
823
1081
|
chmod 600 jwt-private.pem
|
|
824
1082
|
|
|
1083
|
+
# The client registry is a required input too: the scaffold's
|
|
1084
|
+
# config/clients.yaml, or one made from config/clients.yaml.example.
|
|
1085
|
+
|
|
825
1086
|
docker compose -f docker-compose.production.yml up -d --build
|
|
826
1087
|
```
|
|
827
1088
|
|
|
828
1089
|
**Keys in containers.** The pem pair reaches the container as a compose
|
|
829
1090
|
**secret**, mounted read-only at `/run/secrets/`, and the compose file points
|
|
830
|
-
`
|
|
831
|
-
`COPY`s that directory
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
The
|
|
1091
|
+
`KEY_STORE_LOCAL_*_KEY_PATH` there. Do not park them in `config/`: the `Dockerfile`
|
|
1092
|
+
`COPY`s that directory. `.dockerignore` keeps every `*.pem` and `*.key` out of
|
|
1093
|
+
the build context, as `.gitignore` keeps them out of git, but a key under any
|
|
1094
|
+
other name placed there is baked into an image layer and travels with every
|
|
1095
|
+
push — a key you then have to rotate rather than one you merely stored badly.
|
|
1096
|
+
The same applies to `.env`; keep both out of git.
|
|
1097
|
+
|
|
1098
|
+
**The client registry in containers.** `config/clients.yaml` arrives the same
|
|
1099
|
+
way, as the compose secret `client_registry`, with `REPOSITORIES_CLIENT_YAML_PATH` pointed at it.
|
|
1100
|
+
It is per-deployment and may hold client secrets, so `.dockerignore` keeps it
|
|
1101
|
+
out of the build context: no image carries a registry, and an image built from
|
|
1102
|
+
a working copy is the same as one built from a clean checkout. Compose refuses
|
|
1103
|
+
to start until the file exists. Run the image some other way and you mount it
|
|
1104
|
+
and set `REPOSITORIES_CLIENT_YAML_PATH` yourself.
|
|
1105
|
+
|
|
1106
|
+
The production file also pins `SESSION_STORE_SECURE=true` and the `__Host-` cookie
|
|
836
1107
|
name in its `environment:` block, which wins over `env_file`. `.env.example`
|
|
837
|
-
ships `
|
|
1108
|
+
ships `SESSION_STORE_SECURE=false` so that a plain-HTTP compose run (`make dev`) does
|
|
838
1109
|
not trip the `__Host-` cookie check, and this file requires that same `.env` — behind the TLS it assumes, a non-Secure session
|
|
839
1110
|
cookie is the session handed to anyone who can read one plaintext hop.
|
|
840
1111
|
|
|
@@ -855,6 +1126,47 @@ docker run -e HTTP_PORT=8080 -p 8080:8080 my-auth-provider
|
|
|
855
1126
|
`EXPOSE` is image metadata and does not publish ports by itself, so the
|
|
856
1127
|
explicit `-p` mapping is still required.
|
|
857
1128
|
|
|
1129
|
+
### Mailpit for the SMTP sender (development only)
|
|
1130
|
+
|
|
1131
|
+
[`docker-compose.mailpit.yml`](docker-compose.mailpit.yml) is an overlay on
|
|
1132
|
+
`docker-compose.yml` that adds [Mailpit](https://mailpit.axllent.org/), a mail
|
|
1133
|
+
catcher, so a development run with MFA on sends its mail — the account-email
|
|
1134
|
+
proof, the email factor's codes — through the SMTP sender instead of the
|
|
1135
|
+
development sender, which only logs each code:
|
|
1136
|
+
|
|
1137
|
+
```bash
|
|
1138
|
+
docker compose -f docker-compose.yml -f docker-compose.mailpit.yml up --build
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
Read the mail at <http://localhost:8025>. Mailpit keeps it and delivers
|
|
1142
|
+
nothing onward. A plain `docker compose up` (`make dev`) starts no Mailpit, and
|
|
1143
|
+
the production file names none. It is for development only: a deployment
|
|
1144
|
+
names a real relay with the `STANDARD_SMTP_MAIL_SENDER_*` variables
|
|
1145
|
+
([Multi-factor authentication](#multi-factor-authentication)).
|
|
1146
|
+
|
|
1147
|
+
What the overlay sets on the app service:
|
|
1148
|
+
|
|
1149
|
+
- `CONFIG_ENV=mailpit`. Under `development` the template installs the sender
|
|
1150
|
+
that logs each code ([Module Composition Order](#module-composition-order),
|
|
1151
|
+
rule 7). [`config/mailpit.conf`](config/mailpit.conf) includes
|
|
1152
|
+
`development.conf`, so the run is otherwise the development one, the MFA
|
|
1153
|
+
sample key included.
|
|
1154
|
+
- Nothing of `MFA_MODE`: MFA is on as the template ships it, or as your
|
|
1155
|
+
`.env` sets it. With MFA off nothing sends mail.
|
|
1156
|
+
- `ADAPTERS_MFA_FACTOR_STORE=redis` and `ADAPTERS_MFA_TRANSACTION_STORE=redis`,
|
|
1157
|
+
on the compose Redis, as `docker-compose.yml` sets them: under a name other
|
|
1158
|
+
than `development` or `test` the MFA stores may not be kept in memory.
|
|
1159
|
+
- `STANDARD_SMTP_MAIL_SENDER_HOST=localhost`,
|
|
1160
|
+
`STANDARD_SMTP_MAIL_SENDER_PORT=1025`, `STANDARD_SMTP_MAIL_SENDER_SECURE=none`
|
|
1161
|
+
and `STANDARD_SMTP_MAIL_SENDER_FROM=auth@example.com`. The SMTP sender sends
|
|
1162
|
+
in plaintext only to a loopback host, so Mailpit runs in the app container's
|
|
1163
|
+
network namespace (`network_mode: service:app`) and listens on its
|
|
1164
|
+
`localhost`; the app service therefore publishes Mailpit's web UI, on
|
|
1165
|
+
loopback.
|
|
1166
|
+
|
|
1167
|
+
It is an overlay rather than a compose profile because a profile only adds
|
|
1168
|
+
services: it cannot change the app service's environment or ports.
|
|
1169
|
+
|
|
858
1170
|
### Health endpoints
|
|
859
1171
|
|
|
860
1172
|
Two routes, answering two different questions. Both are mounted on the host
|
|
@@ -940,12 +1252,14 @@ To add a custom module, import it in `src/buildModules.mts` and add it to the ar
|
|
|
940
1252
|
return [
|
|
941
1253
|
sessionStoreModuleFor(config),
|
|
942
1254
|
…
|
|
943
|
-
...(federationGrantsEnabled ? [subjectRevocationServiceModule] : []),
|
|
1255
|
+
...(federationGrantsEnabled || mfaInstalled ? [subjectRevocationServiceModule] : []),
|
|
944
1256
|
+ myCustomModule,
|
|
945
1257
|
];
|
|
946
1258
|
```
|
|
947
1259
|
|
|
948
|
-
Keep the other rules there too: the session store module stays first, and a module that fills a store slot replaces that slot's adapter switch rather than being added beside it. [`src/app.mts`](src/app.mts) needs no change: it passes `buildModules(config, …)` to `createApp`, mounts the router `createApp` returns, and wires the server's lifetime — `installGracefulShutdown` (below) drains it and calls `handle.dispose()`.
|
|
1260
|
+
Keep the other rules there too: the session store module stays first, and a module that fills a store slot replaces that slot's adapter switch rather than being added beside it. [`src/app.mts`](src/app.mts) needs no change: it passes `buildModules(config, …)` to `createApp`, mounts the router `createApp` returns, and wires the server's lifetime — `installGracefulShutdown` (below) drains it and calls `handle.dispose()`. The exception is a mail sender of your own: it goes in through the `mailSenderModules` override in that call (rule 7), not into the list, where it would collide with the bundled sender on the `mailSender` slot.
|
|
1261
|
+
|
|
1262
|
+
A module that contributes a session requirement changes what "logged in" means, so its name goes in `core.sessionRequirements.expected`, which `config/application.conf` ships as `[]`. Boot compares the list with what the modules register. A name listed that nothing registers refuses the boot (`session-requirement-missing`), and so does a registered requirement the list leaves out (`session-requirements-undeclared`). When `MFA_MODE` installs MFA, the template adds `mfa` to the list (`expectedSessionRequirements`, [`src/configPath.mts`](src/configPath.mts)), keeping the names you wrote, and writes `core.sessionRequirements.secondFactorAuthority = "mfa"` beside it; a value of your own there other than `mfa` is refused before boot. The MFA module it installs registers `mfa` and declares the second-factor authority. Core refuses a declared authority whose requirement does not declare it (`second-factor-authority-not-declared`), a second requirement named `mfa`, and a second requirement declaring the authority (`duplicate-second-factor-authority`), so a module you add cannot stand in for it. Install MFA through `MFA_MODE`, not by adding its modules to the list: the template would install them a second time.
|
|
949
1263
|
|
|
950
1264
|
### Shutdown guarantees
|
|
951
1265
|
|
|
@@ -955,9 +1269,22 @@ Keep the other rules there too: the session store module stays first, and a modu
|
|
|
955
1269
|
2. **New connections stop immediately**, and idle keep-alive sockets are released — they hold the server open with no request behind them, so a quiet server would otherwise wait out the whole deadline for nothing.
|
|
956
1270
|
3. **In-flight requests get `drainTimeoutMs`** (default **10s**) to finish.
|
|
957
1271
|
4. **Past the deadline the remaining connections are cut and the process exits non-zero.** An orchestrator that only ever sees `0` cannot tell a clean drain from one that ran out of time.
|
|
958
|
-
5. **`cleanup` runs after draining, before exit** — `handle.dispose()`, i.e. reverse-topological component cleanup plus the Redis/timer drain. A failure there is logged through this service's own logger (NDJSON, like every other line) as `shutdown_cleanup_failed` (or `shutdown_cleanup_timed_out`) and reflected in the exit code; every stage is its own event
|
|
1272
|
+
5. **`cleanup` runs after draining, before exit** — `handle.dispose()`, i.e. reverse-topological component cleanup plus the Redis/timer drain. A failure there is logged through this service's own logger (NDJSON, like every other line) as `shutdown_cleanup_failed` (or `shutdown_cleanup_timed_out`) and reflected in the exit code; every stage is its own event (see the table below). A dispose that throws still exits; it never wedges the process. The line carries core's [`loggableError`](../../packages/core/README.md#logger) projection of the failure, never the error itself: `dispose()` rejects with an AggregateError of every cleanup's own error, and the line names each of them with its code (`aggregateErrors`, the first five) and nothing of what it holds — a store write that failed, with what it was writing, can be one of them.
|
|
1273
|
+
|
|
1274
|
+
6. **`cleanup` gets at least the allowance the modules registered**: `handle.cleanupAllowanceMs`, the longest tail a module registered its cleanup with, which `src/app.mts` hands `installGracefulShutdown` as `cleanupAllowanceMs: () => handle.cleanupAllowanceMs`, read when the signal arrives; cleanup's budget is the longer of it and the drain's ten, and `shutdown_draining` logs it as `cleanupTimeoutMs`. An allowance that is not a whole number of milliseconds from 1 to 2147483647 is ignored. The template reads no module's settings to size it. With federation grants on, the package registers its drain's tail as `federation-grants.upstreamHardTimeoutMs` + `persistRetryBudgetMs` + `lockWaitMs` + 12 s, never below 45 s — exactly 45 s under the shipped budgets (25 + 3 + 5 + 12) — because the dispose waits for a rotated upstream credential's write. Raise a budget and the allowance grows with it; raise your orchestrator's grace to match. Off, nothing registers an allowance and the cleanup budget stays the drain's.
|
|
1275
|
+
|
|
1276
|
+
Each stage logs one line:
|
|
959
1277
|
|
|
960
|
-
|
|
1278
|
+
| Event | Level | Fields |
|
|
1279
|
+
|---|---|---|
|
|
1280
|
+
| `shutdown_draining` | info | `drainTimeoutMs`, `cleanupTimeoutMs` |
|
|
1281
|
+
| `shutdown_drain_deadline_exceeded` | error | `drainTimeoutMs` |
|
|
1282
|
+
| `shutdown_server_close_failed` | error | `err` |
|
|
1283
|
+
| `shutdown_cleanup_timed_out` | error | `cleanupTimeoutMs` |
|
|
1284
|
+
| `shutdown_cleanup_failed` | error | `err` |
|
|
1285
|
+
| `shutdown_complete` | info | `reason`, `drain`, `exitCode` |
|
|
1286
|
+
|
|
1287
|
+
`err` is the `loggableError` projection. `drain` is how the drain ended: `drained`, `drain-timeout` or `close-failed` (a listener that did not come down is not a clean drain, and exits non-zero). `reason` is what decided `exitCode`: the drain's outcome, or `cleanup-timeout` / `cleanup-failed` when the cleanup then timed out or threw, so `reason: "drained"` never sits beside a non-zero code.
|
|
961
1288
|
|
|
962
1289
|
**Size `drainTimeoutMs` and `cleanupTimeoutMs` together below your orchestrator's kill grace period.** Kubernetes `terminationGracePeriodSeconds` is 30s by default and compose's `stop_grace_period` is 10s; with federation grants on, the worst case is drain (10s) + cleanup (45s) = 55s, so **set the grace to 60s or more** — the shipped compose files do, and a Kubernetes deployment must set `terminationGracePeriodSeconds: 60` itself, or a rolling restart SIGKILLs the process in the middle of the write the cleanup exists to finish. The point is to close on your terms before `SIGKILL` arrives on someone else's.
|
|
963
1290
|
|
|
@@ -984,8 +1311,9 @@ Keep the other rules there too: the session store module stays first, and a modu
|
|
|
984
1311
|
### Logging
|
|
985
1312
|
|
|
986
1313
|
The provider logs newline-delimited JSON on stdout via [pino](https://getpino.io),
|
|
987
|
-
which is what a log aggregator ingests without a parser. `
|
|
988
|
-
`logging.level
|
|
1314
|
+
which is what a log aggregator ingests without a parser. `LOGGING_LEVEL` (HOCON
|
|
1315
|
+
`logging.level`, the `logging` module's section, read before boot with that
|
|
1316
|
+
module's schema) sets the threshold; `trace` and `debug` carry request-shaped
|
|
989
1317
|
detail and are off by default, and pino drops sub-threshold calls before
|
|
990
1318
|
formatting, so they cost nothing in production rather than being emitted and
|
|
991
1319
|
filtered downstream.
|
|
@@ -993,7 +1321,7 @@ filtered downstream.
|
|
|
993
1321
|
The logger is wired into the boot planner's `logger` component slot, so every
|
|
994
1322
|
module that declares `optional: ["logger"]` — oauth, session, dpop, mtls,
|
|
995
1323
|
token-exchange — logs through this one instance. Filling that slot is what makes
|
|
996
|
-
`
|
|
1324
|
+
`LOGGING_LEVEL` reach them; a composition root that leaves it empty gets each
|
|
997
1325
|
module's own `consoleLogger` default instead, and configuring a level changes
|
|
998
1326
|
nothing.
|
|
999
1327
|
|
|
@@ -1008,7 +1336,7 @@ shape, so a pino-compatible logger needs no adapter.
|
|
|
1008
1336
|
|
|
1009
1337
|
Security-relevant events — who authenticated, what was issued, what was refused,
|
|
1010
1338
|
and when the rate limiter could not answer — go to the sink named by
|
|
1011
|
-
`
|
|
1339
|
+
`adapters.auditSink` (env `ADAPTERS_AUDIT_SINK`). The template ships `"logger"`, which
|
|
1012
1340
|
writes one event per line through the same pino stream as everything else:
|
|
1013
1341
|
|
|
1014
1342
|
```json
|
|
@@ -1021,40 +1349,46 @@ The event type is also the message, so alert on the name — `authorize.rejected
|
|
|
1021
1349
|
`token.issued.failure`, `rate_limit.unavailable` — the same way you would on
|
|
1022
1350
|
`session_store_redis_error`.
|
|
1023
1351
|
|
|
1024
|
-
`
|
|
1352
|
+
`ADAPTERS_AUDIT_SINK=console` selects core's built-in sink instead: the bare event
|
|
1025
1353
|
as one JSON object per line, with no log envelope, for a pipeline that wants the
|
|
1026
1354
|
event and nothing else.
|
|
1027
1355
|
|
|
1028
|
-
**`
|
|
1356
|
+
**`LOGGING_LEVEL` does not gate the audit trail.** The audit stream's level is fixed
|
|
1029
1357
|
at `info`. `warn` is an ordinary production setting and `silent` a legitimate
|
|
1030
1358
|
one, and either silencing this would delete the record of every authentication
|
|
1031
1359
|
and issuance while looking like a logging preference. Where audit events go is
|
|
1032
|
-
chosen by `
|
|
1033
|
-
|
|
1034
|
-
deployment with no audit trail.
|
|
1360
|
+
chosen by `adapters.auditSink` — and that selector has **no `"none"`**. An unknown
|
|
1361
|
+
sink fails boot naming the sinks that are registered, rather than producing a
|
|
1362
|
+
deployment with no audit trail. A composition that installs no sink on purpose
|
|
1363
|
+
says so in core's own section, `core.declaredAbsent = ["auditSink"]`; this
|
|
1364
|
+
template always installs one.
|
|
1035
1365
|
|
|
1036
1366
|
To point it at a real sink — SIEM, log pipeline, message bus — register a
|
|
1037
|
-
builder in `
|
|
1038
|
-
|
|
1367
|
+
builder in `auditSinkModuleFor` (`src/modules.mts`) and select it; its options
|
|
1368
|
+
are the `audit-sink` module's section, under the sink's name:
|
|
1039
1369
|
|
|
1040
1370
|
```ts
|
|
1041
1371
|
factory.register("splunk-hec", (cfg) => createSplunkSink(cfg));
|
|
1042
1372
|
```
|
|
1043
1373
|
|
|
1044
1374
|
```hocon
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
splunk-hec { endpoint = ${?SPLUNK_HEC_URL}, token = ${?SPLUNK_HEC_TOKEN} }
|
|
1049
|
-
}
|
|
1375
|
+
adapters.auditSink = "splunk-hec"
|
|
1376
|
+
audit-sink {
|
|
1377
|
+
splunk-hec { endpoint = ${?SPLUNK_HEC_URL}, token = ${?SPLUNK_HEC_TOKEN} }
|
|
1050
1378
|
}
|
|
1051
1379
|
```
|
|
1052
1380
|
|
|
1381
|
+
To add an audit destination beside the configured one, contribute
|
|
1382
|
+
`auditHooks` from your own module; core fans out `auditSink` and `auditHooks`
|
|
1383
|
+
together.
|
|
1384
|
+
|
|
1053
1385
|
Sinks are fire-and-forget by contract: core dispatches without awaiting and
|
|
1054
1386
|
swallows rejections, so a slow or failing sink cannot add latency to — or
|
|
1055
1387
|
fail — an auth flow. The flip side is that a sink which cannot deliver drops
|
|
1056
|
-
|
|
1057
|
-
|
|
1388
|
+
the event. On its own a sink's failure is swallowed silently; once a module
|
|
1389
|
+
contributes `auditHooks`, the fan-out logs each failing call at error as
|
|
1390
|
+
`audit_sink_failed`, with the sink's position and the event's `type`. The
|
|
1391
|
+
drops are not counted yet — see **Not published yet** under Metrics below.
|
|
1058
1392
|
|
|
1059
1393
|
### Metrics
|
|
1060
1394
|
|