@nest-boot/auth 8.0.5-beta.0 → 8.0.5-beta.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.
- package/README.md +16 -2
- package/dist/auth-module-options.interface.d.ts +1 -1
- package/dist/auth.module.js +16 -10
- package/dist/auth.module.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/api-key-lifecycle.d.ts +13 -0
- package/dist/infrastructure/api-key-lifecycle.js +51 -0
- package/dist/infrastructure/api-key-lifecycle.js.map +1 -0
- package/dist/infrastructure/auth-enum-registry.js +9 -2
- package/dist/infrastructure/auth-enum-registry.js.map +1 -1
- package/dist/interfaces/ability-rules.interface.d.ts +2 -2
- package/dist/interfaces/auth-module-api-key-options.interface.d.ts +7 -14
- package/dist/interfaces/auth-module-api-key-scope-options.interface.d.ts +7 -0
- package/dist/interfaces/auth-module-api-key-scope-options.interface.js +2 -0
- package/dist/interfaces/auth-module-api-key-scope-options.interface.js.map +1 -0
- package/dist/objects/user-api-key-permission-option.object.d.ts +2 -0
- package/dist/objects/user-api-key-permission-option.object.js +6 -0
- package/dist/objects/user-api-key-permission-option.object.js.map +1 -1
- package/dist/objects/workspace-api-key-permission-option.object.d.ts +2 -0
- package/dist/objects/workspace-api-key-permission-option.object.js +6 -0
- package/dist/objects/workspace-api-key-permission-option.object.js.map +1 -1
- package/dist/services/user-api-key.service.d.ts +0 -5
- package/dist/services/user-api-key.service.js +19 -72
- package/dist/services/user-api-key.service.js.map +1 -1
- package/dist/services/workspace-api-key.service.d.ts +0 -6
- package/dist/services/workspace-api-key.service.js +19 -75
- package/dist/services/workspace-api-key.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/api-key-permissions.util.d.ts +3 -2
- package/dist/utils/api-key-permissions.util.js +17 -6
- package/dist/utils/api-key-permissions.util.js.map +1 -1
- package/dist/utils/auth-role.util.d.ts +1 -1
- package/dist/utils/auth-role.util.js +2 -2
- package/dist/utils/auth-role.util.js.map +1 -1
- package/dist/utils/resolve-auth-catalog.util.d.ts +3 -3
- package/dist/utils/resolve-auth-catalog.util.js +19 -9
- package/dist/utils/resolve-auth-catalog.util.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -429,8 +429,16 @@ ownership checks and self-service operations remain enforced by Services.
|
|
|
429
429
|
The `userRoles` and `workspaceRoles` queries return `{ role, grantable }` objects;
|
|
430
430
|
`userPermissions` and `workspacePermissions` return `{ permission, grantable }`.
|
|
431
431
|
`userApiKeyPermissions` and `workspaceApiKeyPermissions` also return
|
|
432
|
-
`{ permission, grantable }` entries
|
|
433
|
-
issuer's grant ceiling
|
|
432
|
+
`{ permission, grantable, default }` entries. `grantable` includes the API-key
|
|
433
|
+
allowlist and issuer's grant ceiling; `default` reflects configured defaults.
|
|
434
|
+
Editors preselect only `default && grantable`. Workspace keys cannot grant
|
|
435
|
+
`invitation:create`.
|
|
436
|
+
|
|
437
|
+
Configure these independently with `apiKey.user` and `apiKey.workspace`, each
|
|
438
|
+
containing `defaultPermissions` and `allowedPermissions`. Defaults are empty;
|
|
439
|
+
omitted allowlists permit the scope's catalog, while `[]` permits no grants.
|
|
440
|
+
User keys support both catalogs; workspace keys only support workspace grants.
|
|
441
|
+
The former flat API-key settings are rejected with a migration message.
|
|
434
442
|
|
|
435
443
|
Module permission catalogs and role maps extend built-in defaults. Same-name
|
|
436
444
|
role grants are merged; custom permissions are not automatically granted to
|
|
@@ -438,6 +446,12 @@ built-in roles. Empty additions preserve defaults. Entity `set*` mutations still
|
|
|
438
446
|
replace stored roles or direct permissions; API-key `allowedPermissions` remains
|
|
439
447
|
an explicit ceiling.
|
|
440
448
|
|
|
449
|
+
Configuration catalogs are immutable snapshots reused by startup validation,
|
|
450
|
+
GraphQL enums, and Services. Configure them before module initialization; change
|
|
451
|
+
stored user/member roles or direct grants through Services at runtime instead
|
|
452
|
+
of mutating module options. Request identity changes still invalidate effective
|
|
453
|
+
permission snapshots and rebuild abilities.
|
|
454
|
+
|
|
441
455
|
Role and permission values remain GraphQL enums. These catalogs retain all configured
|
|
442
456
|
options and mark the current principal's grant ceiling, including API-key restrictions.
|
|
443
457
|
They do not authorize changes to a particular target. Disable unavailable new grants
|
|
@@ -35,7 +35,7 @@ export interface AuthModuleOptions<UserPermission extends string = string, Works
|
|
|
35
35
|
/** Workspace lifecycle and invitation-delivery options. */
|
|
36
36
|
workspace?: AuthModuleWorkspaceOptions<WorkspacePermission | (typeof DEFAULT_WORKSPACE_PERMISSIONS)[number], WorkspaceRole | keyof typeof DEFAULT_WORKSPACE_ROLES>;
|
|
37
37
|
/** API-key permission defaults and grant limits. */
|
|
38
|
-
apiKey?: AuthModuleApiKeyOptions<NoInfer<UserPermission |
|
|
38
|
+
apiKey?: AuthModuleApiKeyOptions<NoInfer<UserPermission | (typeof DEFAULT_USER_PERMISSIONS)[number]>, NoInfer<WorkspacePermission | (typeof DEFAULT_WORKSPACE_PERMISSIONS)[number]>>;
|
|
39
39
|
/** Built-in social and custom OAuth providers, identified by `id`. */
|
|
40
40
|
providers?: readonly AuthModuleProvider[];
|
|
41
41
|
/** Middleware registration options. */
|
package/dist/auth.module.js
CHANGED
|
@@ -51,6 +51,7 @@ import { UserDeletionService } from "./services/user-deletion.service.js";
|
|
|
51
51
|
import { WorkspaceService } from "./services/workspace.service.js";
|
|
52
52
|
import { WorkspaceApiKeyService } from "./services/workspace-api-key.service.js";
|
|
53
53
|
import { DEFAULT_USER_ADMIN_ROLES, DEFAULT_USER_ROLE, } from "./user.constants.js";
|
|
54
|
+
import { resolveApiKeyPermissionCatalog } from "./utils/api-key-permissions.util.js";
|
|
54
55
|
import { assertAuthPermissionList, assertAuthPermissionSubset, assertAuthRolePermissions, assertAuthRolesExist, } from "./utils/auth-role.util.js";
|
|
55
56
|
import { createEmailAndPasswordConfig } from "./utils/create-email-and-password-config.js";
|
|
56
57
|
import { createEmailVerificationConfig } from "./utils/create-email-verification-config.js";
|
|
@@ -169,18 +170,23 @@ AuthModule = __decorate([
|
|
|
169
170
|
useFactory: (options, orm, mailer, hashService, userDeletionService) => {
|
|
170
171
|
const { roles: userRoles, permissions: userPermissions } = resolveAuthCatalog(options, "user");
|
|
171
172
|
const { roles: workspaceRoles, permissions: workspacePermissions } = resolveAuthCatalog(options, "workspace");
|
|
172
|
-
const apiKeyPermissionCatalog = [
|
|
173
|
-
...new Set([...userPermissions, ...workspacePermissions]),
|
|
174
|
-
];
|
|
175
|
-
const allowedApiKeyPermissions = options.apiKey?.allowedPermissions ?? apiKeyPermissionCatalog;
|
|
176
|
-
const defaultApiKeyPermissions = options.apiKey?.defaultPermissions ?? [];
|
|
177
173
|
assertAuthRolePermissions(userRoles, userPermissions, "user");
|
|
178
174
|
assertAuthRolePermissions(workspaceRoles, workspacePermissions, "workspace");
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
if (options.apiKey &&
|
|
176
|
+
("defaultPermissions" in options.apiKey ||
|
|
177
|
+
"allowedPermissions" in options.apiKey)) {
|
|
178
|
+
throw new Error("Configure API key permissions under apiKey.user or apiKey.workspace");
|
|
179
|
+
}
|
|
180
|
+
for (const scope of ["user", "workspace"]) {
|
|
181
|
+
const { permissions: catalog, defaults } = resolveApiKeyPermissionCatalog(options, scope);
|
|
182
|
+
const configured = options.apiKey?.[scope];
|
|
183
|
+
const allowed = configured?.allowedPermissions ?? catalog;
|
|
184
|
+
assertAuthPermissionList(allowed, catalog, `apiKey.${scope}.allowedPermissions`);
|
|
185
|
+
assertAuthPermissionList(defaults, catalog, `apiKey.${scope}.defaultPermissions`);
|
|
186
|
+
assertAuthPermissionSubset(defaults, allowed, `apiKey.${scope}.defaultPermissions`, `apiKey.${scope}.allowedPermissions`);
|
|
187
|
+
if (scope === "workspace" && defaults.includes("invitation:create")) {
|
|
188
|
+
throw new Error("apiKey.workspace.defaultPermissions cannot include invitation:create: workspace API keys require a user identity to send invitations");
|
|
189
|
+
}
|
|
184
190
|
}
|
|
185
191
|
assertAuthRolesExist(userRoles, [options.user?.defaultRole ?? DEFAULT_USER_ROLE], "user.defaultRole");
|
|
186
192
|
assertAuthRolesExist(userRoles, options.user?.adminRoles ?? DEFAULT_USER_ADMIN_ROLES, "user.adminRoles");
|
package/dist/auth.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../src/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAA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CAAC,CAAC,EAAE,CAAC;yBACR;wBACD,QAAQ,EAAE,eAAe,CAAC;4BACxB,eAAe,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,IAAI,iBAAiB;4BAC/D,GAAG;4BACH,QAAQ,EAAE,aAAa;yBACxB,CAAC;qBACH,CAAC;oBAEF,qBAAqB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;oBAClD,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBACvC,CAAC;aACF;SACF;QACD,OAAO,EAAE;YACP,cAAc;YACd,oBAAoB;YACpB,WAAW;YACX,iBAAiB;YACjB,sBAAsB;YACtB,SAAS;YACT,WAAW;YACX,oBAAoB;YACpB,cAAc;YACd,gBAAgB;YAChB,aAAa;YACb,iBAAiB;SAClB;KACF,CAAC;IA4DG,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAG5B,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;6CADM,iBAAiB,UAGpB,cAAc;GAhEtC,UAAU,CA6FtB;;AAED,SAAS,qBAAqB,CAC5B,MAAyB,EACzB,MAAyB;IAEzB,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACrE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClE,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAChD,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export * from "./interfaces/auth-invitation-email-data.interface.js";
|
|
|
51
51
|
export * from "./interfaces/auth-module-account-linking-options.interface.js";
|
|
52
52
|
export * from "./interfaces/auth-module-account-options.interface.js";
|
|
53
53
|
export * from "./interfaces/auth-module-api-key-options.interface.js";
|
|
54
|
+
export * from "./interfaces/auth-module-api-key-scope-options.interface.js";
|
|
54
55
|
export * from "./interfaces/auth-module-change-email-options.interface.js";
|
|
55
56
|
export * from "./interfaces/auth-module-delete-user-options.interface.js";
|
|
56
57
|
export * from "./interfaces/auth-module-email-and-password-options.interface.js";
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ export * from "./interfaces/auth-invitation-email-data.interface.js";
|
|
|
51
51
|
export * from "./interfaces/auth-module-account-linking-options.interface.js";
|
|
52
52
|
export * from "./interfaces/auth-module-account-options.interface.js";
|
|
53
53
|
export * from "./interfaces/auth-module-api-key-options.interface.js";
|
|
54
|
+
export * from "./interfaces/auth-module-api-key-scope-options.interface.js";
|
|
54
55
|
export * from "./interfaces/auth-module-change-email-options.interface.js";
|
|
55
56
|
export * from "./interfaces/auth-module-delete-user-options.interface.js";
|
|
56
57
|
export * from "./interfaces/auth-module-email-and-password-options.interface.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7D,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,gDAAgD,CAA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;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sCAAsC,CAAC;AACrD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AAExD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,kDAAkD,CAAC;AACjE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EntityManager } from "@mikro-orm/core";
|
|
2
|
+
import type { AuthModuleOptions } from "../auth-module-options.interface.js";
|
|
3
|
+
import type { UpdateApiKeyOptions } from "../interfaces/update-api-key-options.interface.js";
|
|
4
|
+
import type { ApiKey } from "../types/api-key.type.js";
|
|
5
|
+
/** Persists already-authorized key changes and publishes their committed identity effects. @internal */
|
|
6
|
+
export declare class ApiKeyLifecycle {
|
|
7
|
+
/** Validates expiration for both key creation and updates. */
|
|
8
|
+
static assertExpiration(expiresAt: Date | null | undefined): void;
|
|
9
|
+
/** Restores managed fields on persistence failure; never publishes an uncommitted credential. */
|
|
10
|
+
static update<Key extends ApiKey>(em: EntityManager, options: AuthModuleOptions, apiKey: Key, input: UpdateApiKeyOptions, permissions: string[] | undefined): Promise<Key>;
|
|
11
|
+
/** Revokes the request identity only after deletion succeeds. */
|
|
12
|
+
static delete<Key extends ApiKey>(em: EntityManager, options: AuthModuleOptions, apiKey: Key): Promise<Key>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BadRequestException } from "@nestjs/common";
|
|
2
|
+
import { RequestIdentity } from "./request-identity.js";
|
|
3
|
+
/** Persists already-authorized key changes and publishes their committed identity effects. @internal */
|
|
4
|
+
export class ApiKeyLifecycle {
|
|
5
|
+
/** Validates expiration for both key creation and updates. */
|
|
6
|
+
static assertExpiration(expiresAt) {
|
|
7
|
+
if (expiresAt && expiresAt <= new Date()) {
|
|
8
|
+
throw new BadRequestException("API key expiration must be in the future");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Restores managed fields on persistence failure; never publishes an uncommitted credential. */
|
|
12
|
+
static async update(em, options, apiKey, input, permissions) {
|
|
13
|
+
this.assertExpiration(input.expiresAt);
|
|
14
|
+
RequestIdentity.assertApiKeyCanCommit(em, apiKey);
|
|
15
|
+
const previous = {
|
|
16
|
+
name: apiKey.name,
|
|
17
|
+
enabled: apiKey.enabled,
|
|
18
|
+
expiresAt: apiKey.expiresAt,
|
|
19
|
+
permissions: apiKey.permissions,
|
|
20
|
+
lastUsedAt: apiKey.lastUsedAt,
|
|
21
|
+
};
|
|
22
|
+
if (input.name !== undefined)
|
|
23
|
+
apiKey.name = input.name;
|
|
24
|
+
if (input.enabled !== undefined)
|
|
25
|
+
apiKey.enabled = input.enabled;
|
|
26
|
+
if (input.expiresAt !== undefined)
|
|
27
|
+
apiKey.expiresAt = input.expiresAt;
|
|
28
|
+
if (permissions !== undefined)
|
|
29
|
+
apiKey.permissions = permissions;
|
|
30
|
+
// Commit the final use before revocation removes the interceptor's identity.
|
|
31
|
+
if (input.enabled === false && RequestIdentity.isCurrentApiKey(apiKey))
|
|
32
|
+
apiKey.lastUsedAt = new Date();
|
|
33
|
+
try {
|
|
34
|
+
await em.persist(apiKey).flush();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
Object.assign(apiKey, previous);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
RequestIdentity.updateApiKey(em, options, apiKey);
|
|
41
|
+
return apiKey;
|
|
42
|
+
}
|
|
43
|
+
/** Revokes the request identity only after deletion succeeds. */
|
|
44
|
+
static async delete(em, options, apiKey) {
|
|
45
|
+
RequestIdentity.assertApiKeyCanCommit(em, apiKey);
|
|
46
|
+
await em.remove(apiKey).flush();
|
|
47
|
+
RequestIdentity.updateApiKey(em, options, apiKey, true);
|
|
48
|
+
return apiKey;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=api-key-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-lifecycle.js","sourceRoot":"","sources":["../../src/infrastructure/api-key-lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,wGAAwG;AACxG,MAAM,OAAO,eAAe;IAC1B,8DAA8D;IAC9D,MAAM,CAAC,gBAAgB,CAAC,SAAkC;QACxD,IAAI,SAAS,IAAI,SAAS,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YACzC,MA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AC;YAChC,MAAM,KAAK,CAAC;QACd,CAAC;QACD,eAAe,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,EAAiB,EACjB,OAA0B,EAC1B,MAAW;QAEX,eAAe,CAAC,qBAAqB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QAChC,eAAe,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UserApiKeyPermission, UserPermission, UserRole, WorkspaceApiKeyPermission, WorkspacePermission, WorkspaceRole, } from "../enums/index.js";
|
|
2
|
+
import { resolveApiKeyPermissionCatalog } from "../utils/api-key-permissions.util.js";
|
|
2
3
|
import { createPermissionEnum } from "../utils/create-permission-enum.util.js";
|
|
3
4
|
import { resolveAuthCatalog } from "../utils/resolve-auth-catalog.util.js";
|
|
4
5
|
let activeSignature;
|
|
@@ -23,8 +24,14 @@ export class AuthEnumRegistry {
|
|
|
23
24
|
[WorkspacePermission, createPermissionEnum(workspaces)],
|
|
24
25
|
// Output enums must also serialize stored grants removed from the allowlist.
|
|
25
26
|
// Services enforce the current allowlist when creating or updating a key.
|
|
26
|
-
[
|
|
27
|
-
|
|
27
|
+
[
|
|
28
|
+
UserApiKeyPermission,
|
|
29
|
+
createPermissionEnum(resolveApiKeyPermissionCatalog(options, "user").permissions),
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
WorkspaceApiKeyPermission,
|
|
33
|
+
createPermissionEnum(resolveApiKeyPermissionCatalog(options, "workspace").permissions),
|
|
34
|
+
],
|
|
28
35
|
];
|
|
29
36
|
const signature = JSON.stringify(enums.map(([, values]) => Object.entries(values).sort(([a], [b]) => a.localeCompare(b))));
|
|
30
37
|
if (activeApplications > 0 && activeSignature !== signature) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-enum-registry.js","sourceRoot":"","sources":["../../src/infrastructure/auth-enum-registry.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,IAAI,eAAmC,CAAC;AACxC,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAE3B,wFAAwF;AACxF,MAAM,OAAO,gBAAgB;IACnB,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAY,OAA0B;QACpC,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC;QAC9D,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,WAAW,CAAC;QACxE,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC/B,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;YACvC,IAAI;SACL,CAAC,CACH,CAAC;QACJ,MAAM,KAAK,GAAG;YACZ,CAAC,QAAQ,EAAE,UAAU,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;YACjE;gBACE,aAAa;gBACb,UAAU,CAAC,kBAAkB,CAAC,OAAO,E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AAS,CAAC;QAC5B,kBAAkB,EAAE,CAAC;IACvB,CAAC;IAED,eAAe;QACb,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,kBAAkB,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -2,7 +2,7 @@ import type { MongoQuery, SubjectType } from "@casl/ability";
|
|
|
2
2
|
/** Restricted extension API; auth owns the builder and the final ability. */
|
|
3
3
|
export interface AbilityRules<Permission extends string = string> {
|
|
4
4
|
/** Grants a business action only when the principal has the named permission. Built-in auth subjects and `all` are forbidden. */
|
|
5
|
-
can(permission: Permission, action: string | string[], subject: SubjectType | SubjectType[], fieldsOrConditions?: string | string[] | MongoQuery, conditions?: MongoQuery)
|
|
5
|
+
can: (permission: Permission, action: string | string[], subject: SubjectType | SubjectType[], fieldsOrConditions?: string | string[] | MongoQuery, conditions?: MongoQuery) => void;
|
|
6
6
|
/** Adds a restriction, including conditions or fields, to business or built-in actions. */
|
|
7
|
-
cannot(action: string | string[], subject: SubjectType | SubjectType[], fieldsOrConditions?: string | string[] | MongoQuery, conditions?: MongoQuery)
|
|
7
|
+
cannot: (action: string | string[], subject: SubjectType | SubjectType[], fieldsOrConditions?: string | string[] | MongoQuery, conditions?: MongoQuery) => void;
|
|
8
8
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
defaultPermissions?: readonly Permission[];
|
|
10
|
-
/**
|
|
11
|
-
* Permissions that may be granted to any API key.
|
|
12
|
-
* Defaults to the combined user and workspace permission catalogs.
|
|
13
|
-
*/
|
|
14
|
-
allowedPermissions?: readonly Permission[];
|
|
1
|
+
import type { AuthModuleApiKeyScopeOptions } from "./auth-module-api-key-scope-options.interface.js";
|
|
2
|
+
/** Independent permission defaults and ceilings for each API-key owner type. */
|
|
3
|
+
export interface AuthModuleApiKeyOptions<UserPermission extends string = string, WorkspacePermission extends string = string> {
|
|
4
|
+
/** User keys may carry both user and workspace permissions, limited again by their owner's grants at use time. */
|
|
5
|
+
user?: AuthModuleApiKeyScopeOptions<UserPermission | WorkspacePermission>;
|
|
6
|
+
/** Workspace keys only carry workspace permissions; invitation:create requires a user identity. */
|
|
7
|
+
workspace?: AuthModuleApiKeyScopeOptions<WorkspacePermission>;
|
|
15
8
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Default selections and grant limits for one API-key owner type. */
|
|
2
|
+
export interface AuthModuleApiKeyScopeOptions<Permission extends string = string> {
|
|
3
|
+
/** Permissions used only when creation omits permissions. Defaults to an empty list. */
|
|
4
|
+
defaultPermissions?: readonly Permission[];
|
|
5
|
+
/** Grant ceiling within this scope's catalog. Omitted means the full catalog; an empty list allows no grants. */
|
|
6
|
+
allowedPermissions?: readonly Permission[];
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-module-api-key-scope-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/auth-module-api-key-scope-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -5,4 +5,6 @@ export declare class UserApiKeyPermissionOption {
|
|
|
5
5
|
permission: UserApiKeyPermission;
|
|
6
6
|
/** Includes configuration limits and the caller's grant ceiling. */
|
|
7
7
|
grantable: boolean;
|
|
8
|
+
/** Whether configuration selects this permission by default, independently of grantability. */
|
|
9
|
+
default: boolean;
|
|
8
10
|
}
|
|
@@ -15,6 +15,8 @@ let UserApiKeyPermissionOption = class UserApiKeyPermissionOption {
|
|
|
15
15
|
permission;
|
|
16
16
|
/** Includes configuration limits and the caller's grant ceiling. */
|
|
17
17
|
grantable;
|
|
18
|
+
/** Whether configuration selects this permission by default, independently of grantability. */
|
|
19
|
+
default;
|
|
18
20
|
};
|
|
19
21
|
__decorate([
|
|
20
22
|
Field(() => UserApiKeyPermission),
|
|
@@ -24,6 +26,10 @@ __decorate([
|
|
|
24
26
|
Field(() => Boolean),
|
|
25
27
|
__metadata("design:type", Boolean)
|
|
26
28
|
], UserApiKeyPermissionOption.prototype, "grantable", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
Field(() => Boolean),
|
|
31
|
+
__metadata("design:type", Boolean)
|
|
32
|
+
], UserApiKeyPermissionOption.prototype, "default", void 0);
|
|
27
33
|
UserApiKeyPermissionOption = __decorate([
|
|
28
34
|
ObjectType()
|
|
29
35
|
], UserApiKeyPermissionOption);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-api-key-permission-option.object.js","sourceRoot":"","sources":["../../src/objects/user-api-key-permission-option.object.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,qEAAqE;AAE9D,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,oDAAoD;IAEpD,UAAU,CAAwB;IAElC,oEAAoE;IAEpE,SAAS,CAAW;
|
|
1
|
+
{"version":3,"file":"user-api-key-permission-option.object.js","sourceRoot":"","sources":["../../src/objects/user-api-key-permission-option.object.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,qEAAqE;AAE9D,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,oDAAoD;IAEpD,UAAU,CAAwB;IAElC,oEAAoE;IAEpE,SAAS,CAAW;IAEpB,+FAA+F;IAE/F,OAAO,CAAW;CACnB,CAAA;AATC;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;;8DACA;AAIlC;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;;6DACD;AAIpB;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;;2DACH;AAXP,0BAA0B;IADtC,UAAU,EAAE;GACA,0BAA0B,CAYtC"}
|
|
@@ -5,4 +5,6 @@ export declare class WorkspaceApiKeyPermissionOption {
|
|
|
5
5
|
permission: WorkspaceApiKeyPermission;
|
|
6
6
|
/** Includes configuration limits, user-identity requirements and the caller's grant ceiling. */
|
|
7
7
|
grantable: boolean;
|
|
8
|
+
/** Whether configuration selects this permission by default, independently of grantability. */
|
|
9
|
+
default: boolean;
|
|
8
10
|
}
|
|
@@ -15,6 +15,8 @@ let WorkspaceApiKeyPermissionOption = class WorkspaceApiKeyPermissionOption {
|
|
|
15
15
|
permission;
|
|
16
16
|
/** Includes configuration limits, user-identity requirements and the caller's grant ceiling. */
|
|
17
17
|
grantable;
|
|
18
|
+
/** Whether configuration selects this permission by default, independently of grantability. */
|
|
19
|
+
default;
|
|
18
20
|
};
|
|
19
21
|
__decorate([
|
|
20
22
|
Field(() => WorkspaceApiKeyPermission),
|
|
@@ -24,6 +26,10 @@ __decorate([
|
|
|
24
26
|
Field(() => Boolean),
|
|
25
27
|
__metadata("design:type", Boolean)
|
|
26
28
|
], WorkspaceApiKeyPermissionOption.prototype, "grantable", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
Field(() => Boolean),
|
|
31
|
+
__metadata("design:type", Boolean)
|
|
32
|
+
], WorkspaceApiKeyPermissionOption.prototype, "default", void 0);
|
|
27
33
|
WorkspaceApiKeyPermissionOption = __decorate([
|
|
28
34
|
ObjectType()
|
|
29
35
|
], WorkspaceApiKeyPermissionOption);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-api-key-permission-option.object.js","sourceRoot":"","sources":["../../src/objects/workspace-api-key-permission-option.object.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,0EAA0E;AAEnE,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAC1C,8DAA8D;IAE9D,UAAU,CAA6B;IAEvC,gGAAgG;IAEhG,SAAS,CAAW;
|
|
1
|
+
{"version":3,"file":"workspace-api-key-permission-option.object.js","sourceRoot":"","sources":["../../src/objects/workspace-api-key-permission-option.object.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAE1F,0EAA0E;AAEnE,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAC1C,8DAA8D;IAE9D,UAAU,CAA6B;IAEvC,gGAAgG;IAEhG,SAAS,CAAW;IAEpB,+FAA+F;IAE/F,OAAO,CAAW;CACnB,CAAA;AATC;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC;;mEACA;AAIvC;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;;kEACD;AAIpB;IADC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;;gEACH;AAXP,+BAA+B;IAD3C,UAAU,EAAE;GACA,+BAA+B,CAY3C"}
|
|
@@ -32,17 +32,12 @@ export declare class UserApiKeyService {
|
|
|
32
32
|
/** Deletes an API key owned by the current user. */
|
|
33
33
|
deleteUserApiKey(id: string): Promise<UserApiKey>;
|
|
34
34
|
private createKey;
|
|
35
|
-
private updateKey;
|
|
36
|
-
private deleteKey;
|
|
37
35
|
private getVisibleApiKey;
|
|
38
36
|
private findWritableApiKey;
|
|
39
37
|
private getOwnedListFilter;
|
|
40
38
|
private assertOwner;
|
|
41
39
|
private unwrapOwner;
|
|
42
40
|
private normalizePermissions;
|
|
43
|
-
private normalizeCreatePermissions;
|
|
44
|
-
private normalizeUpdatedPermissions;
|
|
45
41
|
private assertUserPermissionCeiling;
|
|
46
|
-
private assertDelegatedApiKeyPermissionCeiling;
|
|
47
42
|
private assertPermissionCeiling;
|
|
48
43
|
}
|
|
@@ -13,11 +13,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
var UserApiKeyService_1;
|
|
14
14
|
import { EntityManager, Reference, } from "@mikro-orm/core";
|
|
15
15
|
import { ConnectionManager, } from "@nest-boot/graphql-connection";
|
|
16
|
-
import {
|
|
16
|
+
import { ForbiddenException, Inject, Injectable, Logger, NotFoundException, } from "@nestjs/common";
|
|
17
17
|
import { MODULE_OPTIONS_TOKEN } from "../auth.module-definition.js";
|
|
18
18
|
import { UserApiKeyConnection } from "../connections/user-api-key.connection-definition.js";
|
|
19
19
|
import { UserApiKey } from "../entities/user-api-key.entity.js";
|
|
20
|
-
import {
|
|
20
|
+
import { ApiKeyLifecycle } from "../infrastructure/api-key-lifecycle.js";
|
|
21
21
|
import { generateApiKey, hashApiKey, } from "../utils/api-key-credential.util.js";
|
|
22
22
|
import { resolveApiKeyPermissionCatalog } from "../utils/api-key-permissions.util.js";
|
|
23
23
|
import { normalizeAuthPermissions } from "../utils/auth-role.util.js";
|
|
@@ -41,12 +41,13 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
41
41
|
/** Lists user-key grants subject to configuration and the current credential's ceiling. */
|
|
42
42
|
getUserApiKeyPermissions(user) {
|
|
43
43
|
this.accessControlService.assertCurrentUser(user);
|
|
44
|
-
const { permissions, allowed } = resolveApiKeyPermissionCatalog(this.authOptions, "user");
|
|
44
|
+
const { permissions, allowed, defaults } = resolveApiKeyPermissionCatalog(this.authOptions, "user");
|
|
45
45
|
const allowedSet = new Set(allowed);
|
|
46
46
|
const userPermissions = new Set(resolveAuthCatalog(this.authOptions, "user").permissions);
|
|
47
47
|
const ceiling = this.accessControlService.getApiKeyPermissionCeiling();
|
|
48
48
|
return permissions.map((permission) => ({
|
|
49
49
|
permission,
|
|
50
|
+
default: defaults.includes(permission),
|
|
50
51
|
grantable: allowedSet.has(permission) &&
|
|
51
52
|
(!userPermissions.has(permission) ||
|
|
52
53
|
this.accessControlService.canGrantUserPermissions([permission])) &&
|
|
@@ -82,7 +83,9 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
82
83
|
async createUserApiKey(user, options) {
|
|
83
84
|
this.accessControlService.assertCurrentUser(user);
|
|
84
85
|
this.accessControlService.assertUserCan("create", UserApiKey);
|
|
85
|
-
const permissions = this.
|
|
86
|
+
const permissions = this.normalizePermissions(options.permissions === undefined
|
|
87
|
+
? resolveApiKeyPermissionCatalog(this.authOptions, "user").defaults
|
|
88
|
+
: (options.permissions ?? []));
|
|
86
89
|
this.assertUserPermissionCeiling(user, permissions);
|
|
87
90
|
return await this.createKey(user, options, permissions);
|
|
88
91
|
}
|
|
@@ -92,26 +95,25 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
92
95
|
const apiKey = await this.findWritableApiKey(id);
|
|
93
96
|
this.accessControlService.assertUserCan("update", apiKey);
|
|
94
97
|
const user = this.unwrapOwner(apiKey);
|
|
95
|
-
const permissions =
|
|
98
|
+
const permissions = input.permissions === undefined
|
|
99
|
+
? undefined
|
|
100
|
+
: this.normalizePermissions(input.permissions ?? []);
|
|
96
101
|
// Allow disabling stale grants without replacing them.
|
|
97
102
|
if (input.enabled !== false || permissions !== undefined) {
|
|
98
|
-
const finalPermissions = permissions ??
|
|
99
|
-
this.normalizePermissions(user, apiKey.permissions ?? []);
|
|
103
|
+
const finalPermissions = permissions ?? this.normalizePermissions(apiKey.permissions ?? []);
|
|
100
104
|
this.assertUserPermissionCeiling(user, finalPermissions);
|
|
101
105
|
}
|
|
102
|
-
return await this.
|
|
106
|
+
return await ApiKeyLifecycle.update(this.em, this.authOptions, apiKey, input, permissions);
|
|
103
107
|
}
|
|
104
108
|
/** Deletes an API key owned by the current user. */
|
|
105
109
|
async deleteUserApiKey(id) {
|
|
106
110
|
this.accessControlService.assertUserCan("delete", UserApiKey);
|
|
107
111
|
const apiKey = await this.findWritableApiKey(id);
|
|
108
112
|
this.accessControlService.assertUserCan("delete", apiKey);
|
|
109
|
-
return await this.
|
|
113
|
+
return await ApiKeyLifecycle.delete(this.em, this.authOptions, apiKey);
|
|
110
114
|
}
|
|
111
115
|
async createKey(owner, options, permissions) {
|
|
112
|
-
|
|
113
|
-
throw new BadRequestException("API key expiration must be in the future");
|
|
114
|
-
}
|
|
116
|
+
ApiKeyLifecycle.assertExpiration(options.expiresAt);
|
|
115
117
|
const prefix = options.prefix ?? process.env.API_KEY_PREFIX ?? "sk";
|
|
116
118
|
const plaintextApiKey = generateApiKey(prefix);
|
|
117
119
|
const entity = await this.em.transactional(async (em) => {
|
|
@@ -136,53 +138,13 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
136
138
|
});
|
|
137
139
|
return { apiKey: plaintextApiKey, entity };
|
|
138
140
|
}
|
|
139
|
-
async updateKey(apiKey, input, permissions) {
|
|
140
|
-
if (input.expiresAt && input.expiresAt <= new Date()) {
|
|
141
|
-
throw new BadRequestException("API key expiration must be in the future");
|
|
142
|
-
}
|
|
143
|
-
RequestIdentity.assertApiKeyCanCommit(this.em, apiKey);
|
|
144
|
-
const previous = {
|
|
145
|
-
name: apiKey.name,
|
|
146
|
-
enabled: apiKey.enabled,
|
|
147
|
-
expiresAt: apiKey.expiresAt,
|
|
148
|
-
permissions: apiKey.permissions,
|
|
149
|
-
lastUsedAt: apiKey.lastUsedAt,
|
|
150
|
-
};
|
|
151
|
-
if (input.name !== undefined)
|
|
152
|
-
apiKey.name = input.name;
|
|
153
|
-
if (input.enabled !== undefined)
|
|
154
|
-
apiKey.enabled = input.enabled;
|
|
155
|
-
if (input.expiresAt !== undefined)
|
|
156
|
-
apiKey.expiresAt = input.expiresAt;
|
|
157
|
-
if (permissions !== undefined) {
|
|
158
|
-
apiKey.permissions = permissions;
|
|
159
|
-
}
|
|
160
|
-
// Commit the final use before revocation removes the interceptor's identity.
|
|
161
|
-
if (input.enabled === false && RequestIdentity.isCurrentApiKey(apiKey))
|
|
162
|
-
apiKey.lastUsedAt = new Date();
|
|
163
|
-
try {
|
|
164
|
-
await this.em.persist(apiKey).flush();
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
Object.assign(apiKey, previous);
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
RequestIdentity.updateApiKey(this.em, this.authOptions, apiKey);
|
|
171
|
-
return apiKey;
|
|
172
|
-
}
|
|
173
|
-
async deleteKey(apiKey) {
|
|
174
|
-
RequestIdentity.assertApiKeyCanCommit(this.em, apiKey);
|
|
175
|
-
await this.em.remove(apiKey).flush();
|
|
176
|
-
RequestIdentity.updateApiKey(this.em, this.authOptions, apiKey, true);
|
|
177
|
-
return apiKey;
|
|
178
|
-
}
|
|
179
141
|
async getVisibleApiKey(id, owner) {
|
|
180
142
|
const apiKey = await this.em.findOne(UserApiKey, {
|
|
181
143
|
$and: [{ id }, this.getOwnedListFilter(owner)],
|
|
182
144
|
}, { populate: ["user"], exclude: ["key"] });
|
|
183
145
|
if (apiKey) {
|
|
184
146
|
this.assertOwner(apiKey, owner);
|
|
185
|
-
this.
|
|
147
|
+
this.accessControlService.assertApiKeyPermissionCeiling(apiKey.permissions ?? []);
|
|
186
148
|
}
|
|
187
149
|
return apiKey;
|
|
188
150
|
}
|
|
@@ -202,7 +164,7 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
202
164
|
getOwnedListFilter(owner) {
|
|
203
165
|
const ceiling = this.accessControlService.getApiKeyPermissionCeiling();
|
|
204
166
|
return {
|
|
205
|
-
|
|
167
|
+
user: owner,
|
|
206
168
|
...(ceiling !== null ? { permissions: { $contained: ceiling } } : {}),
|
|
207
169
|
};
|
|
208
170
|
}
|
|
@@ -215,32 +177,17 @@ let UserApiKeyService = UserApiKeyService_1 = class UserApiKeyService {
|
|
|
215
177
|
unwrapOwner(apiKey) {
|
|
216
178
|
return Reference.unwrapReference(apiKey.user);
|
|
217
179
|
}
|
|
218
|
-
normalizePermissions(
|
|
219
|
-
const
|
|
220
|
-
const workspacePermissions = resolveAuthCatalog(this.authOptions, "workspace").permissions;
|
|
221
|
-
const availablePermissions = [...userPermissions, ...workspacePermissions];
|
|
180
|
+
normalizePermissions(permissions) {
|
|
181
|
+
const { permissions: availablePermissions, allowed } = resolveApiKeyPermissionCatalog(this.authOptions, "user");
|
|
222
182
|
const normalizedPermissions = normalizeAuthPermissions(permissions, availablePermissions, "User API key");
|
|
223
|
-
this.assertPermissionCeiling(normalizedPermissions,
|
|
183
|
+
this.assertPermissionCeiling(normalizedPermissions, allowed, "API key permissions exceed configured allowedPermissions");
|
|
224
184
|
return normalizedPermissions;
|
|
225
185
|
}
|
|
226
|
-
normalizeCreatePermissions(owner, options) {
|
|
227
|
-
return this.normalizePermissions(owner, options.permissions === undefined
|
|
228
|
-
? (this.authOptions.apiKey?.defaultPermissions ?? [])
|
|
229
|
-
: (options.permissions ?? []));
|
|
230
|
-
}
|
|
231
|
-
normalizeUpdatedPermissions(apiKey, input) {
|
|
232
|
-
return input.permissions === undefined
|
|
233
|
-
? undefined
|
|
234
|
-
: this.normalizePermissions(this.unwrapOwner(apiKey), input.permissions ?? []);
|
|
235
|
-
}
|
|
236
186
|
assertUserPermissionCeiling(user, permissions) {
|
|
237
187
|
const userPermissionCatalog = new Set(resolveAuthCatalog(this.authOptions, "user").permissions);
|
|
238
188
|
const requestedUserPermissions = permissions.filter((permission) => userPermissionCatalog.has(permission));
|
|
239
189
|
const effectivePermissions = resolveUserPermissions(this.authOptions, user);
|
|
240
190
|
this.assertPermissionCeiling(requestedUserPermissions, effectivePermissions, "User API key permissions exceed owner permissions");
|
|
241
|
-
this.assertDelegatedApiKeyPermissionCeiling(permissions);
|
|
242
|
-
}
|
|
243
|
-
assertDelegatedApiKeyPermissionCeiling(permissions) {
|
|
244
191
|
this.accessControlService.assertApiKeyPermissionCeiling(permissions);
|
|
245
192
|
}
|
|
246
193
|
assertPermissionCeiling(requestedPermissions, effectivePermissions, message) {
|