@fabrika/iam-contract 0.4.2 → 0.4.4
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/access.ts +51 -0
- package/src/index.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/iam-contract",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@fabrika/app": "^0.4.
|
|
28
|
-
"@fabrika/auth-core": "^0.4.
|
|
27
|
+
"@fabrika/app": "^0.4.4",
|
|
28
|
+
"@fabrika/auth-core": "^0.4.4"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/access.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// IAM's own vocabulary (ADR-0058): what IAM authorizes its administration against, reconciled under its durable app id
|
|
2
|
+
// beside the console's by every installation path.
|
|
3
|
+
|
|
4
|
+
import { type AppSchema, type PermissionEntry, permits, scopedValues } from '@fabrika/auth-core'
|
|
5
|
+
|
|
6
|
+
/** Durable IAM application id of IAM itself — a deployed identity, not configuration branding (ADR-0024). */
|
|
7
|
+
export const IAM_APP_ID = 'propustka'
|
|
8
|
+
|
|
9
|
+
export const IAM_ACTIONS = Object.freeze({
|
|
10
|
+
/** Administer identity and access for the installation. Global only; it reaches every application. */
|
|
11
|
+
ADMIN: 'iam.admin',
|
|
12
|
+
/** Manage the people of applications, never of the installation's own apps. Global, or in `app` values. */
|
|
13
|
+
USERS_MANAGE: 'iam.users.manage',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const IAM_SCOPES = Object.freeze({
|
|
17
|
+
/** One application environment, by its IAM id `<app>@<env>`. */
|
|
18
|
+
APP: 'app',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
/** The preset role a user administrator holds. */
|
|
22
|
+
export const USER_ADMIN_ROLE = 'user-admin'
|
|
23
|
+
|
|
24
|
+
/** What a holder of IAM permissions administers: the installation, or the people of some applications (`null` = all). */
|
|
25
|
+
export type IamAdministrationScope =
|
|
26
|
+
| { readonly kind: 'installation' }
|
|
27
|
+
| { readonly kind: 'users'; readonly apps: readonly string[] | null }
|
|
28
|
+
|
|
29
|
+
/** The administration IAM permissions confer, or null for none. IAM adds that a user administrator acts from a session. */
|
|
30
|
+
export function iamAdministrationScope(permissions: PermissionEntry[]): IamAdministrationScope | null {
|
|
31
|
+
if (permits(permissions, IAM_ACTIONS.ADMIN)) return { kind: 'installation' }
|
|
32
|
+
const apps = scopedValues(permissions, IAM_ACTIONS.USERS_MANAGE, IAM_SCOPES.APP)
|
|
33
|
+
if (apps === null) return { kind: 'users', apps: null }
|
|
34
|
+
return apps.length === 0 ? null : { kind: 'users', apps }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const IAM_APP_SCHEMA: AppSchema = {
|
|
38
|
+
displayName: 'Access',
|
|
39
|
+
scopes: [{ type: IAM_SCOPES.APP, label: 'Application' }],
|
|
40
|
+
actions: [
|
|
41
|
+
{ action: IAM_ACTIONS.ADMIN, description: 'Administer identity and access for the installation' },
|
|
42
|
+
{ action: IAM_ACTIONS.USERS_MANAGE, description: 'Manage the people of applications: invite, sign out, reset, grant and revoke' },
|
|
43
|
+
],
|
|
44
|
+
roles: {
|
|
45
|
+
[USER_ADMIN_ROLE]: {
|
|
46
|
+
name: 'User administrator',
|
|
47
|
+
description: "Manage the people of the applications in scope; nothing of the installation's own apps.",
|
|
48
|
+
permissions: [IAM_ACTIONS.USERS_MANAGE],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -145,6 +145,10 @@ export interface CreateGrantRequest {
|
|
|
145
145
|
/** The set of app ids propustka knows about — the choices for a grant's `app`. */
|
|
146
146
|
export interface AppDto {
|
|
147
147
|
id: string
|
|
148
|
+
/** The name the app's schema declares for people; null when it declares none. */
|
|
149
|
+
displayName: string | null
|
|
150
|
+
/** One of the installation's own apps (a platform audience): a user administrator grants nothing there (ADR-0058). */
|
|
151
|
+
installation: boolean
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
// ── Roles & policies (per-app, DB-backed) ─────────────────────────────────────
|
|
@@ -670,4 +674,5 @@ export interface IamAdminRpcContract {
|
|
|
670
674
|
}
|
|
671
675
|
|
|
672
676
|
export type { AppActionDef, AppMemberItem, AppSchema, AppScopeDef, PermissionEntry, PermissionSource, PrincipalAffiliation, PrincipalType, RoleDef }
|
|
677
|
+
export * from './access'
|
|
673
678
|
export * from './oauth'
|