@o3co/create-auth-provider 0.16.0 → 0.17.0-rc.2

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.
Files changed (100) hide show
  1. package/README.ja.md +66 -21
  2. package/README.md +76 -31
  3. package/dist/index.d.mts +33 -10
  4. package/dist/index.d.mts.map +1 -1
  5. package/dist/index.mjs +118 -59
  6. package/dist/internal/template-filter.d.mts +7 -10
  7. package/dist/internal/template-filter.d.mts.map +1 -1
  8. package/dist/internal/template-filter.mjs +7 -10
  9. package/package.json +6 -4
  10. package/templates/standalone/.dockerignore +15 -2
  11. package/templates/standalone/.env.example +59 -29
  12. package/templates/standalone/Dockerfile +6 -2
  13. package/templates/standalone/README.ja.md +324 -169
  14. package/templates/standalone/README.md +618 -208
  15. package/templates/standalone/config/application.conf +211 -352
  16. package/templates/standalone/config/clients.yaml +2 -0
  17. package/templates/standalone/config/clients.yaml.example +4 -0
  18. package/templates/standalone/config/development.conf +13 -4
  19. package/templates/standalone/config/mailpit.conf +8 -0
  20. package/templates/standalone/config/production.conf +5 -6
  21. package/templates/standalone/config/reference.conf +418 -0
  22. package/templates/standalone/docker-compose.mailpit.yml +36 -0
  23. package/templates/standalone/docker-compose.production.yml +63 -32
  24. package/templates/standalone/docker-compose.yml +13 -3
  25. package/templates/standalone/gitignore +1 -0
  26. package/templates/standalone/package.json +9 -6
  27. package/templates/standalone/src/__tests__/adapters.test.mts +419 -0
  28. package/templates/standalone/src/__tests__/admission-lifecycle.test.mts +87 -0
  29. package/templates/standalone/src/__tests__/all-modules-composition.fixture.mts +287 -198
  30. package/templates/standalone/src/__tests__/all-modules-composition.multi.test.mts +71 -35
  31. package/templates/standalone/src/__tests__/all-modules-composition.test.mts +148 -94
  32. package/templates/standalone/src/__tests__/audit-sink.test.mts +84 -81
  33. package/templates/standalone/src/__tests__/config-notices.test.mts +154 -0
  34. package/templates/standalone/src/__tests__/configPath.test.mts +13 -11
  35. package/templates/standalone/src/__tests__/core-federations.test.mts +249 -0
  36. package/templates/standalone/src/__tests__/core-sections.test.mts +190 -0
  37. package/templates/standalone/src/__tests__/device-code-store-client-module.test.mts +10 -15
  38. package/templates/standalone/src/__tests__/documented-env-overrides.test.mts +970 -288
  39. package/templates/standalone/src/__tests__/federation-grants-composition.test.mts +421 -86
  40. package/templates/standalone/src/__tests__/federation-grants-survive-logout.test.mts +87 -72
  41. package/templates/standalone/src/__tests__/federation-token-refresh-outage.test.mts +16 -8
  42. package/templates/standalone/src/__tests__/federation-types.test.mts +239 -0
  43. package/templates/standalone/src/__tests__/google-session.fixture.mts +97 -93
  44. package/templates/standalone/src/__tests__/host-routes.test.mts +4 -11
  45. package/templates/standalone/src/__tests__/library-reference-resolution.smoke.test.mts +1 -1
  46. package/templates/standalone/src/__tests__/library-references.fixture.mts +188 -0
  47. package/templates/standalone/src/__tests__/lifecycle-pending-close.test.mts +216 -0
  48. package/templates/standalone/src/__tests__/listen.test.mts +6 -13
  49. package/templates/standalone/src/__tests__/logger-projection.test.mts +1 -1
  50. package/templates/standalone/src/__tests__/mail-sender.test.mts +134 -0
  51. package/templates/standalone/src/__tests__/mailpit-compose.test.mts +326 -0
  52. package/templates/standalone/src/__tests__/metrics.test.mts +4 -9
  53. package/templates/standalone/src/__tests__/mfa-routes-budget.test.mts +122 -0
  54. package/templates/standalone/src/__tests__/mfa-switch.redis.test.mts +123 -0
  55. package/templates/standalone/src/__tests__/mfa-switch.test.mts +825 -0
  56. package/templates/standalone/src/__tests__/own-modules.test.mts +1486 -0
  57. package/templates/standalone/src/__tests__/post-logout-redirect.test.mts +10 -14
  58. package/templates/standalone/src/__tests__/redis-connection-error-log.test.mts +1 -5
  59. package/templates/standalone/src/__tests__/redis-rate-limiter-config-survives.test.mts +116 -81
  60. package/templates/standalone/src/__tests__/refresh-token-family-client-module.test.mts +25 -31
  61. package/templates/standalone/src/__tests__/replica-safety.test.mts +265 -146
  62. package/templates/standalone/src/__tests__/router-error-answers.test.mts +4 -7
  63. package/templates/standalone/src/__tests__/scaffold-assets.test.mts +278 -103
  64. package/templates/standalone/src/__tests__/sections.test.mts +480 -0
  65. package/templates/standalone/src/__tests__/session-lifecycle.test.mts +215 -0
  66. package/templates/standalone/src/__tests__/session-logout-invalidates-token.test.mts +69 -61
  67. package/templates/standalone/src/__tests__/session-logout-lifecycle.test.mts +130 -0
  68. package/templates/standalone/src/__tests__/session-requirements.test.mts +382 -0
  69. package/templates/standalone/src/__tests__/shipped-config-notices.test.mts +270 -0
  70. package/templates/standalone/src/__tests__/shutdown.test.mts +163 -96
  71. package/templates/standalone/src/__tests__/smoke.test.mts +176 -258
  72. package/templates/standalone/src/__tests__/store-credential.test.mts +88 -52
  73. package/templates/standalone/src/__tests__/supertest-loopback.test.mts +182 -11
  74. package/templates/standalone/src/__tests__/three-tier-resolution.test.mts +131 -102
  75. package/templates/standalone/src/__tests__/two-phase-config.test.mts +604 -0
  76. package/templates/standalone/src/__tests__/upstream-amr.acceptance.test.mts +382 -0
  77. package/templates/standalone/src/adapters.mts +162 -0
  78. package/templates/standalone/src/app.mts +65 -79
  79. package/templates/standalone/src/bootRefusal.mts +117 -0
  80. package/templates/standalone/src/buildModules.mts +220 -309
  81. package/templates/standalone/src/configPath.mts +449 -29
  82. package/templates/standalone/src/listen.mts +12 -18
  83. package/templates/standalone/src/logger.mts +31 -60
  84. package/templates/standalone/src/metrics.mts +24 -47
  85. package/templates/standalone/src/mfaSwitch.mts +285 -0
  86. package/templates/standalone/src/modules.mts +423 -629
  87. package/templates/standalone/src/rootRenames.mts +96 -0
  88. package/templates/standalone/src/routes.mts +8 -14
  89. package/templates/standalone/src/sections.mts +367 -0
  90. package/templates/standalone/src/shutdown.mts +45 -123
  91. package/templates/standalone/tests/index.test.js +6 -5
  92. package/templates/standalone/tests/package-lock.json +1615 -2223
  93. package/templates/standalone/tests/package.json +2 -2
  94. package/templates/standalone/tests/vitest.config.mjs +26 -0
  95. package/templates/standalone/vitest.config.mts +8 -7
  96. package/templates/standalone/vitest.supertest-loopback.mts +97 -69
  97. package/templates/versions.json +18 -15
  98. package/templates/standalone/src/__tests__/access-token-lifetime-alias.test.mts +0 -135
  99. package/templates/standalone/src/__tests__/google-federation-config-module.test.mts +0 -199
  100. package/templates/standalone/src/__tests__/oidc-federation-config-module.test.mts +0 -138
@@ -1,2 +1,4 @@
1
1
  # Client definitions loaded via loadYamlMap into InMemoryClientRepository.
2
2
  # Add client entries here. See clients.yaml.example for format.
3
+ # Per-deployment: `.gitignore` keeps this file out of git and `.dockerignore`
4
+ # out of the image (#705).
@@ -1,6 +1,10 @@
1
1
  # Example client definitions loaded via loadYamlMap into InMemoryClientRepository.
2
2
  # Copy this file to clients.yaml and customize for your deployment.
3
3
  #
4
+ # clients.yaml is per-deployment (#705): `.gitignore` keeps it out of git and
5
+ # `.dockerignore` out of the image, and docker-compose.production.yml mounts it
6
+ # as the secret `client_registry`. This example is the committed one.
7
+ #
4
8
  # `tokenEndpointAuthMethod` is REQUIRED (RFC 6749 §2.3 / RFC 7591 §2):
5
9
  # - "client_secret_basic": HTTP Basic Authorization header — recommended for confidential clients
6
10
  # - "client_secret_post": form-encoded body parameters
@@ -2,7 +2,16 @@
2
2
  # Loaded when CONFIG_ENV (or NODE_ENV) is "development" — the default.
3
3
  # Values here override application.conf.
4
4
  #
5
- # Most values are controlled via environment variables (see ${?VAR}
6
- # substitutions in application.conf). Override entries here only when
7
- # you need a fixed development-specific value that cannot come from
8
- # an environment variable.
5
+ # Most values are controlled via environment variables (see the ${?VAR}
6
+ # substitutions in application.conf and reference.conf). Override entries
7
+ # here only when you need a fixed development-specific value that cannot come
8
+ # from an environment variable.
9
+
10
+ # The MFA key ring's development key: the MFA package's published sample key
11
+ # (MFA_DEVELOPMENT_SAMPLE_KEY), which everyone holds. It stands in for
12
+ # MFA_ENCRYPTION_KEY here: to use a key of your own in development, write it
13
+ # in place of this one. It is refused where the configuration is selected as
14
+ # production or staging, where NODE_ENV is either, and under
15
+ # `core.deployment.mode = "multi"`; boot warns while it is in use
16
+ # (mfa_development_sample_key_in_use). Read only while MFA_MODE installs MFA.
17
+ mfa.encryptionKeys = [{ key = "bzNjbzptZmE6ZGV2ZWxvcG1lbnQtc2FtcGxlLWtleSE=" }]
@@ -0,0 +1,8 @@
1
+ # Environment overlay for a development run whose mail goes to Mailpit
2
+ # (docker-compose.mailpit.yml). Loaded when CONFIG_ENV is "mailpit".
3
+ #
4
+ # The development overlay under another name: the template installs the
5
+ # sender that logs each code only where the configuration is selected as
6
+ # "development", and the SMTP sender under any other name. For development
7
+ # only; a deployment names its own relay.
8
+ include "development.conf"
@@ -2,14 +2,13 @@
2
2
  # Loaded when CONFIG_ENV (or NODE_ENV) is "production".
3
3
  # Values here override application.conf.
4
4
  #
5
- # Most production-sensitive values (SESSION_SECRET, the JWT signing key, REDIS
5
+ # Most production-sensitive values (SESSION_STORE_SECRET, the JWT signing key, REDIS
6
6
  # URLs, federation client secrets, etc.) should be supplied via environment
7
- # variables — see the ${?VAR} substitutions in application.conf.
7
+ # variables — see the ${?VAR} substitutions in application.conf and
8
+ # reference.conf.
8
9
  #
9
- # #407: this used to name OAUTH_JWT_SECRET as the typical example. That is the
10
- # HMAC secret, and it stopped being the default when EdDSA became one (#282) —
11
- # the shipped path is now a key pair delivered as files
12
- # (OAUTH_JWT_PRIVATE_KEY_PATH / OAUTH_JWT_PUBLIC_KEY_PATH), which
10
+ # The signing key is a key pair delivered as files
11
+ # (KEY_STORE_LOCAL_PRIVATE_KEY_PATH / KEY_STORE_LOCAL_PUBLIC_KEY_PATH), which
13
12
  # docker-compose.production.yml mounts as compose secrets.
14
13
  #
15
14
  # Override entries here only when a value must be fixed per-environment rather
@@ -0,0 +1,418 @@
1
+ # Defaults of the standalone template's own modules (src/modules.mts), each in
2
+ # the section named after its module, and of its own `adapters` and
3
+ # `mfaMode`, each key with its variable, named after its path, and the MFA
4
+ # routes' budget in each rate limiter's section (below `mfaMode`). Layered
5
+ # beneath application.conf and {env}.conf: set a deployment's own values
6
+ # there, not here. A value either file sets wins over
7
+ # the variable bound here, except for HTTP_PORT, HTTP_TRUST_PROXY,
8
+ # HTTP_CORS_ALLOWED_ORIGINS and REDIS_CLIENTS_URL / _PASSWORD, which
9
+ # application.conf binds again in its last lines, so they win over a value it
10
+ # sets above them.
11
+
12
+ # `logging`: trace | debug | info | warn | error | fatal | silent. `trace` and
13
+ # `debug` carry request-shaped detail; `silent` spares only the audit trail.
14
+ logging {
15
+ level = "info"
16
+ level = ${?LOGGING_LEVEL}
17
+ }
18
+
19
+ # `http`: the listener, the trusted forwarding hops, the readiness deadline and
20
+ # the CORS list.
21
+ http {
22
+ port = 3000
23
+ port = ${?HTTP_PORT}
24
+ # Express `trust proxy`: whether X-Forwarded-For may rewrite `req.ip`
25
+ # (every IP-keyed rate limit) and X-Forwarded-Proto may rewrite
26
+ # `req.protocol`.
27
+ #
28
+ # Four shapes, all of them Express's own:
29
+ #
30
+ # false trust nothing. `req.ip` is the socket peer. The default.
31
+ # <address list> trust these hops, and only these. An IP literal, a CIDR
32
+ # range (10.0.0.0/8, fc00::/7), or a named range
33
+ # (loopback, linklocal, uniquelocal). This is the only
34
+ # shape that says WHICH hop is trusted, and it is the one
35
+ # to reach for. Via env var, comma-separate:
36
+ # HTTP_TRUST_PROXY=10.0.0.0/8,192.168.0.0/16
37
+ # <hop count> trust that many hops back from the socket peer, e.g. 1
38
+ # for exactly one reverse proxy in front of this process.
39
+ # true trust every hop, i.e. believe the leftmost
40
+ # X-Forwarded-For entry from whoever opened the connection.
41
+ # Correct ONLY when nothing but the proxy can route to this
42
+ # process; otherwise a client that reaches it directly, or
43
+ # through one more hop than you accounted for, forges its
44
+ # own `req.ip` and with it any IP-keyed rate-limit identity.
45
+ #
46
+ # Entries are validated at boot: a hostname, a mistyped keyword or a
47
+ # malformed prefix length fails loudly rather than becoming a rule that
48
+ # never matches.
49
+ #
50
+ # An allowlist is a network control, not a cryptographic one. The edge must
51
+ # also STRIP inbound X-Forwarded-* headers rather than appending to them,
52
+ # and the hop between it and this process must not be reachable by anyone
53
+ # able to spoof a source address.
54
+ #
55
+ # Unrelated to `mtls.trustedProxies`, which shares this vocabulary but
56
+ # answers a different question (may this peer forward a client certificate?)
57
+ # and is deliberately not derived from this key.
58
+ trustProxy = false
59
+ trustProxy = ${?HTTP_TRUST_PROXY}
60
+ # Per-probe deadline for /readyz and the metrics scrape's probes. Keep it
61
+ # below the orchestrator's own probe timeout so an unreachable dependency
62
+ # answers 503 rather than letting the probe hang.
63
+ readinessTimeoutMs = 1000
64
+ readinessTimeoutMs = ${?HTTP_READINESS_TIMEOUT_MS}
65
+ # `cors`: the browser origins allowed to read the token, userinfo,
66
+ # revocation and discovery/JWKS responses. Empty (the default) means CORS
67
+ # is off.
68
+ #
69
+ # Matching against the `Origin` request header is exact string equality,
70
+ # so each entry is a bare origin: scheme, host, and a port only when it is
71
+ # not the scheme's default; no trailing slash, no path, no wildcard. https
72
+ # is required except for a loopback host (localhost, 127.0.0.0/8, [::1]).
73
+ # Each rule is checked at boot.
74
+ #
75
+ # cors.allowedOrigins = ["https://app.example.com", "http://localhost:5173"]
76
+ #
77
+ # No credentials are ever allowed: an allowlisted origin can read these
78
+ # responses and cannot use the browser's session cookie. This list confers
79
+ # no CSRF trust; that is `session.csrf.trustedOrigins`. The variable takes a
80
+ # comma-separated list.
81
+ cors {
82
+ allowedOrigins = []
83
+ allowedOrigins = ${?HTTP_CORS_ALLOWED_ORIGINS}
84
+ }
85
+ }
86
+
87
+ # `key-store`: the JWT signing key.
88
+ key-store {
89
+ provider = "local"
90
+ provider = ${?KEY_STORE_PROVIDER}
91
+ local {
92
+ # The default is asymmetric. HS256 leaves a relying party with two bad
93
+ # options: verify nothing (there is no public key to publish, so
94
+ # /.well-known/jwks.json has nothing to serve), or hold the shared
95
+ # secret, which also lets it mint tokens. EdDSA (Ed25519) publishes a
96
+ # real JWKS and keeps signing capability here.
97
+ #
98
+ # There is no key material default and no fallback: a deployment that
99
+ # configures nothing fails at boot naming the keys to set, rather than
100
+ # quietly signing with a guessable secret.
101
+ #
102
+ # openssl genpkey -algorithm ed25519 -out jwt-private.pem
103
+ # openssl pkey -in jwt-private.pem -pubout -out jwt-public.pem
104
+ #
105
+ # HS256 remains selectable (KEY_STORE_LOCAL_ALGORITHM=HS256) for
106
+ # deployments that verify in-process and publish no JWKS. It then requires
107
+ # KEY_STORE_LOCAL_SECRET with at least 32 bytes (256 bits) of random material
108
+ # (`openssl rand -hex 32`). Hex and base64 values are measured decoded, so
109
+ # a 32-character hex string is only 16 bytes and is refused.
110
+ algorithm = "EdDSA"
111
+ algorithm = ${?KEY_STORE_LOCAL_ALGORITHM}
112
+ kid = "v0"
113
+ kid = ${?KEY_STORE_LOCAL_KID}
114
+ secret = ${?KEY_STORE_LOCAL_SECRET}
115
+ privateKeyPath = ${?KEY_STORE_LOCAL_PRIVATE_KEY_PATH}
116
+ publicKeyPath = ${?KEY_STORE_LOCAL_PUBLIC_KEY_PATH}
117
+ privateKey = ${?KEY_STORE_LOCAL_PRIVATE_KEY}
118
+ publicKey = ${?KEY_STORE_LOCAL_PUBLIC_KEY}
119
+ # Key rotation is shaped per algorithm family. Asymmetric algorithms
120
+ # (RS256, ES256, EdDSA) use `previousKeys` (kid, publicKey or
121
+ # publicKeyPath, expiresAt); HS256 uses `previousSecrets` (kid, secret,
122
+ # expiresAt). The schema is a discriminated union and the key store
123
+ # refuses the other family's field, so the wrong shape fails at boot
124
+ # rather than being dropped at verification time. Neither is declared
125
+ # here: the default algorithm is EdDSA, and an empty
126
+ # `previousSecrets = []` under it would be exactly that wrong shape. Add
127
+ # the one matching your algorithm in your own layer.
128
+ }
129
+ }
130
+
131
+ # `redis-clients`: the one ioredis socket per replica every Redis-backed store
132
+ # shares. More than one replica needs a shared Redis 7.2+ here; localhost
133
+ # inside a container is the container itself.
134
+ redis-clients {
135
+ url = "redis://localhost:6379"
136
+ url = ${?REDIS_CLIENTS_URL}
137
+ password = ${?REDIS_CLIENTS_PASSWORD}
138
+ }
139
+
140
+ # `repositories`: the client registry, and the user repository's settings for
141
+ # each adapter it may be (`adapters.userRepository`). The two YAML paths are
142
+ # cwd-relative.
143
+ repositories {
144
+ client {
145
+ yaml {
146
+ path = "./config/clients.yaml"
147
+ path = ${?REPOSITORIES_CLIENT_YAML_PATH}
148
+ }
149
+ }
150
+ user {
151
+ yaml {
152
+ path = "./config/users.yaml"
153
+ path = ${?REPOSITORIES_USER_YAML_PATH}
154
+ }
155
+ # The Store's HTTP endpoints. Every URL here carries what a Store must
156
+ # never receive in the clear -- user credentials to the first two, a
157
+ # verified federation token and its claims to the link and the lookup, a
158
+ # subject's MFA enrollment witness to the last -- so each must be an
159
+ # absolute https URL; http:// is accepted only for a loopback host
160
+ # (localhost, 127.0.0.0/8, [::1]). Each must be the endpoint that answers:
161
+ # no request follows a 3xx. Boot fails otherwise.
162
+ http {
163
+ authenticateUrl = ${?REPOSITORIES_USER_HTTP_AUTHENTICATE_URL}
164
+ authenticateByTokenUrl = ${?REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL}
165
+ # Optional. With it, a signed-in user can link a second federated
166
+ # identity (GET /session/oauth/federation/<name>?link=1) and the Store
167
+ # decides; without it, link=1 is refused with `link_unsupported`.
168
+ linkFederatedIdentityUrl = ${?REPOSITORIES_USER_HTTP_LINK_FEDERATED_IDENTITY_URL}
169
+ # Optional. The Store's identity lookup for federation grants. With it,
170
+ # declare what the lookup covers, per registration, in a HOCON layer (a
171
+ # list has no environment form):
172
+ # federatedIdentityLookupCoverage = [
173
+ # { provider = "entra-files", issuer = "...", clientId = "...", requiredClaims = ["tid", "oid"] }
174
+ # ]
175
+ findSubjectByFederatedIdentityUrl = ${?REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL}
176
+ federatedIdentityLookupCoverage = []
177
+ # Optional. The Store's MFA enrollment witness endpoint: with it, the
178
+ # provider writes whether a subject has a second factor, which keeps a
179
+ # lost factor store from opening a first binding; without it, a boot
180
+ # with MFA on warns (`mfa_enrollment_witness_unwritable`). The Store
181
+ # must then answer `mfaEnrolled` on both authenticate URLs.
182
+ markMfaEnrolledUrl = ${?REPOSITORIES_USER_HTTP_MARK_MFA_ENROLLED_URL}
183
+ # Optional. Sent on every Store request as `Authorization: Bearer
184
+ # <token>`, so the Store can refuse any caller but this deployment;
185
+ # unset, none is sent. A bare token (no "Bearer " prefix) of at least 32
186
+ # bytes of key material -- `openssl rand -hex 32`. Boot fails on a weak,
187
+ # malformed or blank value. One token goes to every URL above.
188
+ bearerToken = ${?REPOSITORIES_USER_HTTP_BEARER_TOKEN}
189
+ # Positive integer, milliseconds, <= 2147483647.
190
+ timeout = 5000
191
+ timeout = ${?REPOSITORIES_USER_HTTP_TIMEOUT}
192
+ # Largest upstream response body accepted, in bytes. Positive integer.
193
+ maxResponseBytes = 1048576
194
+ maxResponseBytes = ${?REPOSITORIES_USER_HTTP_MAX_RESPONSE_BYTES}
195
+ }
196
+ }
197
+ }
198
+
199
+ # `standalone-in-memory-code-repository`: the in-process authorization-code
200
+ # repository (`adapters.codeRepository = "memory"`), single-replica only. Its
201
+ # codes' default lifetime, in positive whole seconds.
202
+ standalone-in-memory-code-repository {
203
+ defaultExpiresIn = 600
204
+ defaultExpiresIn = ${?STANDALONE_IN_MEMORY_CODE_REPOSITORY_DEFAULT_EXPIRES_IN}
205
+ }
206
+
207
+ # `audit-sink`: each sink's options, under the sink's name, for the sink
208
+ # `adapters.auditSink` selects -- `audit-sink { splunk-hec { ... } }` for a sink
209
+ # a deployment registers in the audit-sink module (src/modules.mts). The
210
+ # template's `logger` and core's `console` take none.
211
+ audit-sink {}
212
+
213
+ # `adapters`: the composition root's own section -- which adapter fills each
214
+ # slot. The template reads it before it chooses its modules, and hands it to
215
+ # no module. Each value is what the template ships.
216
+ #
217
+ # More than one replica needs every shared store on Redis: `memory` forks per
218
+ # replica, and `core.deployment.mode = "multi"` refuses each memory store by
219
+ # name. Each Redis store shares the one socket `redis-clients` opens.
220
+ adapters {
221
+ # The rate-limit counters: the OAuth endpoints' and the MFA routes'.
222
+ rateLimiter = "memory"
223
+ rateLimiter = ${?ADAPTERS_RATE_LIMITER}
224
+ # The counter behind /session/login's own attempt limit
225
+ # (session.rateLimit.login), and device verification's
226
+ # (device-grant.rateLimit) when the device grant is added. `memory` wires
227
+ # none: each counts per process, which `core.deployment.mode = "multi"`
228
+ # refuses. `redis` needs a server whose maxmemory-policy is `noeviction`.
229
+ attemptCounter = "memory"
230
+ attemptCounter = ${?ADAPTERS_ATTEMPT_COUNTER}
231
+ # The four user-session stores and the subject-level revocation pair. They
232
+ # must be on Redis whenever express-session's store is, or a restart leaves
233
+ # every browser a session whose user session is gone.
234
+ userSessionStores = "memory"
235
+ userSessionStores = ${?ADAPTERS_USER_SESSION_STORES}
236
+ # The RFC 7009 access-token denylist, which POST /oauth/revoke writes and
237
+ # verification reads. On Redis, so a token revoked on one replica is revoked
238
+ # on every one.
239
+ accessTokenDenylist = "redis"
240
+ accessTokenDenylist = ${?ADAPTERS_ACCESS_TOKEN_DENYLIST}
241
+ # The `jti` single-use record behind private_key_jwt client authentication.
242
+ replaySeenSet = "redis"
243
+ replaySeenSet = ${?ADAPTERS_REPLAY_SEEN_SET}
244
+ # Consent to a client that is not first-party: "none" wires no store and
245
+ # such clients are refused at /authorize; "memory" is single-replica only;
246
+ # "redis" keeps the consent records and parked requests on the shared
247
+ # socket (key namespace REDIS_CONSENT_STORE_KEY_PREFIX).
248
+ consentStore = "none"
249
+ consentStore = ${?ADAPTERS_CONSENT_STORE}
250
+ # The upstream IdP tokens held for a session. "redis" needs its encryption
251
+ # key, REDIS_FEDERATION_TOKEN_STORE_ENCRYPTION_KEY.
252
+ federationTokenStore = "memory"
253
+ federationTokenStore = ${?ADAPTERS_FEDERATION_TOKEN_STORE}
254
+ # Federation grants and acquisition's records, read only while
255
+ # `federation-grants.enabled`: "none" (the default) wires no store, and an
256
+ # enabled feature refuses boot naming the one it lacks; "memory" is
257
+ # single-replica only; "redis" is the shared socket. Redis grants need the
258
+ # subject boundary in Redis too (`userSessionStores = "redis"`): boot
259
+ # refuses the pairing with a memory one.
260
+ federationGrantStore = "none"
261
+ federationGrantStore = ${?ADAPTERS_FEDERATION_GRANT_STORE}
262
+ federationGrantIntentStore = "none"
263
+ federationGrantIntentStore = ${?ADAPTERS_FEDERATION_GRANT_INTENT_STORE}
264
+ # Where MFA factors ("memory", "redis" or "store") and MFA transactions
265
+ # ("memory" or "redis") are kept, for a composition that installs MFA.
266
+ mfaFactorStore = "memory"
267
+ mfaFactorStore = ${?ADAPTERS_MFA_FACTOR_STORE}
268
+ mfaTransactionStore = "memory"
269
+ mfaTransactionStore = ${?ADAPTERS_MFA_TRANSACTION_STORE}
270
+ # The authorization-code repository ("memory" loses codes on restart and
271
+ # across replicas).
272
+ codeRepository = "redis"
273
+ codeRepository = ${?ADAPTERS_CODE_REPOSITORY}
274
+ # The client registry (YAML), and the user repository: the Store's HTTP
275
+ # endpoints, or a YAML directory.
276
+ clientRepository = "yaml"
277
+ clientRepository = ${?ADAPTERS_CLIENT_REPOSITORY}
278
+ userRepository = "http"
279
+ userRepository = ${?ADAPTERS_USER_REPOSITORY}
280
+ # Where the audit trail goes: "logger" writes each event through the pino
281
+ # stream every other line takes; core's "console" writes the bare event.
282
+ # There is no "none": a name no sink is registered under refuses boot.
283
+ auditSink = "logger"
284
+ auditSink = ${?ADAPTERS_AUDIT_SINK}
285
+ }
286
+
287
+ # `mfaMode`: the composition root's own key -- whether the template installs
288
+ # MFA. Read before it chooses its modules, and handed to no module, as
289
+ # `adapters` is. "required" (the default: every password login has a second
290
+ # factor) and "optional" (users with a factor are challenged) install the MFA
291
+ # package's modules over the two MFA stores above, declare `mfa` in
292
+ # core.sessionRequirements.expected and write `mfa.mode` from this; "off"
293
+ # installs nothing of MFA. Anything else is refused before boot. A
294
+ # configuration that writes `mfa.mode` itself must write what this says, or
295
+ # boot is refused.
296
+ #
297
+ # With MFA on outside development, it needs its two stores on "redis" (or the
298
+ # factors in the "store"), MFA_ENCRYPTION_KEY, an SMTP relay
299
+ # (STANDARD_SMTP_MAIL_SENDER_HOST and _FROM) or the deployment's own mail
300
+ # sender, and a page served at MFA_PAGE_URL (/mfa unless set); a deployment
301
+ # that wants none of it sets MFA_MODE=off.
302
+ mfaMode = "required"
303
+ mfaMode = ${?MFA_MODE}
304
+
305
+ # The MFA routes' budget: the one setting this file writes in sections of
306
+ # modules other than the template's own. Every /session/mfa POST is limited
307
+ # per client address under the prefix `mfa` (`mfa:ip:<ip>`) by the wired
308
+ # limiter alone: the MFA package ships no budget of its own. Both limiters
309
+ # carry it, so switching `adapters.rateLimiter` keeps it; written here, beside
310
+ # each package's own defaults, the limiter not wired has it as a default
311
+ # rather than as a setting nothing reads. Without an entry the limiter's
312
+ # `defaultLimit` (60 per 60 s) applies. The MFA lock is separate and unchanged.
313
+ core-rate-limiter-memory.limits.mfa { limit = 60, windowSeconds = 300 }
314
+ redis-rate-limiter.limits.mfa { limit = 60, windowSeconds = 300 }
315
+
316
+ # The old paths of these sections refuse boot naming the new ones: `cors`,
317
+ # `oauth.jwt.signingKey`, `refreshTokenFamilyStore.redis`,
318
+ # `repositories.code` and `audit.sink`; the old adapter switches
319
+ # (`rateLimiter.adapter`, `oauth.code.adapter`, ...) are refused before the
320
+ # modules are chosen, and so are the variables renamed with them. What the
321
+ # resolution saw of each variable they renamed: each name null, then its value
322
+ # when set. Boot refuses an old name set unless its new name is set to the
323
+ # same value, and removes this section before it parses the configuration.
324
+ # Never write it in another layer.
325
+ renamed-variables {
326
+ LOG_LEVEL = null
327
+ LOG_LEVEL = ${?LOG_LEVEL}
328
+ LOGGING_LEVEL = null
329
+ LOGGING_LEVEL = ${?LOGGING_LEVEL}
330
+ CORS_ALLOWED_ORIGINS = null
331
+ CORS_ALLOWED_ORIGINS = ${?CORS_ALLOWED_ORIGINS}
332
+ HTTP_CORS_ALLOWED_ORIGINS = null
333
+ HTTP_CORS_ALLOWED_ORIGINS = ${?HTTP_CORS_ALLOWED_ORIGINS}
334
+ OAUTH_JWT_SIGNING_KEY_PROVIDER = null
335
+ OAUTH_JWT_SIGNING_KEY_PROVIDER = ${?OAUTH_JWT_SIGNING_KEY_PROVIDER}
336
+ KEY_STORE_PROVIDER = null
337
+ KEY_STORE_PROVIDER = ${?KEY_STORE_PROVIDER}
338
+ OAUTH_JWT_ALGORITHM = null
339
+ OAUTH_JWT_ALGORITHM = ${?OAUTH_JWT_ALGORITHM}
340
+ KEY_STORE_LOCAL_ALGORITHM = null
341
+ KEY_STORE_LOCAL_ALGORITHM = ${?KEY_STORE_LOCAL_ALGORITHM}
342
+ OAUTH_JWT_KID = null
343
+ OAUTH_JWT_KID = ${?OAUTH_JWT_KID}
344
+ KEY_STORE_LOCAL_KID = null
345
+ KEY_STORE_LOCAL_KID = ${?KEY_STORE_LOCAL_KID}
346
+ OAUTH_JWT_SECRET = null
347
+ OAUTH_JWT_SECRET = ${?OAUTH_JWT_SECRET}
348
+ KEY_STORE_LOCAL_SECRET = null
349
+ KEY_STORE_LOCAL_SECRET = ${?KEY_STORE_LOCAL_SECRET}
350
+ OAUTH_JWT_PRIVATE_KEY_PATH = null
351
+ OAUTH_JWT_PRIVATE_KEY_PATH = ${?OAUTH_JWT_PRIVATE_KEY_PATH}
352
+ KEY_STORE_LOCAL_PRIVATE_KEY_PATH = null
353
+ KEY_STORE_LOCAL_PRIVATE_KEY_PATH = ${?KEY_STORE_LOCAL_PRIVATE_KEY_PATH}
354
+ OAUTH_JWT_PUBLIC_KEY_PATH = null
355
+ OAUTH_JWT_PUBLIC_KEY_PATH = ${?OAUTH_JWT_PUBLIC_KEY_PATH}
356
+ KEY_STORE_LOCAL_PUBLIC_KEY_PATH = null
357
+ KEY_STORE_LOCAL_PUBLIC_KEY_PATH = ${?KEY_STORE_LOCAL_PUBLIC_KEY_PATH}
358
+ OAUTH_JWT_PRIVATE_KEY = null
359
+ OAUTH_JWT_PRIVATE_KEY = ${?OAUTH_JWT_PRIVATE_KEY}
360
+ KEY_STORE_LOCAL_PRIVATE_KEY = null
361
+ KEY_STORE_LOCAL_PRIVATE_KEY = ${?KEY_STORE_LOCAL_PRIVATE_KEY}
362
+ OAUTH_JWT_PUBLIC_KEY = null
363
+ OAUTH_JWT_PUBLIC_KEY = ${?OAUTH_JWT_PUBLIC_KEY}
364
+ KEY_STORE_LOCAL_PUBLIC_KEY = null
365
+ KEY_STORE_LOCAL_PUBLIC_KEY = ${?KEY_STORE_LOCAL_PUBLIC_KEY}
366
+ REFRESH_TOKEN_FAMILY_STORE_REDIS_URL = null
367
+ REFRESH_TOKEN_FAMILY_STORE_REDIS_URL = ${?REFRESH_TOKEN_FAMILY_STORE_REDIS_URL}
368
+ REDIS_CLIENTS_URL = null
369
+ REDIS_CLIENTS_URL = ${?REDIS_CLIENTS_URL}
370
+ REFRESH_TOKEN_FAMILY_STORE_REDIS_PASSWORD = null
371
+ REFRESH_TOKEN_FAMILY_STORE_REDIS_PASSWORD = ${?REFRESH_TOKEN_FAMILY_STORE_REDIS_PASSWORD}
372
+ REDIS_CLIENTS_PASSWORD = null
373
+ REDIS_CLIENTS_PASSWORD = ${?REDIS_CLIENTS_PASSWORD}
374
+ CLIENT_PATH = null
375
+ CLIENT_PATH = ${?CLIENT_PATH}
376
+ REPOSITORIES_CLIENT_YAML_PATH = null
377
+ REPOSITORIES_CLIENT_YAML_PATH = ${?REPOSITORIES_CLIENT_YAML_PATH}
378
+ CLIENT_USER_PATH = null
379
+ CLIENT_USER_PATH = ${?CLIENT_USER_PATH}
380
+ REPOSITORIES_USER_YAML_PATH = null
381
+ REPOSITORIES_USER_YAML_PATH = ${?REPOSITORIES_USER_YAML_PATH}
382
+ CLIENT_USER_AUTHENTICATE_URL = null
383
+ CLIENT_USER_AUTHENTICATE_URL = ${?CLIENT_USER_AUTHENTICATE_URL}
384
+ REPOSITORIES_USER_HTTP_AUTHENTICATE_URL = null
385
+ REPOSITORIES_USER_HTTP_AUTHENTICATE_URL = ${?REPOSITORIES_USER_HTTP_AUTHENTICATE_URL}
386
+ CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL = null
387
+ CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL = ${?CLIENT_USER_AUTHENTICATE_BY_TOKEN_URL}
388
+ REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL = null
389
+ REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL = ${?REPOSITORIES_USER_HTTP_AUTHENTICATE_BY_TOKEN_URL}
390
+ CLIENT_USER_LINK_FEDERATED_IDENTITY_URL = null
391
+ CLIENT_USER_LINK_FEDERATED_IDENTITY_URL = ${?CLIENT_USER_LINK_FEDERATED_IDENTITY_URL}
392
+ REPOSITORIES_USER_HTTP_LINK_FEDERATED_IDENTITY_URL = null
393
+ REPOSITORIES_USER_HTTP_LINK_FEDERATED_IDENTITY_URL = ${?REPOSITORIES_USER_HTTP_LINK_FEDERATED_IDENTITY_URL}
394
+ CLIENT_USER_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL = null
395
+ CLIENT_USER_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL = ${?CLIENT_USER_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL}
396
+ REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL = null
397
+ REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL = ${?REPOSITORIES_USER_HTTP_FIND_SUBJECT_BY_FEDERATED_IDENTITY_URL}
398
+ CLIENT_USER_BEARER_TOKEN = null
399
+ CLIENT_USER_BEARER_TOKEN = ${?CLIENT_USER_BEARER_TOKEN}
400
+ REPOSITORIES_USER_HTTP_BEARER_TOKEN = null
401
+ REPOSITORIES_USER_HTTP_BEARER_TOKEN = ${?REPOSITORIES_USER_HTTP_BEARER_TOKEN}
402
+ CLIENT_USER_TIMEOUT = null
403
+ CLIENT_USER_TIMEOUT = ${?CLIENT_USER_TIMEOUT}
404
+ REPOSITORIES_USER_HTTP_TIMEOUT = null
405
+ REPOSITORIES_USER_HTTP_TIMEOUT = ${?REPOSITORIES_USER_HTTP_TIMEOUT}
406
+ CLIENT_USER_MAX_RESPONSE_BYTES = null
407
+ CLIENT_USER_MAX_RESPONSE_BYTES = ${?CLIENT_USER_MAX_RESPONSE_BYTES}
408
+ REPOSITORIES_USER_HTTP_MAX_RESPONSE_BYTES = null
409
+ REPOSITORIES_USER_HTTP_MAX_RESPONSE_BYTES = ${?REPOSITORIES_USER_HTTP_MAX_RESPONSE_BYTES}
410
+ CLIENT_CODE_DEFAULT_EXPIRES_IN = null
411
+ CLIENT_CODE_DEFAULT_EXPIRES_IN = ${?CLIENT_CODE_DEFAULT_EXPIRES_IN}
412
+ STANDALONE_IN_MEMORY_CODE_REPOSITORY_DEFAULT_EXPIRES_IN = null
413
+ STANDALONE_IN_MEMORY_CODE_REPOSITORY_DEFAULT_EXPIRES_IN = ${?STANDALONE_IN_MEMORY_CODE_REPOSITORY_DEFAULT_EXPIRES_IN}
414
+ CLIENT_CODE_ENDPOINT_URI = null
415
+ CLIENT_CODE_ENDPOINT_URI = ${?CLIENT_CODE_ENDPOINT_URI}
416
+ CLIENT_CODE_PASSWORD = null
417
+ CLIENT_CODE_PASSWORD = ${?CLIENT_CODE_PASSWORD}
418
+ }
@@ -0,0 +1,36 @@
1
+ # Mailpit for the SMTP mail sender: a DEVELOPMENT overlay on
2
+ # docker-compose.yml, for a run with MFA on (the template's default, or
3
+ # MFA_MODE in .env) whose mail you can read.
4
+ #
5
+ # docker compose -f docker-compose.yml -f docker-compose.mailpit.yml up --build
6
+ #
7
+ # Mailpit keeps every mail the provider sends and delivers none; read them at
8
+ # http://localhost:8025. Never use it in production, where
9
+ # STANDARD_SMTP_MAIL_SENDER_* name a real relay. Leave every
10
+ # STANDARD_SMTP_MAIL_SENDER_* unset in .env for this run, USER and PASSWORD
11
+ # included: the overlay sets HOST, PORT, SECURE and FROM, not the credentials.
12
+ #
13
+ # The SMTP sender sends in plaintext (`none`) only to a loopback host, so
14
+ # Mailpit shares the app container's network namespace and listens on its
15
+ # localhost, and the app service publishes Mailpit's web UI. The configuration
16
+ # is selected as `mailpit` (config/mailpit.conf, the development overlay
17
+ # under another name), since under `development` the template installs the
18
+ # sender that logs each code instead. Under that name the MFA stores may not
19
+ # be kept in memory, so both are on the Redis docker-compose.yml runs.
20
+
21
+ services:
22
+ app:
23
+ ports:
24
+ - "127.0.0.1:8025:8025"
25
+ environment:
26
+ CONFIG_ENV: mailpit
27
+ ADAPTERS_MFA_FACTOR_STORE: redis
28
+ ADAPTERS_MFA_TRANSACTION_STORE: redis
29
+ STANDARD_SMTP_MAIL_SENDER_HOST: localhost
30
+ STANDARD_SMTP_MAIL_SENDER_PORT: "1025"
31
+ STANDARD_SMTP_MAIL_SENDER_SECURE: none
32
+ STANDARD_SMTP_MAIL_SENDER_FROM: auth@example.com
33
+
34
+ mailpit:
35
+ image: axllent/mailpit:v1.31.3
36
+ network_mode: service:app