@spinajs/authz-http-admin 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/cjs/controllers/AuthzAdminController.d.ts +35 -19
  2. package/lib/cjs/controllers/AuthzAdminController.d.ts.map +1 -1
  3. package/lib/cjs/controllers/AuthzAdminController.js +56 -28
  4. package/lib/cjs/controllers/AuthzAdminController.js.map +1 -1
  5. package/lib/cjs/routes/query.d.ts +12 -4
  6. package/lib/cjs/routes/query.d.ts.map +1 -1
  7. package/lib/cjs/routes/query.js +18 -6
  8. package/lib/cjs/routes/query.js.map +1 -1
  9. package/lib/cjs/routes/status.d.ts +1 -1
  10. package/lib/cjs/routes/status.d.ts.map +1 -1
  11. package/lib/cjs/routes/status.js +4 -2
  12. package/lib/cjs/routes/status.js.map +1 -1
  13. package/lib/cjs/schemas/bodies.d.ts +1 -0
  14. package/lib/cjs/schemas/bodies.d.ts.map +1 -1
  15. package/lib/cjs/schemas/bodies.js +3 -7
  16. package/lib/cjs/schemas/bodies.js.map +1 -1
  17. package/lib/cjs/schemas/commands.d.ts +15 -1
  18. package/lib/cjs/schemas/commands.d.ts.map +1 -1
  19. package/lib/cjs/schemas/commands.js +48 -3
  20. package/lib/cjs/schemas/commands.js.map +1 -1
  21. package/lib/cjs/schemas/document.d.ts +5 -2
  22. package/lib/cjs/schemas/document.d.ts.map +1 -1
  23. package/lib/cjs/schemas/document.js +12 -8
  24. package/lib/cjs/schemas/document.js.map +1 -1
  25. package/lib/cjs/schemas/index.d.ts +1 -0
  26. package/lib/cjs/schemas/index.d.ts.map +1 -1
  27. package/lib/cjs/schemas/index.js +1 -0
  28. package/lib/cjs/schemas/index.js.map +1 -1
  29. package/lib/cjs/schemas/primitives.d.ts +2 -0
  30. package/lib/cjs/schemas/primitives.d.ts.map +1 -1
  31. package/lib/cjs/schemas/primitives.js +10 -0
  32. package/lib/cjs/schemas/primitives.js.map +1 -1
  33. package/lib/cjs/schemas/provider.d.ts +5 -1
  34. package/lib/cjs/schemas/provider.d.ts.map +1 -1
  35. package/lib/cjs/schemas/provider.js +15 -1
  36. package/lib/cjs/schemas/provider.js.map +1 -1
  37. package/lib/cjs/schemas/registry.d.ts +21 -0
  38. package/lib/cjs/schemas/registry.d.ts.map +1 -0
  39. package/lib/cjs/schemas/registry.js +71 -0
  40. package/lib/cjs/schemas/registry.js.map +1 -0
  41. package/lib/mjs/controllers/AuthzAdminController.d.ts +35 -19
  42. package/lib/mjs/controllers/AuthzAdminController.d.ts.map +1 -1
  43. package/lib/mjs/controllers/AuthzAdminController.js +58 -30
  44. package/lib/mjs/controllers/AuthzAdminController.js.map +1 -1
  45. package/lib/mjs/routes/query.d.ts +12 -4
  46. package/lib/mjs/routes/query.d.ts.map +1 -1
  47. package/lib/mjs/routes/query.js +18 -6
  48. package/lib/mjs/routes/query.js.map +1 -1
  49. package/lib/mjs/routes/status.d.ts +1 -1
  50. package/lib/mjs/routes/status.d.ts.map +1 -1
  51. package/lib/mjs/routes/status.js +4 -2
  52. package/lib/mjs/routes/status.js.map +1 -1
  53. package/lib/mjs/schemas/bodies.d.ts +1 -0
  54. package/lib/mjs/schemas/bodies.d.ts.map +1 -1
  55. package/lib/mjs/schemas/bodies.js +4 -8
  56. package/lib/mjs/schemas/bodies.js.map +1 -1
  57. package/lib/mjs/schemas/commands.d.ts +15 -1
  58. package/lib/mjs/schemas/commands.d.ts.map +1 -1
  59. package/lib/mjs/schemas/commands.js +47 -2
  60. package/lib/mjs/schemas/commands.js.map +1 -1
  61. package/lib/mjs/schemas/document.d.ts +5 -2
  62. package/lib/mjs/schemas/document.d.ts.map +1 -1
  63. package/lib/mjs/schemas/document.js +12 -8
  64. package/lib/mjs/schemas/document.js.map +1 -1
  65. package/lib/mjs/schemas/index.d.ts +1 -0
  66. package/lib/mjs/schemas/index.d.ts.map +1 -1
  67. package/lib/mjs/schemas/index.js +1 -0
  68. package/lib/mjs/schemas/index.js.map +1 -1
  69. package/lib/mjs/schemas/primitives.d.ts +2 -0
  70. package/lib/mjs/schemas/primitives.d.ts.map +1 -1
  71. package/lib/mjs/schemas/primitives.js +9 -0
  72. package/lib/mjs/schemas/primitives.js.map +1 -1
  73. package/lib/mjs/schemas/provider.d.ts +5 -1
  74. package/lib/mjs/schemas/provider.d.ts.map +1 -1
  75. package/lib/mjs/schemas/provider.js +16 -2
  76. package/lib/mjs/schemas/provider.js.map +1 -1
  77. package/lib/mjs/schemas/registry.d.ts +21 -0
  78. package/lib/mjs/schemas/registry.d.ts.map +1 -0
  79. package/lib/mjs/schemas/registry.js +67 -0
  80. package/lib/mjs/schemas/registry.js.map +1 -0
  81. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  82. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  83. package/package.json +12 -12
@@ -0,0 +1,21 @@
1
+ import type { IContainer } from '@spinajs/di';
2
+ import type { JsonSchema } from './primitives.js';
3
+ /**
4
+ * The JSON schemas of one model's admin commands, by command kind. Each model contributes one with
5
+ * `@Injectable(AuthzCommandSchemaSource)`; the batch body of POST /authz/commands lists every registered kind.
6
+ */
7
+ export declare abstract class AuthzCommandSchemaSource {
8
+ /** Command kind -> the JSON schema of that command, `kind` included. */
9
+ abstract schemas(): Readonly<Record<string, object>>;
10
+ }
11
+ /** The command schemas of every registered AuthzCommandSchemaSource, read on each call so a late registration counts. */
12
+ export declare class AuthzCommandSchemaRegistry {
13
+ protected readonly container: IContainer;
14
+ constructor(container: IContainer);
15
+ /** Command kind -> JSON schema, merged from the sources of this container and its ancestors. */
16
+ commands(): Readonly<Record<string, JsonSchema>>;
17
+ /** The body of POST /authz/commands over the registered command kinds (schema AuthzAdminBatch). */
18
+ batch(): JsonSchema;
19
+ private sources;
20
+ }
21
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/schemas/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,8BAAsB,wBAAwB;IAC5C,wEAAwE;IACxE,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD;AASD,yHAAyH;AACzH,qBAEa,0BAA0B;IACzB,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU;IAApD,YAA+B,SAAS,EAAE,UAAU,EAAI;IAExD,gGAAgG;IACzF,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CActD;IAED,mGAAmG;IAC5F,KAAK,IAAI,UAAU,CAEzB;IAED,OAAO,CAAC,OAAO;CAShB"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthzCommandSchemaRegistry = exports.AuthzCommandSchemaSource = void 0;
13
+ const authz_1 = require("@spinajs/authz");
14
+ const di_1 = require("@spinajs/di");
15
+ const primitives_js_1 = require("./primitives.js");
16
+ /**
17
+ * The JSON schemas of one model's admin commands, by command kind. Each model contributes one with
18
+ * `@Injectable(AuthzCommandSchemaSource)`; the batch body of POST /authz/commands lists every registered kind.
19
+ */
20
+ class AuthzCommandSchemaSource {
21
+ }
22
+ exports.AuthzCommandSchemaSource = AuthzCommandSchemaSource;
23
+ const q = (v) => JSON.stringify(v);
24
+ function namesKind(schema, kind) {
25
+ const property = schema.properties?.kind;
26
+ return Array.isArray(property?.enum) && property.enum.length === 1 && property.enum[0] === kind;
27
+ }
28
+ /** The command schemas of every registered AuthzCommandSchemaSource, read on each call so a late registration counts. */
29
+ let AuthzCommandSchemaRegistry = class AuthzCommandSchemaRegistry {
30
+ constructor(container) {
31
+ this.container = container;
32
+ }
33
+ /** Command kind -> JSON schema, merged from the sources of this container and its ancestors. */
34
+ commands() {
35
+ const out = {};
36
+ const owners = new Map();
37
+ for (const source of this.sources()) {
38
+ const name = source.constructor.name;
39
+ for (const [kind, schema] of Object.entries(source.schemas())) {
40
+ const other = owners.get(kind);
41
+ if (other !== undefined)
42
+ throw new authz_1.AuthzConfigError(`Two AuthzCommandSchemaSources describe command kind ${q(kind)}: ${other} and ${name}`);
43
+ if (!namesKind(schema, kind))
44
+ throw new authz_1.AuthzConfigError(`${name}: the schema of command kind ${q(kind)} must have properties.kind.enum [${q(kind)}]`);
45
+ owners.set(kind, name);
46
+ out[kind] = schema;
47
+ }
48
+ }
49
+ return out;
50
+ }
51
+ /** The body of POST /authz/commands over the registered command kinds (schema AuthzAdminBatch). */
52
+ batch() {
53
+ return (0, primitives_js_1.commandBatch)(Object.values(this.commands()));
54
+ }
55
+ sources() {
56
+ const sources = this.container.resolve(Array.chainOf(AuthzCommandSchemaSource));
57
+ // SchemaProvider.getSchema is synchronous, so the sources must be too.
58
+ if (sources instanceof Promise) {
59
+ sources.catch(() => undefined);
60
+ throw new authz_1.AuthzConfigError('An AuthzCommandSchemaSource must not be an AsyncService');
61
+ }
62
+ return [...sources];
63
+ }
64
+ };
65
+ exports.AuthzCommandSchemaRegistry = AuthzCommandSchemaRegistry;
66
+ exports.AuthzCommandSchemaRegistry = AuthzCommandSchemaRegistry = __decorate([
67
+ (0, di_1.Singleton)(),
68
+ (0, di_1.Inject)(di_1.Container),
69
+ __metadata("design:paramtypes", [Object])
70
+ ], AuthzCommandSchemaRegistry);
71
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/schemas/registry.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAkD;AAClD,oCAA2D;AAG3D,mDAA+C;AAG/C;;;GAGG;AACH;CAGC;;AAED,MAAM,CAAC,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAEpD,SAAS,SAAS,CAAC,MAAc,EAAE,IAAY;IAC7C,MAAM,QAAQ,GAAI,MAAyD,CAAC,UAAU,EAAE,IAAI,CAAC;IAC7F,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAClG,CAAC;AAED,yHAAyH;AAGlH,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YAA+B,SAAqB;yBAArB,SAAS;IAAe,CAAC;IAExD,gGAAgG;IACzF,QAAQ;QACb,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;YACrC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;gBAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAI,KAAK,KAAK,SAAS;oBAAE,MAAM,IAAI,wBAAgB,CAAC,uDAAuD,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,EAAE,CAAC,CAAC;gBAC5I,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC;oBAAE,MAAM,IAAI,wBAAgB,CAAC,GAAG,IAAI,gCAAgC,CAAC,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACvJ,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACvB,GAAG,CAAC,IAAI,CAAC,GAAG,MAAoB,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,mGAAmG;IAC5F,KAAK;QACV,OAAO,IAAA,4BAAY,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IAEO,OAAO;QACb,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAChF,uEAAuE;QACvE,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,IAAI,wBAAgB,CAAC,yDAAyD,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;IACtB,CAAC;CACF,CAAA;;qCAlCY,0BAA0B;IAFtC,IAAA,cAAS,GAAE;IACX,IAAA,WAAM,EAAC,cAAS,CAAC;;GACL,0BAA0B,CAkCtC"}
@@ -16,8 +16,11 @@ import '../schemas/provider.js';
16
16
  export declare class AuthzAdminController extends BaseController {
17
17
  protected AdminDomain: string;
18
18
  protected Domains: AuthzDomains;
19
- /** Runs a route on the domain's AuthzAdmin; an AuthzAdminFailure becomes its status with `{ error }`, anything else propagates. */
20
- protected guarded(fn: (admin: AuthzAdmin) => Promise<Response>): Promise<Response>;
19
+ /**
20
+ * Runs a route on the AuthzAdmin of the domain the AuthzDomainResolver names for `req`, `authz.http.admin.domain` being its fallback and the domain without a request.
21
+ * An AuthzAdminFailure becomes its status with `{ error }`, a domain no live domain bears 403 `unknown_domain`, anything else propagates.
22
+ */
23
+ protected guarded(fn: (admin: AuthzAdmin) => Promise<Response>, req?: Request): Promise<Response>;
21
24
  /** One batch built from the route, with the options of the query string. */
22
25
  protected single(req: Request, build: () => AuthzCommand[]): Promise<Response<any>>;
23
26
  protected list(req: Request, build: () => AuthzAdminQuery): Promise<Response<any>>;
@@ -29,15 +32,16 @@ export declare class AuthzAdminController extends BaseController {
29
32
  * @response 200 {AuthzAdminResults} Every command succeeded
30
33
  * @response 400 {AuthzAdminError} invalid_request, invalid_batch or a validation code of the command
31
34
  * @response 401 Unauthorized: a valid session or token is required
32
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
35
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
33
36
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
34
37
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
38
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
35
39
  */
36
40
  commands(req: Request): Promise<Response<any>>;
37
41
  /**
38
42
  * List assignments
39
43
  * Lists assignments, filtered by the query.
40
- * Query: `scope` (`<type>` or `<type>:<id>`), `subject` (`<type>:<id>` or `set:<role>@<type>:<id>`), `role`, `includeExpired` (`true` or `false`), `limit`, `offset`.
44
+ * Query: `scope` (`<type>` or `<type>:<id>`), `subject` (`<type>:<id>` or `set:<role>@<type>:<id>`), `role`, `includeExpired` (`true` or `false`), `limit`, `offset` or `after` (the `next` of the previous page).
41
45
  * @response 200 {AuthzAdminPage} One page of rows
42
46
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
43
47
  * @response 401 Unauthorized: a valid session or token is required
@@ -47,7 +51,7 @@ export declare class AuthzAdminController extends BaseController {
47
51
  /**
48
52
  * List holders
49
53
  * Who holds a permission on a resource through role assignments on it, its ancestors or $global; each principal is verified by a fresh check.
50
- * Query: `scope` (`<type>:<id>`), `permission`, `expandSets` (`true` or `false`), `limit`, `offset`.
54
+ * Query: `scope` (`<type>:<id>`), `permission`, `expandSets` (`true` or `false`), `limit`, `offset` or `after` (the `next` of the previous page).
51
55
  * @response 200 {AuthzAdminPage} One page of holders
52
56
  * @response 400 {AuthzAdminError} invalid_query: a malformed or missing query parameter
53
57
  * @response 401 Unauthorized: a valid session or token is required
@@ -62,9 +66,10 @@ export declare class AuthzAdminController extends BaseController {
62
66
  * @response 200 {AuthzAdminResults} Every command succeeded
63
67
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
64
68
  * @response 401 Unauthorized: a valid session or token is required
65
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
69
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
66
70
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
67
71
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
72
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
68
73
  */
69
74
  grant(req: Request): Promise<Response<any>>;
70
75
  /**
@@ -75,9 +80,10 @@ export declare class AuthzAdminController extends BaseController {
75
80
  * @response 200 {AuthzAdminResults} Every command succeeded
76
81
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
77
82
  * @response 401 Unauthorized: a valid session or token is required
78
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
83
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
79
84
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
80
85
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
86
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
81
87
  */
82
88
  patchAssignment(req: Request): Promise<Response<any>>;
83
89
  /**
@@ -87,15 +93,16 @@ export declare class AuthzAdminController extends BaseController {
87
93
  * @response 200 {AuthzAdminResults} Every command succeeded
88
94
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
89
95
  * @response 401 Unauthorized: a valid session or token is required
90
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
96
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
91
97
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
92
98
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
99
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
93
100
  */
94
101
  revoke(req: Request): Promise<Response<any>>;
95
102
  /**
96
103
  * List share links
97
104
  * Lists the share links, filtered by the query. A listing never carries a token or its hash: the token is shown once, when the link is created.
98
- * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset`.
105
+ * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset` or `after` (the `next` of the previous page).
99
106
  * @response 200 {AuthzAdminPage} One page of rows
100
107
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
101
108
  * @response 401 Unauthorized: a valid session or token is required
@@ -110,9 +117,10 @@ export declare class AuthzAdminController extends BaseController {
110
117
  * @response 200 {AuthzAdminResults} The link was created; results[0] holds its id and token
111
118
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
112
119
  * @response 401 Unauthorized: a valid session or token is required
113
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
120
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
114
121
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
115
122
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
123
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
116
124
  */
117
125
  createLink(req: Request): Promise<Response<any>>;
118
126
  /**
@@ -123,9 +131,10 @@ export declare class AuthzAdminController extends BaseController {
123
131
  * @response 200 {AuthzAdminResults} Every command succeeded
124
132
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
125
133
  * @response 401 Unauthorized: a valid session or token is required
126
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
134
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
127
135
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
128
136
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
137
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
129
138
  */
130
139
  patchLink(req: Request): Promise<Response<any>>;
131
140
  /**
@@ -135,15 +144,16 @@ export declare class AuthzAdminController extends BaseController {
135
144
  * @response 200 {AuthzAdminResults} Every command succeeded
136
145
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
137
146
  * @response 401 Unauthorized: a valid session or token is required
138
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
147
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
139
148
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
140
149
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
150
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
141
151
  */
142
152
  revokeLink(req: Request): Promise<Response<any>>;
143
153
  /**
144
154
  * List rules
145
155
  * Lists the RBAC rules held as rows.
146
- * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset`.
156
+ * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset` or `after` (the `next` of the previous page).
147
157
  * @response 200 {AuthzAdminPage} One page of rows
148
158
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
149
159
  * @response 401 Unauthorized: a valid session or token is required
@@ -158,9 +168,10 @@ export declare class AuthzAdminController extends BaseController {
158
168
  * @response 200 {AuthzAdminResults} Every command succeeded
159
169
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
160
170
  * @response 401 Unauthorized: a valid session or token is required
161
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
171
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
162
172
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
163
173
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
174
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
164
175
  */
165
176
  putRule(req: Request): Promise<Response<any>>;
166
177
  /**
@@ -170,9 +181,10 @@ export declare class AuthzAdminController extends BaseController {
170
181
  * @response 200 {AuthzAdminResults} Every command succeeded
171
182
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
172
183
  * @response 401 Unauthorized: a valid session or token is required
173
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
184
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
174
185
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
175
186
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
187
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
176
188
  */
177
189
  deleteRule(req: Request): Promise<Response<any>>;
178
190
  /**
@@ -193,9 +205,10 @@ export declare class AuthzAdminController extends BaseController {
193
205
  * @response 200 {AuthzAdminResults} Every command succeeded
194
206
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
195
207
  * @response 401 Unauthorized: a valid session or token is required
196
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
208
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
197
209
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
198
210
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
211
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
199
212
  */
200
213
  putPolicy(req: Request): Promise<Response<any>>;
201
214
  /**
@@ -205,9 +218,10 @@ export declare class AuthzAdminController extends BaseController {
205
218
  * @response 200 {AuthzAdminResults} Every command succeeded
206
219
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
207
220
  * @response 401 Unauthorized: a valid session or token is required
208
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
221
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
209
222
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
210
223
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
224
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
211
225
  */
212
226
  deletePolicy(req: Request): Promise<Response<any>>;
213
227
  /**
@@ -227,9 +241,10 @@ export declare class AuthzAdminController extends BaseController {
227
241
  * @response 200 {AuthzAdminResults} Every command succeeded
228
242
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
229
243
  * @response 401 Unauthorized: a valid session or token is required
230
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
244
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
231
245
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
232
246
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
247
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
233
248
  */
234
249
  patchAttributes(req: Request): Promise<Response<any>>;
235
250
  /**
@@ -240,9 +255,10 @@ export declare class AuthzAdminController extends BaseController {
240
255
  * @response 200 {AuthzAdminResults} Every command succeeded
241
256
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
242
257
  * @response 401 Unauthorized: a valid session or token is required
243
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
258
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
244
259
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
245
260
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
261
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
246
262
  */
247
263
  replaceAttributes(req: Request): Promise<Response<any>>;
248
264
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AuthzAdminController.d.ts","sourceRoot":"","sources":["../../../src/controllers/AuthzAdminController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAqB,eAAe,EAAE,YAAY,EAA0B,MAAM,gBAAgB,CAAC;AAC3H,OAAO,EAAsB,cAAc,EAAgG,MAAM,eAAe,CAAC;AACjK,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIvD,OAAO,wBAAwB,CAAC;AAkEhC;;;;;;;;;GASG;AACH,qBAEa,oBAAqB,SAAQ,cAAc;IAEtD,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAG9B,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC;IAEhC,mIAAmI;IACnI,UAAgB,OAAO,CAAC,EAA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;;OAYG;IAEU,iBAAiB,CAAQ,GAAG,EAAE,OAAO,0BAEjD;CACF"}
@@ -13,8 +13,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  import { AuthzAdminFailure, AuthzDomains } from '@spinajs/authz';
14
14
  import { Config } from '@spinajs/configuration';
15
15
  import { Autoinject } from '@spinajs/di';
16
- import { BadRequestResponse, BaseController, BasePath, Conflict, Del, ForbiddenResponse, Get, NotFound, Ok, Patch, Policy, Post, Put, Req } from '@spinajs/http';
17
- import { IsAuthenticated } from '@spinajs/authz-http';
16
+ import { BadRequestResponse, BaseController, BasePath, Conflict, Del, ForbiddenResponse, Get, NotFound, Ok, Patch, Policy, Post, Put, Req, ServerError } from '@spinajs/http';
17
+ import { IsAuthenticated, UnknownAuthzDomain, resolveAuthzDomain } from '@spinajs/authz-http';
18
18
  import { isPlainObject } from '@spinajs/util';
19
19
  import '../schemas/provider.js';
20
20
  import { decodeCommand, decodeCommands } from '../routes/decode.js';
@@ -32,6 +32,8 @@ function respond(status, body) {
32
32
  return new NotFound(body);
33
33
  case 409:
34
34
  return new Conflict(body);
35
+ case 500:
36
+ return new ServerError(body);
35
37
  default:
36
38
  return new BadRequestResponse(body);
37
39
  }
@@ -54,6 +56,8 @@ function withPathId(body, id, what) {
54
56
  badRequest(`the body id ${JSON.stringify(o.id)} is not the path id ${JSON.stringify(id)}`, 'id');
55
57
  return { ...o, id };
56
58
  }
59
+ // The routes serve the RBAC and ABAC commands, whose AuthzCommandMap entries this package does not import.
60
+ const byId = (kind, id) => ({ kind, id });
57
61
  const LINK_PATCH_KEYS = ['expiresAt', 'attributes', 'role', 'tags'];
58
62
  /** PATCH /authz/links/:id as one link.update; like the assignment patch, a key it does not serve is refused, not ignored. */
59
63
  function linkUpdate(body, id) {
@@ -85,9 +89,20 @@ const scopeOf = (req) => ({ type: param(req, 'type'), id: param(req, 'id') });
85
89
  * @tags Authz admin
86
90
  */
87
91
  let AuthzAdminController = class AuthzAdminController extends BaseController {
88
- /** Runs a route on the domain's AuthzAdmin; an AuthzAdminFailure becomes its status with `{ error }`, anything else propagates. */
89
- async guarded(fn) {
90
- const admin = (await this.Domains.service(this.AdminDomain)).admin();
92
+ /**
93
+ * Runs a route on the AuthzAdmin of the domain the AuthzDomainResolver names for `req`, `authz.http.admin.domain` being its fallback and the domain without a request.
94
+ * An AuthzAdminFailure becomes its status with `{ error }`, a domain no live domain bears 403 `unknown_domain`, anything else propagates.
95
+ */
96
+ async guarded(fn, req) {
97
+ let admin;
98
+ try {
99
+ admin = (await this.Domains.service(req ? await resolveAuthzDomain(req, this.AdminDomain) : this.AdminDomain)).admin();
100
+ }
101
+ catch (e) {
102
+ if (e instanceof UnknownAuthzDomain)
103
+ return respond(403, { error: { code: 'unknown_domain', message: e.message } });
104
+ throw e;
105
+ }
91
106
  try {
92
107
  return await fn(admin);
93
108
  }
@@ -102,10 +117,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
102
117
  return this.guarded(async (admin) => {
103
118
  const opts = readWriteOptions(query(req));
104
119
  return results(await admin.execute(actorOf(req), build(), opts));
105
- });
120
+ }, req);
106
121
  }
107
122
  list(req, build) {
108
- return this.guarded(async (admin) => respond(200, await admin.list(actorOf(req), build())));
123
+ return this.guarded(async (admin) => respond(200, await admin.list(actorOf(req), build())), req);
109
124
  }
110
125
  /**
111
126
  * Run a batch of commands
@@ -115,9 +130,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
115
130
  * @response 200 {AuthzAdminResults} Every command succeeded
116
131
  * @response 400 {AuthzAdminError} invalid_request, invalid_batch or a validation code of the command
117
132
  * @response 401 Unauthorized: a valid session or token is required
118
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
133
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
119
134
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
120
135
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
136
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
121
137
  */
122
138
  async commands(req) {
123
139
  noStore(req);
@@ -128,12 +144,12 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
128
144
  if (key in body)
129
145
  opts[key] = body[key];
130
146
  return results(await admin.execute(actorOf(req), decodeCommands(body.commands), opts));
131
- });
147
+ }, req);
132
148
  }
133
149
  /**
134
150
  * List assignments
135
151
  * Lists assignments, filtered by the query.
136
- * Query: `scope` (`<type>` or `<type>:<id>`), `subject` (`<type>:<id>` or `set:<role>@<type>:<id>`), `role`, `includeExpired` (`true` or `false`), `limit`, `offset`.
152
+ * Query: `scope` (`<type>` or `<type>:<id>`), `subject` (`<type>:<id>` or `set:<role>@<type>:<id>`), `role`, `includeExpired` (`true` or `false`), `limit`, `offset` or `after` (the `next` of the previous page).
137
153
  * @response 200 {AuthzAdminPage} One page of rows
138
154
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
139
155
  * @response 401 Unauthorized: a valid session or token is required
@@ -145,7 +161,7 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
145
161
  /**
146
162
  * List holders
147
163
  * Who holds a permission on a resource through role assignments on it, its ancestors or $global; each principal is verified by a fresh check.
148
- * Query: `scope` (`<type>:<id>`), `permission`, `expandSets` (`true` or `false`), `limit`, `offset`.
164
+ * Query: `scope` (`<type>:<id>`), `permission`, `expandSets` (`true` or `false`), `limit`, `offset` or `after` (the `next` of the previous page).
149
165
  * @response 200 {AuthzAdminPage} One page of holders
150
166
  * @response 400 {AuthzAdminError} invalid_query: a malformed or missing query parameter
151
167
  * @response 401 Unauthorized: a valid session or token is required
@@ -162,9 +178,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
162
178
  * @response 200 {AuthzAdminResults} Every command succeeded
163
179
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
164
180
  * @response 401 Unauthorized: a valid session or token is required
165
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
181
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
166
182
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
167
183
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
184
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
168
185
  */
169
186
  async grant(req) {
170
187
  return this.single(req, () => [decodeCommand({ ...objectBody(req.body, 'the fields of assignment.grant'), kind: 'assignment.grant' })]);
@@ -177,9 +194,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
177
194
  * @response 200 {AuthzAdminResults} Every command succeeded
178
195
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
179
196
  * @response 401 Unauthorized: a valid session or token is required
180
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
197
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
181
198
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
182
199
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
200
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
183
201
  */
184
202
  async patchAssignment(req) {
185
203
  return this.single(req, () => {
@@ -206,17 +224,18 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
206
224
  * @response 200 {AuthzAdminResults} Every command succeeded
207
225
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
208
226
  * @response 401 Unauthorized: a valid session or token is required
209
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
227
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
210
228
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
211
229
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
230
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
212
231
  */
213
232
  async revoke(req) {
214
- return this.single(req, () => [{ kind: 'assignment.revoke', id: param(req, 'id') }]);
233
+ return this.single(req, () => [byId('assignment.revoke', param(req, 'id'))]);
215
234
  }
216
235
  /**
217
236
  * List share links
218
237
  * Lists the share links, filtered by the query. A listing never carries a token or its hash: the token is shown once, when the link is created.
219
- * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset`.
238
+ * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset` or `after` (the `next` of the previous page).
220
239
  * @response 200 {AuthzAdminPage} One page of rows
221
240
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
222
241
  * @response 401 Unauthorized: a valid session or token is required
@@ -233,9 +252,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
233
252
  * @response 200 {AuthzAdminResults} The link was created; results[0] holds its id and token
234
253
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
235
254
  * @response 401 Unauthorized: a valid session or token is required
236
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
255
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
237
256
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
238
257
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
258
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
239
259
  */
240
260
  async createLink(req) {
241
261
  noStore(req);
@@ -249,9 +269,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
249
269
  * @response 200 {AuthzAdminResults} Every command succeeded
250
270
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
251
271
  * @response 401 Unauthorized: a valid session or token is required
252
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
272
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
253
273
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
254
274
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
275
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
255
276
  */
256
277
  async patchLink(req) {
257
278
  return this.single(req, () => [linkUpdate(req.body, param(req, 'id'))]);
@@ -263,17 +284,18 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
263
284
  * @response 200 {AuthzAdminResults} Every command succeeded
264
285
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
265
286
  * @response 401 Unauthorized: a valid session or token is required
266
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
287
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
267
288
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
268
289
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
290
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
269
291
  */
270
292
  async revokeLink(req) {
271
- return this.single(req, () => [{ kind: 'link.revoke', id: param(req, 'id') }]);
293
+ return this.single(req, () => [byId('link.revoke', param(req, 'id'))]);
272
294
  }
273
295
  /**
274
296
  * List rules
275
297
  * Lists the RBAC rules held as rows.
276
- * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset`.
298
+ * Query: `scope` (`<type>` or `<type>:<id>`), `limit`, `offset` or `after` (the `next` of the previous page).
277
299
  * @response 200 {AuthzAdminPage} One page of rows
278
300
  * @response 400 {AuthzAdminError} invalid_query: a malformed query parameter
279
301
  * @response 401 Unauthorized: a valid session or token is required
@@ -290,9 +312,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
290
312
  * @response 200 {AuthzAdminResults} Every command succeeded
291
313
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
292
314
  * @response 401 Unauthorized: a valid session or token is required
293
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
315
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
294
316
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
295
317
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
318
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
296
319
  */
297
320
  async putRule(req) {
298
321
  return this.single(req, () => [decodeCommand({ kind: 'rule.put', rule: withPathId(req.body, param(req, 'id'), 'a rule') })]);
@@ -304,12 +327,13 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
304
327
  * @response 200 {AuthzAdminResults} Every command succeeded
305
328
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
306
329
  * @response 401 Unauthorized: a valid session or token is required
307
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
330
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
308
331
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
309
332
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
333
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
310
334
  */
311
335
  async deleteRule(req) {
312
- return this.single(req, () => [{ kind: 'rule.delete', id: param(req, 'id') }]);
336
+ return this.single(req, () => [byId('rule.delete', param(req, 'id'))]);
313
337
  }
314
338
  /**
315
339
  * List policies
@@ -331,9 +355,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
331
355
  * @response 200 {AuthzAdminResults} Every command succeeded
332
356
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
333
357
  * @response 401 Unauthorized: a valid session or token is required
334
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
358
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
335
359
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
336
360
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
361
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
337
362
  */
338
363
  async putPolicy(req) {
339
364
  return this.single(req, () => [decodeCommand({ kind: 'policy.put', policy: withPathId(req.body, param(req, 'id'), 'a policy') })]);
@@ -345,12 +370,13 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
345
370
  * @response 200 {AuthzAdminResults} Every command succeeded
346
371
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
347
372
  * @response 401 Unauthorized: a valid session or token is required
348
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
373
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
349
374
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
350
375
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
376
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
351
377
  */
352
378
  async deletePolicy(req) {
353
- return this.single(req, () => [{ kind: 'policy.delete', id: param(req, 'id') }]);
379
+ return this.single(req, () => [byId('policy.delete', param(req, 'id'))]);
354
380
  }
355
381
  /**
356
382
  * Read scope attributes
@@ -371,9 +397,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
371
397
  * @response 200 {AuthzAdminResults} Every command succeeded
372
398
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
373
399
  * @response 401 Unauthorized: a valid session or token is required
374
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
400
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
375
401
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
376
402
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
403
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
377
404
  */
378
405
  async patchAttributes(req) {
379
406
  return this.single(req, () => [{ kind: 'scope.setAttributes', scope: scopeOf(req), patch: req.body }]);
@@ -386,9 +413,10 @@ let AuthzAdminController = class AuthzAdminController extends BaseController {
386
413
  * @response 200 {AuthzAdminResults} Every command succeeded
387
414
  * @response 400 {AuthzAdminError} invalid_request, invalid_query (an option of the query string), invalid_batch or a validation code of the command
388
415
  * @response 401 Unauthorized: a valid session or token is required
389
- * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout or protected_role
416
+ * @response 403 {AuthzAdminError} forbidden, escalation, last_holder, self_lockout, protected_role or hook:<code> (an action hook refused)
390
417
  * @response 404 {AuthzAdminError} not_found: a row the command names does not exist
391
418
  * @response 409 {AuthzAdminError} conflict: the row changed or exists already
419
+ * @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
392
420
  */
393
421
  async replaceAttributes(req) {
394
422
  return this.single(req, () => [{ kind: 'scope.replaceAttributes', scope: scopeOf(req), attributes: req.body }]);
@@ -537,7 +565,7 @@ __decorate([
537
565
  ], AuthzAdminController.prototype, "replaceAttributes", null);
538
566
  AuthzAdminController = __decorate([
539
567
  Policy(IsAuthenticated),
540
- BasePath('authz')
568
+ BasePath({ config: 'authz.http.admin.basePath', default: 'authz' })
541
569
  ], AuthzAdminController);
542
570
  export { AuthzAdminController };
543
571
  function results(r) {