@fabrika/auth 0.9.0-dev.12 → 0.9.0-dev.13
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/package.json +3 -3
- package/src/app-schema.ts +21 -1
- package/types/src/app-schema.d.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/auth",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^3.25.76",
|
|
31
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
32
|
-
"@fabrika/jwks": "0.9.0-dev.
|
|
31
|
+
"@fabrika/auth-core": "0.9.0-dev.13",
|
|
32
|
+
"@fabrika/jwks": "0.9.0-dev.13",
|
|
33
33
|
"jose": "^5.9.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/app-schema.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
displayNameProblem,
|
|
5
5
|
isActionAllowed,
|
|
6
6
|
isOwnWorkloadName,
|
|
7
|
+
isReservedScopeType,
|
|
7
8
|
LOCALES,
|
|
8
9
|
mailTemplateProblems,
|
|
9
10
|
type MessageKind,
|
|
@@ -19,7 +20,7 @@ const quote = (value: string): string => `\`${value.slice(0, 80)}\``
|
|
|
19
20
|
const keySchema = z.string().min(1).refine((key) => key !== '__proto__')
|
|
20
21
|
|
|
21
22
|
const scopeSchema = z.object({
|
|
22
|
-
type: z.string().min(1),
|
|
23
|
+
type: z.string().min(1).refine((type) => !isReservedScopeType(type), 'a scope type never starts with ~ (IAM reserves it)'),
|
|
23
24
|
label: z.string().min(1).optional(),
|
|
24
25
|
in: z.string().min(1).optional(),
|
|
25
26
|
creator: z.string().min(1).optional(),
|
|
@@ -34,6 +35,7 @@ const roleSchema = z.object({
|
|
|
34
35
|
permissions: z.array(z.string().min(1)),
|
|
35
36
|
member: z.object({ scope: z.string().min(1), assignableBy: z.array(z.string().min(1)).optional() }).optional(),
|
|
36
37
|
external: z.literal(true).optional(),
|
|
38
|
+
via: z.record(z.string().min(1), z.array(z.string().min(1)).min(1)).optional(),
|
|
37
39
|
})
|
|
38
40
|
/** A link lives at most a year; the mount's `maxDays` is the bound a contract states below that. */
|
|
39
41
|
const MAX_LINK_DAYS = 365
|
|
@@ -276,6 +278,24 @@ export const appSchemaSchema = appSchemaShape.superRefine((schema, ctx) => {
|
|
|
276
278
|
})
|
|
277
279
|
}
|
|
278
280
|
}
|
|
281
|
+
for (const [relation, actions] of Object.entries(role.via ?? {})) {
|
|
282
|
+
if (role.member !== undefined || role.external === true) {
|
|
283
|
+
ctx.addIssue({
|
|
284
|
+
code: 'custom',
|
|
285
|
+
path: ['roles', key, 'via'],
|
|
286
|
+
message: `role ${quote(key)} holds actions via a relation and is a membership or external role`,
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
for (const [index, action] of actions.entries()) {
|
|
290
|
+
if (!catalog.includes(action)) {
|
|
291
|
+
ctx.addIssue({
|
|
292
|
+
code: 'custom',
|
|
293
|
+
path: ['roles', key, 'via', relation, index],
|
|
294
|
+
message: `role ${quote(key)} holds an unknown action via ${quote(relation)}: ${quote(action)}`,
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
279
299
|
if (role.member !== undefined && !scopes.includes(role.member.scope)) {
|
|
280
300
|
ctx.addIssue({
|
|
281
301
|
code: 'custom',
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
9
9
|
scopes: z.ZodArray<z.ZodObject<{
|
|
10
|
-
type: z.ZodString
|
|
10
|
+
type: z.ZodEffects<z.ZodString, string, string>;
|
|
11
11
|
label: z.ZodOptional<z.ZodString>;
|
|
12
12
|
in: z.ZodOptional<z.ZodString>;
|
|
13
13
|
creator: z.ZodOptional<z.ZodString>;
|
|
@@ -71,6 +71,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
71
71
|
assignableBy?: string[] | undefined;
|
|
72
72
|
}>>;
|
|
73
73
|
external: z.ZodOptional<z.ZodLiteral<true>>;
|
|
74
|
+
via: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
74
75
|
}, "strip", z.ZodTypeAny, {
|
|
75
76
|
name: string;
|
|
76
77
|
permissions: string[];
|
|
@@ -79,6 +80,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
79
80
|
scope: string;
|
|
80
81
|
assignableBy?: string[] | undefined;
|
|
81
82
|
} | undefined;
|
|
83
|
+
via?: Record<string, string[]> | undefined;
|
|
82
84
|
description?: string | undefined;
|
|
83
85
|
}, {
|
|
84
86
|
name: string;
|
|
@@ -88,6 +90,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
88
90
|
scope: string;
|
|
89
91
|
assignableBy?: string[] | undefined;
|
|
90
92
|
} | undefined;
|
|
93
|
+
via?: Record<string, string[]> | undefined;
|
|
91
94
|
description?: string | undefined;
|
|
92
95
|
}>>;
|
|
93
96
|
contract: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -302,6 +305,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
302
305
|
scope: string;
|
|
303
306
|
assignableBy?: string[] | undefined;
|
|
304
307
|
} | undefined;
|
|
308
|
+
via?: Record<string, string[]> | undefined;
|
|
305
309
|
description?: string | undefined;
|
|
306
310
|
}>;
|
|
307
311
|
scopes: {
|
|
@@ -386,6 +390,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
386
390
|
scope: string;
|
|
387
391
|
assignableBy?: string[] | undefined;
|
|
388
392
|
} | undefined;
|
|
393
|
+
via?: Record<string, string[]> | undefined;
|
|
389
394
|
description?: string | undefined;
|
|
390
395
|
}>;
|
|
391
396
|
scopes: {
|
|
@@ -470,6 +475,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
470
475
|
scope: string;
|
|
471
476
|
assignableBy?: string[] | undefined;
|
|
472
477
|
} | undefined;
|
|
478
|
+
via?: Record<string, string[]> | undefined;
|
|
473
479
|
description?: string | undefined;
|
|
474
480
|
}>;
|
|
475
481
|
scopes: {
|
|
@@ -554,6 +560,7 @@ export declare const appSchemaSchema: z.ZodEffects<z.ZodObject<{
|
|
|
554
560
|
scope: string;
|
|
555
561
|
assignableBy?: string[] | undefined;
|
|
556
562
|
} | undefined;
|
|
563
|
+
via?: Record<string, string[]> | undefined;
|
|
557
564
|
description?: string | undefined;
|
|
558
565
|
}>;
|
|
559
566
|
scopes: {
|