@radicaltools/cli 0.2.0 → 0.3.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.md +353 -33
- package/dist/hub-catalogue/concern/concern-api-collections.radical +1136 -0
- package/dist/hub-catalogue/concern/concern-api-errors.radical +1180 -0
- package/dist/hub-catalogue/concern/concern-api-evolution.radical +1174 -0
- package/dist/hub-catalogue/concern/concern-api-idempotency.radical +1218 -0
- package/dist/hub-catalogue/concern/concern-api-resource-design.radical +1102 -0
- package/dist/hub-catalogue/concern/concern-api-style-guide.radical +1210 -0
- package/dist/hub-catalogue/concern/concern-architecture-style.radical +1268 -0
- package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
- package/dist/hub-catalogue/concern/concern-authentication.radical +895 -0
- package/dist/hub-catalogue/concern/concern-authorization.radical +1686 -0
- package/dist/hub-catalogue/concern/concern-availability.radical +1028 -0
- package/dist/hub-catalogue/concern/concern-backend-stack.radical +1037 -0
- package/dist/hub-catalogue/concern/concern-backup-recovery.radical +1560 -0
- package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
- package/dist/hub-catalogue/concern/concern-capacity.radical +915 -0
- package/dist/hub-catalogue/concern/concern-code-documentation.radical +1397 -0
- package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +1409 -0
- package/dist/hub-catalogue/concern/concern-code-review-branching.radical +1416 -0
- package/dist/hub-catalogue/concern/concern-code-style.radical +1058 -0
- package/dist/hub-catalogue/concern/concern-communication-style.radical +1508 -0
- package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
- package/dist/hub-catalogue/concern/concern-data-consistency.radical +1112 -0
- package/dist/hub-catalogue/concern/concern-data-store.radical +1282 -0
- package/dist/hub-catalogue/concern/concern-decomposition.radical +1318 -0
- package/dist/hub-catalogue/concern/concern-definition-of-done.radical +1214 -0
- package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +966 -0
- package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +1345 -0
- package/dist/hub-catalogue/concern/concern-deployment.radical +1203 -0
- package/dist/hub-catalogue/concern/concern-encryption.radical +1318 -0
- package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +1197 -0
- package/dist/hub-catalogue/concern/concern-eu-dora.radical +1321 -0
- package/dist/hub-catalogue/concern/concern-frontend-stack.radical +1647 -0
- package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
- package/dist/hub-catalogue/concern/concern-infrastructure.radical +2183 -0
- package/dist/hub-catalogue/concern/concern-integration-resilience.radical +1116 -0
- package/dist/hub-catalogue/concern/concern-messaging.radical +973 -0
- package/dist/hub-catalogue/concern/concern-module-boundaries.radical +867 -0
- package/dist/hub-catalogue/concern/concern-observability.radical +997 -0
- package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
- package/dist/hub-catalogue/concern/concern-personal-data.radical +1949 -0
- package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
- package/dist/hub-catalogue/concern/concern-rate-limiting.radical +1445 -0
- package/dist/hub-catalogue/concern/concern-release-versioning.radical +1358 -0
- package/dist/hub-catalogue/concern/concern-retention.radical +1399 -0
- package/dist/hub-catalogue/concern/concern-secrets.radical +1284 -0
- package/dist/hub-catalogue/concern/concern-secure-coding.radical +1379 -0
- package/dist/hub-catalogue/concern/concern-secure-development.radical +1245 -0
- package/dist/hub-catalogue/concern/concern-security-detection.radical +1153 -0
- package/dist/hub-catalogue/concern/concern-supply-chain.radical +1386 -0
- package/dist/hub-catalogue/concern/concern-technical-debt.radical +1450 -0
- package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +1145 -0
- package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +1440 -0
- package/dist/hub-catalogue/concern/concern-test-strategy.radical +1212 -0
- package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
- package/dist/index.js +12712 -7144
- package/package.json +5 -3
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hub": {
|
|
3
|
+
"id": "concern-authentication",
|
|
4
|
+
"category": "concern",
|
|
5
|
+
"name": "Authentication",
|
|
6
|
+
"description": "Who is calling: how people and other systems prove who they are, how long that lasts, and how it is taken back.",
|
|
7
|
+
"tags": [
|
|
8
|
+
"security",
|
|
9
|
+
"authentication",
|
|
10
|
+
"identity",
|
|
11
|
+
"sessions",
|
|
12
|
+
"oidc",
|
|
13
|
+
"mfa"
|
|
14
|
+
],
|
|
15
|
+
"requiredMetamodel": "c4-ddd-governance-builtin",
|
|
16
|
+
"concern": {
|
|
17
|
+
"id": "authentication",
|
|
18
|
+
"trigger": "LIST RELATIONS WHERE (source.type = \"person\" OR source.external = true) AND target.external != true AND (target.type = \"system\" OR target.type = \"container\" OR target.type = \"webapp\" OR target.type = \"component\")",
|
|
19
|
+
"applyTo": "target",
|
|
20
|
+
"why": "people or external systems reach these elements, so who is calling has to be decided.",
|
|
21
|
+
"group": "security"
|
|
22
|
+
},
|
|
23
|
+
"sources": [
|
|
24
|
+
{
|
|
25
|
+
"title": "OWASP ASVS 4.0.3, V2 Authentication and V3 Session Management",
|
|
26
|
+
"url": "https://owasp.org/www-project-application-security-verification-standard/"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"title": "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management",
|
|
30
|
+
"url": "https://pages.nist.gov/800-63-4/sp800-63b.html"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"title": "RFC 9700, Best Current Practice for OAuth 2.0 Security",
|
|
34
|
+
"url": "https://www.rfc-editor.org/rfc/rfc9700"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"title": "OpenID Connect Core 1.0",
|
|
38
|
+
"url": "https://openid.net/specs/openid-connect-core-1_0.html"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"title": "OWASP Password Storage Cheat Sheet",
|
|
42
|
+
"url": "https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"templateParams": [
|
|
46
|
+
{
|
|
47
|
+
"key": "IDENTITY",
|
|
48
|
+
"title": "Sign-in",
|
|
49
|
+
"label": "How do people sign in?",
|
|
50
|
+
"hint": "This decides most of what follows: who keeps the passwords, who slows down guessing, and who you depend on to sign in.",
|
|
51
|
+
"defaultValue": "idp",
|
|
52
|
+
"options": [
|
|
53
|
+
{
|
|
54
|
+
"value": "idp",
|
|
55
|
+
"label": "an external identity provider (OpenID Connect)",
|
|
56
|
+
"description": "Entra ID, Okta, Auth0, Keycloak or Google keep the passwords, MFA and lockout. Pick it for business users with a corporate directory, or whenever you would rather not own credentials."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"value": "own",
|
|
60
|
+
"label": "our own user store",
|
|
61
|
+
"description": "You keep accounts, password hashes, lockout and the breach response. Pick it only when a provider is ruled out (cost per user, data residency, offline use) and someone owns it."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"value": "none",
|
|
65
|
+
"label": "nobody signs in",
|
|
66
|
+
"description": "No person signs in; everything people reach is public and the same for everyone. Pick it for read-only public sites and tools; the decision records it so nothing comes to depend on who is calling. Other systems may still call with credentials of their own (next question)."
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"key": "MACHINE",
|
|
72
|
+
"title": "Other systems",
|
|
73
|
+
"label": "How do other systems call it?",
|
|
74
|
+
"hint": "A call from inside the network is not a call from a known system: each caller needs an identity of its own, and its own list of what it may do. Independent of how people sign in.",
|
|
75
|
+
"defaultValue": "oauth",
|
|
76
|
+
"options": [
|
|
77
|
+
{
|
|
78
|
+
"value": "oauth",
|
|
79
|
+
"label": "OAuth 2.0 client credentials",
|
|
80
|
+
"description": "Each caller gets a client id and short-lived tokens from the identity provider. Pick it when you have a provider and the callers can use OAuth."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"value": "mtls",
|
|
84
|
+
"label": "mutual TLS",
|
|
85
|
+
"description": "Each caller holds its own certificate; the connection proves who it is. Pick it inside a service mesh or between companies with a PKI."
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"value": "keys",
|
|
89
|
+
"label": "API keys, one per calling system",
|
|
90
|
+
"description": "Simple to hand out and to revoke one by one; they must be rotated and kept out of logs. Pick it for a few partners without OAuth."
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"value": "none",
|
|
94
|
+
"label": "none",
|
|
95
|
+
"description": "No other system calls it; only people reach it. Pick it when the model shows no other system calling."
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"key": "STEP_UP",
|
|
101
|
+
"title": "Second factor",
|
|
102
|
+
"label": "Do some operations need a second factor?",
|
|
103
|
+
"hint": "A stolen session alone should not be enough for the operations that do the most harm: changing permissions, moving money, exporting data. Only when people sign in (not with nobody signs in).",
|
|
104
|
+
"defaultValue": "yes",
|
|
105
|
+
"options": [
|
|
106
|
+
{
|
|
107
|
+
"value": "yes",
|
|
108
|
+
"label": "a second factor for risky operations",
|
|
109
|
+
"description": "Risky operations ask for a second factor confirmed in the last 5 minutes (step-up). Pick it when any operation moves money, changes rights or exports data."
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"value": "no",
|
|
113
|
+
"label": "the session alone",
|
|
114
|
+
"description": "A signed-in session may do everything its account may. Pick it only when no operation is worth more than the session itself."
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"key": "SESSION_MINUTES",
|
|
120
|
+
"label": "How long may a session stay idle (minutes)?",
|
|
121
|
+
"defaultValue": "30",
|
|
122
|
+
"type": "number"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"key": "REVOKE_SECONDS",
|
|
126
|
+
"label": "How fast must a revoked session stop working (seconds)?",
|
|
127
|
+
"defaultValue": "60",
|
|
128
|
+
"type": "number"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"key": "PRIVILEGED_OPS",
|
|
132
|
+
"label": "Which operations need a second factor? (a second factor for risky operations only)",
|
|
133
|
+
"defaultValue": "changing permissions, exporting data, payouts"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"nodes": [
|
|
138
|
+
{
|
|
139
|
+
"id": "need",
|
|
140
|
+
"type": "need",
|
|
141
|
+
"label": "Callers are who they claim",
|
|
142
|
+
"x": 0,
|
|
143
|
+
"y": 0,
|
|
144
|
+
"kind": "brief",
|
|
145
|
+
"source": "Hub concern pack: Authentication",
|
|
146
|
+
"description": "People and other systems reach this element from outside. Whatever it does on their behalf rests on knowing who they are: a stolen or guessed credential, a session that outlives its user, a token that cannot be taken back, or a call from a system nobody vouched for each turns into data read or changed by the wrong party. Sign-in also has to stay usable, and the evidence of who did what has to hold up after an incident. The snippets assume the application under src/ (src/app exports the router's table, src/auth the sign-in code, src/audit the audit store) and the tests under tests/ with their fixtures in tests/auth."
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"id": "req-reject",
|
|
150
|
+
"type": "requirement",
|
|
151
|
+
"label": "Unauthenticated calls refused",
|
|
152
|
+
"x": 260,
|
|
153
|
+
"y": 0,
|
|
154
|
+
"ears_type": "unwanted-behaviour",
|
|
155
|
+
"unwanted_condition": "a request to an operation that is not on the public list carries no credential, or an expired or revoked one",
|
|
156
|
+
"action": "refuse it with 401 before any part of the operation runs, and say nothing about whether the account exists",
|
|
157
|
+
"rationale": "An operation forgotten on the protected side is the most common authentication flaw; the public list makes the exceptions explicit (ASVS V2.1, V3.1).",
|
|
158
|
+
"hubWhen": {
|
|
159
|
+
"IDENTITY": [
|
|
160
|
+
"idp",
|
|
161
|
+
"own"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "req-idle",
|
|
167
|
+
"type": "requirement",
|
|
168
|
+
"label": "Idle sessions end",
|
|
169
|
+
"x": 260,
|
|
170
|
+
"y": 130,
|
|
171
|
+
"ears_type": "event-driven",
|
|
172
|
+
"trigger": "a session has seen no request for {{SESSION_MINUTES}} minutes",
|
|
173
|
+
"action": "end it, so that the next request has to sign in again",
|
|
174
|
+
"rationale": "A session left open on a shared or lost device is a credential nobody is watching (ASVS V3.3; NIST SP 800-63B-4 sec. 2.2.3, inactivity timeout).",
|
|
175
|
+
"hubWhen": {
|
|
176
|
+
"IDENTITY": [
|
|
177
|
+
"idp",
|
|
178
|
+
"own"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"id": "req-revoke",
|
|
184
|
+
"type": "requirement",
|
|
185
|
+
"label": "Revoked sessions stop",
|
|
186
|
+
"x": 260,
|
|
187
|
+
"y": 260,
|
|
188
|
+
"ears_type": "event-driven",
|
|
189
|
+
"trigger": "a user signs out, or an administrator revokes one session or every session of an account",
|
|
190
|
+
"action": "refuse that session's credentials within {{REVOKE_SECONDS}} seconds on every instance, tokens already issued included",
|
|
191
|
+
"rationale": "Self-contained tokens are valid until they expire unless revocation is designed in; this bounds how long a stolen one keeps working (RFC 9700 4.14).",
|
|
192
|
+
"hubWhen": {
|
|
193
|
+
"IDENTITY": [
|
|
194
|
+
"idp",
|
|
195
|
+
"own"
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"id": "req-audit",
|
|
201
|
+
"type": "requirement",
|
|
202
|
+
"label": "Sign-ins are audited",
|
|
203
|
+
"x": 260,
|
|
204
|
+
"y": 390,
|
|
205
|
+
"ears_type": "ubiquitous",
|
|
206
|
+
"action": "record every sign-in, failed sign-in, sign-out and revocation in the audit trail, with the account, the time, the client and the source address, and never record the credential itself; where the trail is kept and for how long is decided in the Audit trail pack",
|
|
207
|
+
"rationale": "After an incident this is the record of who was in; with the credential in it, the log becomes the leak (ASVS V7.1).",
|
|
208
|
+
"hubWhen": {
|
|
209
|
+
"IDENTITY": [
|
|
210
|
+
"idp",
|
|
211
|
+
"own"
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "req-lockout",
|
|
217
|
+
"type": "requirement",
|
|
218
|
+
"label": "Guessing is slowed",
|
|
219
|
+
"x": 260,
|
|
220
|
+
"y": 520,
|
|
221
|
+
"ears_type": "unwanted-behaviour",
|
|
222
|
+
"unwanted_condition": "five sign-ins to one account fail within 15 minutes",
|
|
223
|
+
"action": "delay further attempts on that account and from that source address, longer after each failure up to 15 minutes, and tell the account's owner",
|
|
224
|
+
"rationale": "With your own user store, credential stuffing and guessing hit you directly; an identity provider does this for you (NIST SP 800-63B-4 sec. 3.2.2, rate limiting).",
|
|
225
|
+
"hubWhen": {
|
|
226
|
+
"IDENTITY": [
|
|
227
|
+
"own"
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "req-passwords",
|
|
233
|
+
"type": "requirement",
|
|
234
|
+
"label": "Passwords stored as hashes",
|
|
235
|
+
"x": 260,
|
|
236
|
+
"y": 650,
|
|
237
|
+
"ears_type": "ubiquitous",
|
|
238
|
+
"action": "store passwords only as Argon2id hashes (at least 19 MiB memory, 2 iterations, 1 lane), accept passwords of 8 to 64 characters, and refuse one found in known breaches",
|
|
239
|
+
"rationale": "A leaked user table must not become a list of working passwords; length and breach checks beat composition rules (OWASP Password Storage Cheat Sheet; NIST SP 800-63B-4 sec. 3.1.1.2, password verifiers).",
|
|
240
|
+
"hubWhen": {
|
|
241
|
+
"IDENTITY": [
|
|
242
|
+
"own"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"id": "req-stepup",
|
|
248
|
+
"type": "requirement",
|
|
249
|
+
"label": "Second factor for risky operations",
|
|
250
|
+
"x": 260,
|
|
251
|
+
"y": 780,
|
|
252
|
+
"ears_type": "event-driven",
|
|
253
|
+
"trigger": "a signed-in user starts one of: {{PRIVILEGED_OPS}}",
|
|
254
|
+
"action": "require a second factor confirmed within the last 5 minutes before running it",
|
|
255
|
+
"rationale": "A stolen session alone must not be enough for the operations that do the most harm (ASVS V2.8, V4.3).",
|
|
256
|
+
"hubWhen": {
|
|
257
|
+
"IDENTITY": [
|
|
258
|
+
"idp",
|
|
259
|
+
"own"
|
|
260
|
+
],
|
|
261
|
+
"STEP_UP": [
|
|
262
|
+
"yes"
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "req-machine",
|
|
268
|
+
"type": "requirement",
|
|
269
|
+
"label": "Calling systems authenticate",
|
|
270
|
+
"x": 260,
|
|
271
|
+
"y": 910,
|
|
272
|
+
"ears_type": "event-driven",
|
|
273
|
+
"trigger": "another system calls the element",
|
|
274
|
+
"action": "require it to authenticate with {{MACHINE}}, with credentials of its own that expire or are rotated within 90 days, and let each caller run only the operations listed for it",
|
|
275
|
+
"rationale": "A call from inside the network is not a call from a known system; each caller authenticates as a client of its own (RFC 9700 2.5) and holds only the privileges listed for it (RFC 9700 2.3).",
|
|
276
|
+
"hubWhen": {
|
|
277
|
+
"MACHINE": [
|
|
278
|
+
"oauth",
|
|
279
|
+
"mtls",
|
|
280
|
+
"keys"
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": "req-public",
|
|
286
|
+
"type": "requirement",
|
|
287
|
+
"label": "Public by design",
|
|
288
|
+
"x": 260,
|
|
289
|
+
"y": 1040,
|
|
290
|
+
"ears_type": "ubiquitous",
|
|
291
|
+
"action": "offer people no sign-in and no session, keep no person's credential, and run for anyone who reaches it only operations that are safe for anyone",
|
|
292
|
+
"rationale": "Nobody signs in, so nothing may depend on knowing which person is calling; this makes that a requirement instead of an accident.",
|
|
293
|
+
"hubWhen": {
|
|
294
|
+
"IDENTITY": [
|
|
295
|
+
"none"
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"id": "sc-reject",
|
|
301
|
+
"type": "scenario",
|
|
302
|
+
"label": "Call without credential",
|
|
303
|
+
"x": 520,
|
|
304
|
+
"y": 0,
|
|
305
|
+
"given": "an operation that is not on the public list",
|
|
306
|
+
"when": "it is called without a credential, with an expired one and with a revoked one",
|
|
307
|
+
"then": "each call is refused with 401 and the operation leaves no trace",
|
|
308
|
+
"hubWhen": {
|
|
309
|
+
"IDENTITY": [
|
|
310
|
+
"idp",
|
|
311
|
+
"own"
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"id": "sc-idle",
|
|
317
|
+
"type": "scenario",
|
|
318
|
+
"label": "Idle session ends",
|
|
319
|
+
"x": 520,
|
|
320
|
+
"y": 130,
|
|
321
|
+
"given": "a signed-in session",
|
|
322
|
+
"when": "no request comes for {{SESSION_MINUTES}} minutes and then one does",
|
|
323
|
+
"then": "the request is refused and asks to sign in again",
|
|
324
|
+
"hubWhen": {
|
|
325
|
+
"IDENTITY": [
|
|
326
|
+
"idp",
|
|
327
|
+
"own"
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"id": "sc-revoke",
|
|
333
|
+
"type": "scenario",
|
|
334
|
+
"label": "Revoked session stops",
|
|
335
|
+
"x": 520,
|
|
336
|
+
"y": 260,
|
|
337
|
+
"given": "a signed-in session on two instances",
|
|
338
|
+
"when": "the user signs out on one of them",
|
|
339
|
+
"then": "within {{REVOKE_SECONDS}} seconds both instances refuse its credentials",
|
|
340
|
+
"hubWhen": {
|
|
341
|
+
"IDENTITY": [
|
|
342
|
+
"idp",
|
|
343
|
+
"own"
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"id": "sc-audit",
|
|
349
|
+
"type": "scenario",
|
|
350
|
+
"label": "Sign-in leaves a record",
|
|
351
|
+
"x": 520,
|
|
352
|
+
"y": 390,
|
|
353
|
+
"given": "an account",
|
|
354
|
+
"when": "it signs in, fails to sign in, signs out and has a session revoked",
|
|
355
|
+
"then": "the audit trail holds the four events with account, time, client and address, and no credential",
|
|
356
|
+
"hubWhen": {
|
|
357
|
+
"IDENTITY": [
|
|
358
|
+
"idp",
|
|
359
|
+
"own"
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"id": "sc-lockout",
|
|
365
|
+
"type": "scenario",
|
|
366
|
+
"label": "Guessing slowed",
|
|
367
|
+
"x": 520,
|
|
368
|
+
"y": 520,
|
|
369
|
+
"given": "an account",
|
|
370
|
+
"when": "five sign-ins to it fail within 15 minutes",
|
|
371
|
+
"then": "the sixth attempt is delayed and the owner is told",
|
|
372
|
+
"hubWhen": {
|
|
373
|
+
"IDENTITY": [
|
|
374
|
+
"own"
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"id": "sc-passwords",
|
|
380
|
+
"type": "scenario",
|
|
381
|
+
"label": "Breached password refused",
|
|
382
|
+
"x": 520,
|
|
383
|
+
"y": 650,
|
|
384
|
+
"given": "a user setting a password",
|
|
385
|
+
"when": "the password is in a list of breached passwords, and then one that is not",
|
|
386
|
+
"then": "the first is refused; the second is stored as an Argon2id hash, never as the text",
|
|
387
|
+
"hubWhen": {
|
|
388
|
+
"IDENTITY": [
|
|
389
|
+
"own"
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"id": "sc-stepup",
|
|
395
|
+
"type": "scenario",
|
|
396
|
+
"label": "Risky operation asks again",
|
|
397
|
+
"x": 520,
|
|
398
|
+
"y": 780,
|
|
399
|
+
"given": "a signed-in user whose second factor is older than 5 minutes",
|
|
400
|
+
"when": "the user starts one of: {{PRIVILEGED_OPS}}",
|
|
401
|
+
"then": "it runs only after the second factor is confirmed",
|
|
402
|
+
"hubWhen": {
|
|
403
|
+
"IDENTITY": [
|
|
404
|
+
"idp",
|
|
405
|
+
"own"
|
|
406
|
+
],
|
|
407
|
+
"STEP_UP": [
|
|
408
|
+
"yes"
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"id": "sc-machine",
|
|
414
|
+
"type": "scenario",
|
|
415
|
+
"label": "Unknown system refused",
|
|
416
|
+
"x": 520,
|
|
417
|
+
"y": 910,
|
|
418
|
+
"given": "a calling system with its own identity and list of operations",
|
|
419
|
+
"when": "it calls an operation on its list, one off its list, and a third system calls without authenticating",
|
|
420
|
+
"then": "only the first call runs",
|
|
421
|
+
"hubWhen": {
|
|
422
|
+
"MACHINE": [
|
|
423
|
+
"oauth",
|
|
424
|
+
"mtls",
|
|
425
|
+
"keys"
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"id": "sc-public",
|
|
431
|
+
"type": "scenario",
|
|
432
|
+
"label": "No sign-in surface",
|
|
433
|
+
"x": 520,
|
|
434
|
+
"y": 1040,
|
|
435
|
+
"given": "the element as deployed",
|
|
436
|
+
"when": "every route or command it offers is listed",
|
|
437
|
+
"then": "none signs a person in, keeps a session or stores a person's credential",
|
|
438
|
+
"hubWhen": {
|
|
439
|
+
"IDENTITY": [
|
|
440
|
+
"none"
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"id": "adr-idp",
|
|
446
|
+
"type": "adr",
|
|
447
|
+
"label": "Users sign in through an identity provider",
|
|
448
|
+
"x": 780,
|
|
449
|
+
"y": 0,
|
|
450
|
+
"concern": "authentication",
|
|
451
|
+
"status": "accepted",
|
|
452
|
+
"date": "",
|
|
453
|
+
"context": "People or other systems reach this element from outside, so it must know who is calling before it acts for them. The forces: credentials leak and get guessed (credential stuffing tries billions of leaked pairs); sessions outlive the person on a shared or lost device; self-contained tokens stay valid until they expire unless revocation is designed in; other systems call too, and a call from inside the network is not a call from a known system; and after an incident the record of who did what has to hold.",
|
|
454
|
+
"decision": "Users sign in through an external identity provider with OpenID Connect (authorization code flow with PKCE); we store no password. Sessions end after {{SESSION_MINUTES}} minutes without a request and are revoked within {{REVOKE_SECONDS}} seconds. Revocation is a server-side check on every instance (a shared session or revocation store, or token introspection), not the token's lifetime: providers keep the shortest access-token lifetime at minutes, not seconds (Entra ID 10 minutes at the least), so access tokens live 5 to 10 minutes and refresh tokens are rotated on use. Calls from other systems: {{MACHINE}}. Step-up: {{STEP_UP}}. Operations open without sign-in are on a public list kept in the code. Choosing the provider: the one the users' organisation already runs (Entra ID, Okta, Google Workspace) for business users; Auth0, Cognito or Keycloak for consumers, by cost per active user and where the data may be kept.",
|
|
455
|
+
"consequences": "• No passwords to store, reset or leak; MFA, lockout and breached-password checks come from the provider.\n• The provider is on the sign-in path: when it is down nobody new signs in, sessions already open keep working until they expire.\n• Revocation within {{REVOKE_SECONDS}} s means a revocation store or introspection call on every request, a little latency and one more thing every instance must reach.\n• Who may do what (authorisation) is still yours to design: a valid token says who, not what.",
|
|
456
|
+
"alternatives": "1. Our own user store: full control of the experience, but you own password storage, lockout, MFA and breach response.\n2. Server-side sessions only (cookies): simple for one web app, awkward for APIs called by other systems and mobile clients.\n3. Long-lived tokens without revocation: fewer calls to the provider, but a stolen token works until it expires.",
|
|
457
|
+
"hubWhen": {
|
|
458
|
+
"IDENTITY": [
|
|
459
|
+
"idp"
|
|
460
|
+
]
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"id": "adr-own",
|
|
465
|
+
"type": "adr",
|
|
466
|
+
"label": "Users sign in with our own user store",
|
|
467
|
+
"x": 780,
|
|
468
|
+
"y": 130,
|
|
469
|
+
"concern": "authentication",
|
|
470
|
+
"status": "accepted",
|
|
471
|
+
"date": "",
|
|
472
|
+
"context": "People or other systems reach this element from outside, so it must know who is calling before it acts for them. The forces: credentials leak and get guessed (credential stuffing tries billions of leaked pairs); sessions outlive the person on a shared or lost device; self-contained tokens stay valid until they expire unless revocation is designed in; other systems call too, and a call from inside the network is not a call from a known system; and after an incident the record of who did what has to hold.",
|
|
473
|
+
"decision": "Users sign in with an account in our own user store: passwords kept as Argon2id hashes, failed attempts slowed per account and per address, breached passwords refused (Have I Been Pwned range API). Sessions end after {{SESSION_MINUTES}} minutes without a request and are revoked within {{REVOKE_SECONDS}} seconds; session state lives on the server, so revoking is deleting it. Calls from other systems: {{MACHINE}}. Step-up: {{STEP_UP}}. Operations open without sign-in are on a public list kept in the code. Use the framework's maintained identity library (ASP.NET Core Identity, Spring Security, Devise, Better Auth) rather than code of our own.",
|
|
474
|
+
"consequences": "• We own the whole of sign-in: password storage, resets, lockout, MFA and the response to a breach.\n• No third party on the sign-in path, and no per-user cost of a provider.\n• Server-side sessions make revocation immediate, but every instance needs the session store.\n• Single sign-on with customers' own identity providers is a later project.",
|
|
475
|
+
"alternatives": "1. An external identity provider (OpenID Connect): no passwords to keep, MFA and lockout included, but a dependency on the sign-in path and a cost per user.\n2. Passwordless sign-in by e-mail link or passkeys only: nothing to guess, but sign-in is as safe as the mailbox or needs passkey support everywhere.",
|
|
476
|
+
"hubWhen": {
|
|
477
|
+
"IDENTITY": [
|
|
478
|
+
"own"
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"id": "adr-none",
|
|
484
|
+
"type": "adr",
|
|
485
|
+
"label": "Nobody signs in",
|
|
486
|
+
"x": 780,
|
|
487
|
+
"y": 260,
|
|
488
|
+
"concern": "authentication",
|
|
489
|
+
"status": "accepted",
|
|
490
|
+
"date": "",
|
|
491
|
+
"context": "People or other systems reach this element from outside, so it must know who is calling before it acts for them. The forces: credentials leak and get guessed (credential stuffing tries billions of leaked pairs); sessions outlive the person on a shared or lost device; self-contained tokens stay valid until they expire unless revocation is designed in; other systems call too, and a call from inside the network is not a call from a known system; and after an incident the record of who did what has to hold. Here no person needs to be told apart: the element serves the same to everyone who reaches it.",
|
|
492
|
+
"decision": "No person signs in: the element has no sign-in and no session for people and keeps no person's credential; everything people reach is public and safe for anyone. Other systems: {{MACHINE}}. Any credential the element checks belongs to a calling system, never to a person. Anything that would need to know which person is calling is out of scope until this decision is superseded.",
|
|
493
|
+
"consequences": "• Nothing to steal at sign-in and nothing to revoke for people.\n• Any feature that depends on who the user is (their own data, rights, an audit of who did what) needs this decision superseded first.\n• Abuse is limited by what the element offers, not by who asks: rate limits and the shape of the operations matter more.",
|
|
494
|
+
"alternatives": "1. Sign-in through an external identity provider, kept for later.\n2. A shared secret for everyone: no real identity, and a secret everyone knows is not one.",
|
|
495
|
+
"hubWhen": {
|
|
496
|
+
"IDENTITY": [
|
|
497
|
+
"none"
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"id": "adr-stepup",
|
|
503
|
+
"type": "adr",
|
|
504
|
+
"label": "A second factor for risky operations",
|
|
505
|
+
"x": 780,
|
|
506
|
+
"y": 390,
|
|
507
|
+
"concern": "authentication",
|
|
508
|
+
"status": "accepted",
|
|
509
|
+
"date": "",
|
|
510
|
+
"context": "People or other systems reach this element from outside, so it must know who is calling before it acts for them. The forces: credentials leak and get guessed (credential stuffing tries billions of leaked pairs); sessions outlive the person on a shared or lost device; self-contained tokens stay valid until they expire unless revocation is designed in; other systems call too, and a call from inside the network is not a call from a known system; and after an incident the record of who did what has to hold.",
|
|
511
|
+
"decision": "A second factor confirmed within the last 5 minutes is required before each of: {{PRIVILEGED_OPS}}. The operations are listed in one place in the code (a set the request pipeline checks), the time of the last second-factor confirmation is kept with the session, and the check runs on the server before the operation, never only in the interface. With an identity provider, the step-up is an OpenID Connect request with acr_values or max_age=300 and the id token's auth_time is checked; with our own store, the TOTP or passkey verification sets the confirmation time.",
|
|
512
|
+
"consequences": "• A stolen session alone cannot move money, change rights or export data.\n• Each listed operation gains a prompt; the list must stay short and known, or users learn to click through.\n• The confirmation time is part of the session state and travels with it across instances.",
|
|
513
|
+
"alternatives": "1. The session alone: no prompts, and a stolen session is worth everything the account may do.\n2. A second factor at every sign-in only: stronger sign-in, but a session stolen after it is as powerful as before.",
|
|
514
|
+
"hubWhen": {
|
|
515
|
+
"IDENTITY": [
|
|
516
|
+
"idp",
|
|
517
|
+
"own"
|
|
518
|
+
],
|
|
519
|
+
"STEP_UP": [
|
|
520
|
+
"yes"
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"id": "adr-no-stepup",
|
|
526
|
+
"type": "adr",
|
|
527
|
+
"label": "The session alone is enough",
|
|
528
|
+
"x": 780,
|
|
529
|
+
"y": 520,
|
|
530
|
+
"concern": "authentication",
|
|
531
|
+
"status": "accepted",
|
|
532
|
+
"date": "",
|
|
533
|
+
"context": "People or other systems reach this element from outside, so it must know who is calling before it acts for them. The forces: credentials leak and get guessed (credential stuffing tries billions of leaked pairs); sessions outlive the person on a shared or lost device; self-contained tokens stay valid until they expire unless revocation is designed in; other systems call too, and a call from inside the network is not a call from a known system; and after an incident the record of who did what has to hold.",
|
|
534
|
+
"decision": "No operation asks for a second factor beyond sign-in: a signed-in session may do everything its account may. This holds while no operation moves money, changes rights or exports data in bulk; the first such operation supersedes this decision.",
|
|
535
|
+
"consequences": "• Nothing to prompt for and nothing to keep about the second factor.\n• A stolen session is worth everything the account may do, so the idle and revocation limits carry the weight.\n• The first risky operation needs this decision superseded, not an exception.",
|
|
536
|
+
"alternatives": "1. A second factor for risky operations: one more prompt where it matters.\n2. Shorter sessions for everyone instead: cheaper to build, and annoying for everyone instead of for the few risky operations.",
|
|
537
|
+
"hubWhen": {
|
|
538
|
+
"IDENTITY": [
|
|
539
|
+
"idp",
|
|
540
|
+
"own"
|
|
541
|
+
],
|
|
542
|
+
"STEP_UP": [
|
|
543
|
+
"no"
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
"id": "ff-reject",
|
|
549
|
+
"type": "fitness-fn",
|
|
550
|
+
"label": "Unauthenticated calls refused",
|
|
551
|
+
"x": 1040,
|
|
552
|
+
"y": 0,
|
|
553
|
+
"characteristic": "security",
|
|
554
|
+
"scope": "atomic",
|
|
555
|
+
"cadence": "triggered",
|
|
556
|
+
"trigger": "pull-request",
|
|
557
|
+
"invocation": "automated",
|
|
558
|
+
"description": "A test lists the element's operations from its router (not from a list kept by hand), calls each without a credential, with an expired token and with a token of a session revoked in the test, and expects 401 from every one that is not on the public list. A new operation fails the test until it is protected or added to the public list, which shows up in the pull request.\n\nThreshold: Every operation not on the public list answers 401 without a credential, with an expired one and with a revoked one; 0 operations outside the public list answer anything else\n\nTool: Vitest with supertest (or the test runner and HTTP client of your stack: JUnit with MockMvc, xUnit with WebApplicationFactory, RSpec request specs)\n\n```ts\nimport request from 'supertest'\nimport { app, routes } from '../src/app' // routes: the router's table\nimport { PUBLIC } from '../src/auth/publicRoutes' // the public list, in the code\nimport { EXPIRED, signIn, signOut } from './auth/fixtures'\n\nconst revoked = await signIn()\nawait signOut(revoked)\n\ndescribe.each(routes.filter((r) => !PUBLIC.has(`${r.method} ${r.path}`)))('$method $path', (route) => {\n it('refuses a call without a credential', async () => {\n await request(app)[route.method.toLowerCase()](route.example).expect(401)\n })\n it('refuses an expired token', async () => {\n await request(app)[route.method.toLowerCase()](route.example).set('Authorization', `Bearer ${EXPIRED}`).expect(401)\n })\n it('refuses a revoked session', async () => {\n await request(app)[route.method.toLowerCase()](route.example).set('Authorization', `Bearer ${revoked}`).expect(401)\n })\n})\n```",
|
|
559
|
+
"hubWhen": {
|
|
560
|
+
"IDENTITY": [
|
|
561
|
+
"idp",
|
|
562
|
+
"own"
|
|
563
|
+
]
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
"id": "ff-session",
|
|
568
|
+
"type": "fitness-fn",
|
|
569
|
+
"label": "Session limits hold",
|
|
570
|
+
"x": 1040,
|
|
571
|
+
"y": 130,
|
|
572
|
+
"characteristic": "security",
|
|
573
|
+
"scope": "atomic",
|
|
574
|
+
"cadence": "triggered",
|
|
575
|
+
"trigger": "pull-request",
|
|
576
|
+
"invocation": "automated",
|
|
577
|
+
"description": "An integration test signs in on two instances, revokes the session on one and polls the other until it refuses, failing past {{REVOKE_SECONDS}} seconds. A second test runs against instances started with the idle timeout set to 5 seconds (the same setting that is {{SESSION_MINUTES}} minutes in production, read from the environment), waits 6 seconds and expects the next request to be refused; fake timers cannot move the server's clock, so the limit itself is made short for the drill. Where the session alone is enough, these two limits are the whole control, so this test is what keeps that decision honest.\n\nThreshold: An idle session ends after {{SESSION_MINUTES}} minutes; a revoked one is refused within {{REVOKE_SECONDS}} seconds on every instance\n\nTool: Vitest against two instances started by Testcontainers or docker compose with SESSION_IDLE_SECONDS=5 (or the equivalent of your stack)\n\n```ts\nimport { instanceA, instanceB, signIn, signOut, call, sleep } from './auth/instances' // started with SESSION_IDLE_SECONDS=5\nimport { REVOKE_SECONDS } from './auth/limits' // {{REVOKE_SECONDS}}, from the decision\n\nit('a revoked session stops on every instance in time', async () => {\n const token = await signIn(instanceA)\n await signOut(instanceA, token)\n const started = Date.now()\n while ((await call(instanceB, token)).status !== 401) {\n expect(Date.now() - started).toBeLessThan(REVOKE_SECONDS * 1000)\n await sleep(1000)\n }\n})\n\nit('an idle session ends after the idle limit', async () => {\n const token = await signIn(instanceA)\n expect((await call(instanceA, token)).status).toBe(200)\n await sleep(6_000) // past SESSION_IDLE_SECONDS=5 of the drill instances\n expect((await call(instanceA, token)).status).toBe(401)\n})\n```",
|
|
578
|
+
"hubWhen": {
|
|
579
|
+
"IDENTITY": [
|
|
580
|
+
"idp",
|
|
581
|
+
"own"
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
"id": "ff-audit",
|
|
587
|
+
"type": "fitness-fn",
|
|
588
|
+
"label": "Sign-in events recorded, credentials not",
|
|
589
|
+
"x": 1040,
|
|
590
|
+
"y": 260,
|
|
591
|
+
"characteristic": "security",
|
|
592
|
+
"scope": "atomic",
|
|
593
|
+
"cadence": "triggered",
|
|
594
|
+
"trigger": "pull-request",
|
|
595
|
+
"invocation": "automated",
|
|
596
|
+
"description": "An integration test performs the four events for one account with a password and token of a known random value, reads back the audit records whose target is the account and checks their fields (action, at, source.client and source.address, as in the Audit trail pack's record format), then searches them and the captured application log for the credential values.\n\nThreshold: Each of sign-in, failed sign-in, sign-out and revocation produces 1 audit record naming the account as its target, with time, client and source address; 0 occurrences of the password or token in the audit trail and the application log\n\nTool: Vitest with supertest, the logs captured to a file by the test harness\n\n```ts\nimport { readFileSync } from 'node:fs'\nimport { app } from '../src/app'\nimport { audit } from '../src/audit/store'\nimport { createAccount, signInAs, signOut, revokeAll } from './auth/fixtures'\n\nit('audits the four sign-in events without the credential', async () => {\n const password = `pw-${crypto.randomUUID()}`\n const account = await createAccount({ password })\n const token = await signInAs(app, account, password)\n await signInAs(app, account, 'wrong-' + password).catch(() => undefined)\n await signOut(app, token)\n await revokeAll(app, account)\n const records = await audit.find({ target: { type: 'account', id: account.id } })\n expect(records.map((r) => r.action).sort()).toEqual(['revoke', 'sign-in', 'sign-in-failed', 'sign-out'])\n for (const r of records) expect(r).toMatchObject({ at: expect.any(Date), source: { client: expect.any(String), address: expect.any(String) } })\n const logs = JSON.stringify(records) + readFileSync(process.env.APP_LOG_FILE!, 'utf8')\n expect(logs).not.toContain(password)\n expect(logs).not.toContain(token)\n})\n```",
|
|
597
|
+
"hubWhen": {
|
|
598
|
+
"IDENTITY": [
|
|
599
|
+
"idp",
|
|
600
|
+
"own"
|
|
601
|
+
]
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"id": "ff-lockout",
|
|
606
|
+
"type": "fitness-fn",
|
|
607
|
+
"label": "Guessing slowed",
|
|
608
|
+
"x": 1040,
|
|
609
|
+
"y": 390,
|
|
610
|
+
"characteristic": "security",
|
|
611
|
+
"scope": "atomic",
|
|
612
|
+
"cadence": "triggered",
|
|
613
|
+
"trigger": "pull-request",
|
|
614
|
+
"invocation": "automated",
|
|
615
|
+
"description": "An integration test fails five sign-ins for one account, measures the sixth (a 429 or a response at least 1 second slower than the first failure counts as delayed), and checks the outbox for the owner's notification.\n\nThreshold: After 5 failed sign-ins within 15 minutes the 6th attempt on that account is refused or delayed by at least 1 second, and 1 notification to the account's owner is sent\n\nTool: Vitest with supertest, with the mail or notification sender captured by the test harness\n\n```ts\nimport request from 'supertest'\nimport { app } from '../src/app'\nimport { createAccount, notifications } from './auth/fixtures'\n\nit('slows the sixth attempt and tells the owner', async () => {\n const account = await createAccount({ password: 'correct horse battery staple' })\n const attempt = () => request(app).post('/auth/sign-in').send({ email: account.email, password: 'wrong' })\n const first = Date.now()\n await attempt()\n const firstMs = Date.now() - first\n for (let i = 0; i < 4; i++) await attempt()\n const started = Date.now()\n const sixth = await attempt()\n const delayed = sixth.status === 429 || Date.now() - started >= firstMs + 1000\n expect(delayed).toBe(true)\n expect(await notifications.sentTo(account.email, 'sign-in-attempts')).toHaveLength(1)\n})\n```",
|
|
616
|
+
"hubWhen": {
|
|
617
|
+
"IDENTITY": [
|
|
618
|
+
"own"
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"id": "ff-passwords",
|
|
624
|
+
"type": "fitness-fn",
|
|
625
|
+
"label": "Passwords hashed and checked",
|
|
626
|
+
"x": 1040,
|
|
627
|
+
"y": 520,
|
|
628
|
+
"characteristic": "security",
|
|
629
|
+
"scope": "atomic",
|
|
630
|
+
"cadence": "triggered",
|
|
631
|
+
"trigger": "pull-request",
|
|
632
|
+
"invocation": "automated",
|
|
633
|
+
"description": "An integration test sets passwords through the sign-up operation (a breached one from the Pwned Passwords range API, too short, too long, and two valid ones) and reads the stored hashes to check the algorithm and its parameters.\n\nThreshold: 100% of stored password hashes start with $argon2id$v=19$m=19456,t=2,p=1$ (or stronger parameters); a breached password and one of 7 or 65 characters are refused; one of 8 and one of 64 are accepted\n\nTool: Vitest with supertest and a direct database read\n\n```ts\nimport request from 'supertest'\nimport { app } from '../src/app'\nimport { db } from './db'\n\nconst signUp = (password: string) => request(app).post('/auth/sign-up').send({ email: `${crypto.randomUUID()}@example.test`, password })\n\nit('refuses breached and mis-sized passwords, stores the rest as Argon2id', async () => {\n expect((await signUp('password123')).status).toBe(400) // in Pwned Passwords\n expect((await signUp('abcdefg')).status).toBe(400) // 7 characters\n expect((await signUp('x'.repeat(65))).status).toBe(400) // 65 characters\n expect((await signUp('Aq7!tRw9')).status).toBe(201) // 8 characters\n expect((await signUp(crypto.randomUUID().repeat(2).slice(0, 64))).status).toBe(201)\n const { rows } = await db.query('select password_hash from users')\n for (const { password_hash } of rows) expect(password_hash).toMatch(/^\\$argon2id\\$v=19\\$m=(1945[6-9]|194[6-9]\\d|19[5-9]\\d\\d|[2-9]\\d{4}|[1-9]\\d{5,}),t=([2-9]|\\d{2,}),p=\\d+\\$/)\n})\n```",
|
|
634
|
+
"hubWhen": {
|
|
635
|
+
"IDENTITY": [
|
|
636
|
+
"own"
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"id": "ff-stepup",
|
|
642
|
+
"type": "fitness-fn",
|
|
643
|
+
"label": "Risky operations ask for a second factor",
|
|
644
|
+
"x": 1040,
|
|
645
|
+
"y": 650,
|
|
646
|
+
"characteristic": "security",
|
|
647
|
+
"scope": "atomic",
|
|
648
|
+
"cadence": "triggered",
|
|
649
|
+
"trigger": "pull-request",
|
|
650
|
+
"invocation": "automated",
|
|
651
|
+
"description": "A test reads the step-up list from the code, calls each listed operation with a session whose last second-factor confirmation is set to 6 minutes ago, expects a refusal, confirms the second factor and expects the operation to run.\n\nThreshold: Every operation on the step-up list refuses a session whose second factor is older than 5 minutes (401 or 403) and runs after a fresh confirmation; 0 listed operations run without one\n\nTool: Vitest with supertest (or the test runner and HTTP client of your stack)\n\n```ts\nimport request from 'supertest'\nimport { app } from '../src/app'\nimport { STEP_UP_OPERATIONS } from '../src/auth/stepUp' // the operations of the decision: {{PRIVILEGED_OPS}}\nimport { sessionWithMfaAgeMinutes, confirmSecondFactor } from './auth/fixtures'\n\ndescribe.each([...STEP_UP_OPERATIONS])('$method $path', (op) => {\n it('refuses a stale second factor and runs after a fresh one', async () => {\n const token = await sessionWithMfaAgeMinutes(6)\n const stale = await request(app)[op.method.toLowerCase()](op.example).set('Authorization', `Bearer ${token}`)\n expect([401, 403]).toContain(stale.status)\n await confirmSecondFactor(token)\n const fresh = await request(app)[op.method.toLowerCase()](op.example).set('Authorization', `Bearer ${token}`)\n expect(fresh.status).toBeLessThan(400)\n })\n})\n```",
|
|
652
|
+
"hubWhen": {
|
|
653
|
+
"IDENTITY": [
|
|
654
|
+
"idp",
|
|
655
|
+
"own"
|
|
656
|
+
],
|
|
657
|
+
"STEP_UP": [
|
|
658
|
+
"yes"
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"id": "ff-machine",
|
|
664
|
+
"type": "fitness-fn",
|
|
665
|
+
"label": "Calling systems known and limited",
|
|
666
|
+
"x": 1040,
|
|
667
|
+
"y": 780,
|
|
668
|
+
"characteristic": "security",
|
|
669
|
+
"scope": "atomic",
|
|
670
|
+
"cadence": "triggered",
|
|
671
|
+
"trigger": "pull-request",
|
|
672
|
+
"invocation": "automated",
|
|
673
|
+
"description": "An integration test calls as a registered system (OAuth client, client certificate or API key, whichever the decision names) an operation on its list, one off it, and once without authenticating, and checks the registry of system credentials for any issued or rotated more than 90 days ago.\n\nThreshold: A call without a system credential and a call with one to an operation off the caller's list are refused (401 or 403); 0 system credentials older than 90 days in the credential registry\n\nTool: Vitest with supertest, the system credential issued by the test fixture (an OAuth client, a client certificate or an API key, as decided)\n\n```ts\nimport request from 'supertest'\nimport { app } from '../src/app'\nimport { systemCredentials } from '../src/auth/systemCredentials' // the registry: id, issued or rotated at, allowed operations\nimport { asSystem } from './auth/fixtures' // sets the credential of the decision on the request\n\nit('lets a known system run only its operations', async () => {\n const partner = await asSystem('partner-billing', { operations: ['POST /invoices'] })\n expect((await partner(request(app).post('/invoices').send({}))).status).toBeLessThan(400)\n expect([401, 403]).toContain((await partner(request(app).delete('/orders/1'))).status)\n expect((await request(app).post('/invoices').send({})).status).toBe(401)\n})\n\nit('has no system credential older than 90 days', async () => {\n const limit = Date.now() - 90 * 86_400_000\n expect((await systemCredentials.all()).filter((c) => c.rotatedAt.getTime() < limit)).toEqual([])\n})\n```",
|
|
674
|
+
"hubWhen": {
|
|
675
|
+
"MACHINE": [
|
|
676
|
+
"oauth",
|
|
677
|
+
"mtls",
|
|
678
|
+
"keys"
|
|
679
|
+
]
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"id": "ff-none",
|
|
684
|
+
"type": "fitness-fn",
|
|
685
|
+
"label": "Nothing to sign in to",
|
|
686
|
+
"x": 1040,
|
|
687
|
+
"y": 910,
|
|
688
|
+
"characteristic": "security",
|
|
689
|
+
"scope": "atomic",
|
|
690
|
+
"cadence": "triggered",
|
|
691
|
+
"trigger": "pull-request",
|
|
692
|
+
"invocation": "automated",
|
|
693
|
+
"description": "A dependency rule fails the build when a sign-in or session library is added, which would mean a sign-in arrived without its decision. Token validation libraries (jose, jsonwebtoken) stay allowed: calling systems authenticate as decided under Other systems.\n\nThreshold: No operation signs a person in, starts a session or reads a person's credential, and no sign-in or session library is a dependency\n\nTool: dependency-cruiser (or the equivalent for your stack: ArchUnit, NetArchTest, a RuboCop custom cop)\n\n```js\n// .dependency-cruiser.cjs\nmodule.exports = {\n forbidden: [{\n name: 'no-sign-in',\n comment: 'ADR Nobody signs in: supersede it before adding sign-in or sessions for people',\n severity: 'error',\n from: {},\n to: { path: 'node_modules/(passport|next-auth|@auth/|express-session|iron-session|oidc-client-ts|better-auth|lucia)' },\n }],\n}\n```",
|
|
694
|
+
"hubWhen": {
|
|
695
|
+
"IDENTITY": [
|
|
696
|
+
"none"
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
],
|
|
701
|
+
"relations": [
|
|
702
|
+
{
|
|
703
|
+
"id": "req-reject--derives--need",
|
|
704
|
+
"sourceId": "req-reject",
|
|
705
|
+
"targetId": "need",
|
|
706
|
+
"relationType": "derives"
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"id": "req-idle--derives--need",
|
|
710
|
+
"sourceId": "req-idle",
|
|
711
|
+
"targetId": "need",
|
|
712
|
+
"relationType": "derives"
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
"id": "req-revoke--derives--need",
|
|
716
|
+
"sourceId": "req-revoke",
|
|
717
|
+
"targetId": "need",
|
|
718
|
+
"relationType": "derives"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"id": "req-audit--derives--need",
|
|
722
|
+
"sourceId": "req-audit",
|
|
723
|
+
"targetId": "need",
|
|
724
|
+
"relationType": "derives"
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
"id": "req-lockout--derives--need",
|
|
728
|
+
"sourceId": "req-lockout",
|
|
729
|
+
"targetId": "need",
|
|
730
|
+
"relationType": "derives"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"id": "req-passwords--derives--need",
|
|
734
|
+
"sourceId": "req-passwords",
|
|
735
|
+
"targetId": "need",
|
|
736
|
+
"relationType": "derives"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
"id": "req-stepup--derives--need",
|
|
740
|
+
"sourceId": "req-stepup",
|
|
741
|
+
"targetId": "need",
|
|
742
|
+
"relationType": "derives"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"id": "req-machine--derives--need",
|
|
746
|
+
"sourceId": "req-machine",
|
|
747
|
+
"targetId": "need",
|
|
748
|
+
"relationType": "derives"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
"id": "req-public--derives--need",
|
|
752
|
+
"sourceId": "req-public",
|
|
753
|
+
"targetId": "need",
|
|
754
|
+
"relationType": "derives"
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
"id": "sc-reject--verifies--req-reject",
|
|
758
|
+
"sourceId": "sc-reject",
|
|
759
|
+
"targetId": "req-reject",
|
|
760
|
+
"relationType": "verifies"
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
"id": "sc-idle--verifies--req-idle",
|
|
764
|
+
"sourceId": "sc-idle",
|
|
765
|
+
"targetId": "req-idle",
|
|
766
|
+
"relationType": "verifies"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
"id": "sc-revoke--verifies--req-revoke",
|
|
770
|
+
"sourceId": "sc-revoke",
|
|
771
|
+
"targetId": "req-revoke",
|
|
772
|
+
"relationType": "verifies"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
"id": "sc-audit--verifies--req-audit",
|
|
776
|
+
"sourceId": "sc-audit",
|
|
777
|
+
"targetId": "req-audit",
|
|
778
|
+
"relationType": "verifies"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
"id": "sc-lockout--verifies--req-lockout",
|
|
782
|
+
"sourceId": "sc-lockout",
|
|
783
|
+
"targetId": "req-lockout",
|
|
784
|
+
"relationType": "verifies"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"id": "sc-passwords--verifies--req-passwords",
|
|
788
|
+
"sourceId": "sc-passwords",
|
|
789
|
+
"targetId": "req-passwords",
|
|
790
|
+
"relationType": "verifies"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
"id": "sc-stepup--verifies--req-stepup",
|
|
794
|
+
"sourceId": "sc-stepup",
|
|
795
|
+
"targetId": "req-stepup",
|
|
796
|
+
"relationType": "verifies"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
"id": "sc-machine--verifies--req-machine",
|
|
800
|
+
"sourceId": "sc-machine",
|
|
801
|
+
"targetId": "req-machine",
|
|
802
|
+
"relationType": "verifies"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
"id": "sc-public--verifies--req-public",
|
|
806
|
+
"sourceId": "sc-public",
|
|
807
|
+
"targetId": "req-public",
|
|
808
|
+
"relationType": "verifies"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
"id": "ff-reject--implements--adr-idp",
|
|
812
|
+
"sourceId": "ff-reject",
|
|
813
|
+
"targetId": "adr-idp",
|
|
814
|
+
"relationType": "implements"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
"id": "ff-reject--implements--adr-own",
|
|
818
|
+
"sourceId": "ff-reject",
|
|
819
|
+
"targetId": "adr-own",
|
|
820
|
+
"relationType": "implements"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
"id": "ff-session--implements--adr-idp",
|
|
824
|
+
"sourceId": "ff-session",
|
|
825
|
+
"targetId": "adr-idp",
|
|
826
|
+
"relationType": "implements"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
"id": "ff-session--implements--adr-own",
|
|
830
|
+
"sourceId": "ff-session",
|
|
831
|
+
"targetId": "adr-own",
|
|
832
|
+
"relationType": "implements"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
"id": "ff-session--implements--adr-no-stepup",
|
|
836
|
+
"sourceId": "ff-session",
|
|
837
|
+
"targetId": "adr-no-stepup",
|
|
838
|
+
"relationType": "implements"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"id": "ff-audit--implements--adr-idp",
|
|
842
|
+
"sourceId": "ff-audit",
|
|
843
|
+
"targetId": "adr-idp",
|
|
844
|
+
"relationType": "implements"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
"id": "ff-audit--implements--adr-own",
|
|
848
|
+
"sourceId": "ff-audit",
|
|
849
|
+
"targetId": "adr-own",
|
|
850
|
+
"relationType": "implements"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
"id": "ff-lockout--implements--adr-own",
|
|
854
|
+
"sourceId": "ff-lockout",
|
|
855
|
+
"targetId": "adr-own",
|
|
856
|
+
"relationType": "implements"
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
"id": "ff-passwords--implements--adr-own",
|
|
860
|
+
"sourceId": "ff-passwords",
|
|
861
|
+
"targetId": "adr-own",
|
|
862
|
+
"relationType": "implements"
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
"id": "ff-stepup--implements--adr-stepup",
|
|
866
|
+
"sourceId": "ff-stepup",
|
|
867
|
+
"targetId": "adr-stepup",
|
|
868
|
+
"relationType": "implements"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
"id": "ff-machine--implements--adr-idp",
|
|
872
|
+
"sourceId": "ff-machine",
|
|
873
|
+
"targetId": "adr-idp",
|
|
874
|
+
"relationType": "implements"
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
"id": "ff-machine--implements--adr-own",
|
|
878
|
+
"sourceId": "ff-machine",
|
|
879
|
+
"targetId": "adr-own",
|
|
880
|
+
"relationType": "implements"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
"id": "ff-machine--implements--adr-none",
|
|
884
|
+
"sourceId": "ff-machine",
|
|
885
|
+
"targetId": "adr-none",
|
|
886
|
+
"relationType": "implements"
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
"id": "ff-none--implements--adr-none",
|
|
890
|
+
"sourceId": "ff-none",
|
|
891
|
+
"targetId": "adr-none",
|
|
892
|
+
"relationType": "implements"
|
|
893
|
+
}
|
|
894
|
+
]
|
|
895
|
+
}
|