@spinajs/authz-http-admin 3.0.12 → 3.0.14
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 +9 -8
- package/lib/cjs/controllers/AuthzAdminController.d.ts +35 -29
- package/lib/cjs/controllers/AuthzAdminController.d.ts.map +1 -1
- package/lib/cjs/controllers/AuthzAdminController.js +172 -175
- package/lib/cjs/controllers/AuthzAdminController.js.map +1 -1
- package/lib/cjs/dto/assignments.d.ts +33 -0
- package/lib/cjs/dto/assignments.d.ts.map +1 -0
- package/lib/cjs/dto/assignments.js +39 -0
- package/lib/cjs/dto/assignments.js.map +1 -0
- package/lib/cjs/dto/attributes.d.ts +20 -0
- package/lib/cjs/dto/attributes.d.ts.map +1 -0
- package/lib/cjs/dto/attributes.js +29 -0
- package/lib/cjs/dto/attributes.js.map +1 -0
- package/lib/cjs/dto/batch.d.ts +11 -0
- package/lib/cjs/dto/batch.d.ts.map +1 -0
- package/lib/cjs/dto/batch.js +10 -0
- package/lib/cjs/dto/batch.js.map +1 -0
- package/lib/cjs/dto/index.d.ts +9 -0
- package/lib/cjs/dto/index.d.ts.map +1 -0
- package/lib/cjs/dto/index.js +25 -0
- package/lib/cjs/dto/index.js.map +1 -0
- package/lib/cjs/dto/input.d.ts +8 -0
- package/lib/cjs/dto/input.d.ts.map +1 -0
- package/lib/cjs/dto/input.js +19 -0
- package/lib/cjs/dto/input.js.map +1 -0
- package/lib/cjs/dto/links.d.ts +28 -0
- package/lib/cjs/dto/links.d.ts.map +1 -0
- package/lib/cjs/dto/links.js +40 -0
- package/lib/cjs/dto/links.js.map +1 -0
- package/lib/cjs/dto/params.d.ts +19 -0
- package/lib/cjs/dto/params.d.ts.map +1 -0
- package/lib/cjs/dto/params.js +9 -0
- package/lib/cjs/dto/params.js.map +1 -0
- package/lib/cjs/dto/queries.d.ts +37 -0
- package/lib/cjs/dto/queries.d.ts.map +1 -0
- package/lib/cjs/dto/queries.js +70 -0
- package/lib/cjs/dto/queries.js.map +1 -0
- package/lib/cjs/dto/rules.d.ts +18 -0
- package/lib/cjs/dto/rules.d.ts.map +1 -0
- package/lib/cjs/dto/rules.js +34 -0
- package/lib/cjs/dto/rules.js.map +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/routes/answers.d.ts +22 -0
- package/lib/cjs/routes/answers.d.ts.map +1 -0
- package/lib/cjs/routes/answers.js +121 -0
- package/lib/cjs/routes/answers.js.map +1 -0
- package/lib/cjs/routes/args.d.ts +59 -0
- package/lib/cjs/routes/args.d.ts.map +1 -0
- package/lib/cjs/routes/args.js +167 -0
- package/lib/cjs/routes/args.js.map +1 -0
- package/lib/cjs/routes/index.d.ts +3 -0
- package/lib/cjs/routes/index.d.ts.map +1 -1
- package/lib/cjs/routes/index.js +3 -0
- package/lib/cjs/routes/index.js.map +1 -1
- package/lib/cjs/routes/no-store.d.ts +10 -0
- package/lib/cjs/routes/no-store.d.ts.map +1 -0
- package/lib/cjs/routes/no-store.js +18 -0
- package/lib/cjs/routes/no-store.js.map +1 -0
- package/lib/cjs/routes/query.d.ts +6 -7
- package/lib/cjs/routes/query.d.ts.map +1 -1
- package/lib/cjs/routes/query.js +15 -62
- package/lib/cjs/routes/query.js.map +1 -1
- package/lib/cjs/schemas/answers.d.ts +7 -0
- package/lib/cjs/schemas/answers.d.ts.map +1 -0
- package/lib/cjs/schemas/answers.js +14 -0
- package/lib/cjs/schemas/answers.js.map +1 -0
- package/lib/cjs/schemas/commands.d.ts +4 -0
- package/lib/cjs/schemas/commands.d.ts.map +1 -1
- package/lib/cjs/schemas/commands.js +20 -12
- package/lib/cjs/schemas/commands.js.map +1 -1
- package/lib/cjs/schemas/document.d.ts +8 -17
- package/lib/cjs/schemas/document.d.ts.map +1 -1
- package/lib/cjs/schemas/document.js +53 -64
- package/lib/cjs/schemas/document.js.map +1 -1
- package/lib/cjs/schemas/index.d.ts +1 -1
- package/lib/cjs/schemas/index.d.ts.map +1 -1
- package/lib/cjs/schemas/index.js +1 -1
- package/lib/cjs/schemas/index.js.map +1 -1
- package/lib/cjs/schemas/primitives.d.ts +8 -1
- package/lib/cjs/schemas/primitives.d.ts.map +1 -1
- package/lib/cjs/schemas/primitives.js +25 -15
- package/lib/cjs/schemas/primitives.js.map +1 -1
- package/lib/cjs/schemas/provider.d.ts +4 -4
- package/lib/cjs/schemas/provider.d.ts.map +1 -1
- package/lib/cjs/schemas/provider.js +6 -6
- package/lib/cjs/schemas/provider.js.map +1 -1
- package/lib/mjs/controllers/AuthzAdminController.d.ts +35 -29
- package/lib/mjs/controllers/AuthzAdminController.d.ts.map +1 -1
- package/lib/mjs/controllers/AuthzAdminController.js +174 -177
- package/lib/mjs/controllers/AuthzAdminController.js.map +1 -1
- package/lib/mjs/dto/assignments.d.ts +33 -0
- package/lib/mjs/dto/assignments.d.ts.map +1 -0
- package/lib/mjs/dto/assignments.js +36 -0
- package/lib/mjs/dto/assignments.js.map +1 -0
- package/lib/mjs/dto/attributes.d.ts +20 -0
- package/lib/mjs/dto/attributes.d.ts.map +1 -0
- package/lib/mjs/dto/attributes.js +26 -0
- package/lib/mjs/dto/attributes.js.map +1 -0
- package/lib/mjs/dto/batch.d.ts +11 -0
- package/lib/mjs/dto/batch.d.ts.map +1 -0
- package/lib/mjs/dto/batch.js +7 -0
- package/lib/mjs/dto/batch.js.map +1 -0
- package/lib/mjs/dto/index.d.ts +9 -0
- package/lib/mjs/dto/index.d.ts.map +1 -0
- package/lib/mjs/dto/index.js +9 -0
- package/lib/mjs/dto/index.js.map +1 -0
- package/lib/mjs/dto/input.d.ts +8 -0
- package/lib/mjs/dto/input.d.ts.map +1 -0
- package/lib/mjs/dto/input.js +15 -0
- package/lib/mjs/dto/input.js.map +1 -0
- package/lib/mjs/dto/links.d.ts +28 -0
- package/lib/mjs/dto/links.d.ts.map +1 -0
- package/lib/mjs/dto/links.js +37 -0
- package/lib/mjs/dto/links.js.map +1 -0
- package/lib/mjs/dto/params.d.ts +19 -0
- package/lib/mjs/dto/params.d.ts.map +1 -0
- package/lib/mjs/dto/params.js +6 -0
- package/lib/mjs/dto/params.js.map +1 -0
- package/lib/mjs/dto/queries.d.ts +37 -0
- package/lib/mjs/dto/queries.d.ts.map +1 -0
- package/lib/mjs/dto/queries.js +66 -0
- package/lib/mjs/dto/queries.js.map +1 -0
- package/lib/mjs/dto/rules.d.ts +18 -0
- package/lib/mjs/dto/rules.d.ts.map +1 -0
- package/lib/mjs/dto/rules.js +31 -0
- package/lib/mjs/dto/rules.js.map +1 -0
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +1 -0
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/routes/answers.d.ts +22 -0
- package/lib/mjs/routes/answers.d.ts.map +1 -0
- package/lib/mjs/routes/answers.js +115 -0
- package/lib/mjs/routes/answers.js.map +1 -0
- package/lib/mjs/routes/args.d.ts +59 -0
- package/lib/mjs/routes/args.d.ts.map +1 -0
- package/lib/mjs/routes/args.js +160 -0
- package/lib/mjs/routes/args.js.map +1 -0
- package/lib/mjs/routes/index.d.ts +3 -0
- package/lib/mjs/routes/index.d.ts.map +1 -1
- package/lib/mjs/routes/index.js +3 -0
- package/lib/mjs/routes/index.js.map +1 -1
- package/lib/mjs/routes/no-store.d.ts +10 -0
- package/lib/mjs/routes/no-store.d.ts.map +1 -0
- package/lib/mjs/routes/no-store.js +14 -0
- package/lib/mjs/routes/no-store.js.map +1 -0
- package/lib/mjs/routes/query.d.ts +6 -7
- package/lib/mjs/routes/query.d.ts.map +1 -1
- package/lib/mjs/routes/query.js +15 -62
- package/lib/mjs/routes/query.js.map +1 -1
- package/lib/mjs/schemas/answers.d.ts +7 -0
- package/lib/mjs/schemas/answers.d.ts.map +1 -0
- package/lib/mjs/schemas/answers.js +11 -0
- package/lib/mjs/schemas/answers.js.map +1 -0
- package/lib/mjs/schemas/commands.d.ts +4 -0
- package/lib/mjs/schemas/commands.d.ts.map +1 -1
- package/lib/mjs/schemas/commands.js +19 -12
- package/lib/mjs/schemas/commands.js.map +1 -1
- package/lib/mjs/schemas/document.d.ts +8 -17
- package/lib/mjs/schemas/document.d.ts.map +1 -1
- package/lib/mjs/schemas/document.js +53 -63
- package/lib/mjs/schemas/document.js.map +1 -1
- package/lib/mjs/schemas/index.d.ts +1 -1
- package/lib/mjs/schemas/index.d.ts.map +1 -1
- package/lib/mjs/schemas/index.js +1 -1
- package/lib/mjs/schemas/index.js.map +1 -1
- package/lib/mjs/schemas/primitives.d.ts +8 -1
- package/lib/mjs/schemas/primitives.d.ts.map +1 -1
- package/lib/mjs/schemas/primitives.js +22 -14
- package/lib/mjs/schemas/primitives.js.map +1 -1
- package/lib/mjs/schemas/provider.d.ts +4 -4
- package/lib/mjs/schemas/provider.d.ts.map +1 -1
- package/lib/mjs/schemas/provider.js +6 -6
- package/lib/mjs/schemas/provider.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/lib/cjs/schemas/bodies.d.ts +0 -17
- package/lib/cjs/schemas/bodies.d.ts.map +0 -1
- package/lib/cjs/schemas/bodies.js +0 -35
- package/lib/cjs/schemas/bodies.js.map +0 -1
- package/lib/mjs/schemas/bodies.d.ts +0 -17
- package/lib/mjs/schemas/bodies.d.ts.map +0 -1
- package/lib/mjs/schemas/bodies.js +0 -32
- package/lib/mjs/schemas/bodies.js.map +0 -1
|
@@ -18,112 +18,63 @@ const configuration_1 = require("@spinajs/configuration");
|
|
|
18
18
|
const di_1 = require("@spinajs/di");
|
|
19
19
|
const http_1 = require("@spinajs/http");
|
|
20
20
|
const authz_http_1 = require("@spinajs/authz-http");
|
|
21
|
-
const
|
|
21
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
22
|
+
const validation_1 = require("@spinajs/validation");
|
|
22
23
|
require("../schemas/provider.js");
|
|
24
|
+
const assignments_js_1 = require("../dto/assignments.js");
|
|
25
|
+
const attributes_js_1 = require("../dto/attributes.js");
|
|
26
|
+
const links_js_1 = require("../dto/links.js");
|
|
27
|
+
const params_js_1 = require("../dto/params.js");
|
|
28
|
+
const queries_js_1 = require("../dto/queries.js");
|
|
29
|
+
const rules_js_1 = require("../dto/rules.js");
|
|
30
|
+
const answers_js_1 = require("../routes/answers.js");
|
|
31
|
+
const args_js_1 = require("../routes/args.js");
|
|
23
32
|
const decode_js_1 = require("../routes/decode.js");
|
|
33
|
+
const no_store_js_1 = require("../routes/no-store.js");
|
|
24
34
|
const query_js_1 = require("../routes/query.js");
|
|
25
35
|
const status_js_1 = require("../routes/status.js");
|
|
26
|
-
const PATCH_KEYS = ['tags', 'addTags', 'removeTags', 'expiresAt'];
|
|
27
36
|
const PATCH_KINDS = { tags: 'assignment.setTags', addTags: 'assignment.addTags', removeTags: 'assignment.removeTags' };
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return new http_1.ForbiddenResponse(body);
|
|
34
|
-
case 404:
|
|
35
|
-
return new http_1.NotFound(body);
|
|
36
|
-
case 409:
|
|
37
|
-
return new http_1.Conflict(body);
|
|
38
|
-
case 500:
|
|
39
|
-
return new http_1.ServerError(body);
|
|
40
|
-
default:
|
|
41
|
-
return new http_1.BadRequestResponse(body);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function refused(e) {
|
|
45
|
-
return respond((0, status_js_1.adminErrorStatus)(e.code), { error: { code: e.code, message: e.message, ...(e.field === undefined ? {} : { field: e.field }) } });
|
|
46
|
-
}
|
|
47
|
-
function badRequest(message, field) {
|
|
48
|
-
throw new authz_1.AuthzAdminFailure('invalid_request', message, field);
|
|
49
|
-
}
|
|
50
|
-
function objectBody(body, what) {
|
|
51
|
-
if (!(0, util_1.isPlainObject)(body))
|
|
52
|
-
badRequest(`the body must be ${what}`);
|
|
53
|
-
return body;
|
|
54
|
-
}
|
|
55
|
-
/** The body of PUT /authz/rules/:id or /authz/policies/:id with the path id; an id in the body must equal it. */
|
|
56
|
-
function withPathId(body, id, what) {
|
|
57
|
-
const o = objectBody(body, what);
|
|
58
|
-
if (o.id !== undefined && o.id !== id)
|
|
59
|
-
badRequest(`the body id ${JSON.stringify(o.id)} is not the path id ${JSON.stringify(id)}`, 'id');
|
|
60
|
-
return { ...o, id };
|
|
37
|
+
/** A body the route runs under its path id; an id in the body must equal it. */
|
|
38
|
+
function withPathId(body, id) {
|
|
39
|
+
if (body.id !== undefined && body.id !== id)
|
|
40
|
+
throw new authz_1.AuthzAdminFailure('invalid_request', `the body id ${JSON.stringify(body.id)} is not the path id ${JSON.stringify(id)}`, 'id');
|
|
41
|
+
return { ...body, id };
|
|
61
42
|
}
|
|
62
43
|
// The routes serve the RBAC and ABAC commands, whose AuthzCommandMap entries this package does not import.
|
|
63
44
|
const byId = (kind, id) => ({ kind, id });
|
|
64
|
-
const
|
|
65
|
-
/** PATCH /authz/links/:id as one link.update; like the assignment patch, a key it does not serve is refused, not ignored. */
|
|
66
|
-
function linkUpdate(body, id) {
|
|
67
|
-
const patch = withPathId(body, id, 'an object { expiresAt?, attributes?, role?, tags? }');
|
|
68
|
-
const unknown = Object.keys(patch).find((k) => k !== 'id' && !LINK_PATCH_KEYS.includes(k));
|
|
69
|
-
if (unknown !== undefined)
|
|
70
|
-
badRequest(`a link patch takes ${LINK_PATCH_KEYS.join(', ')}, not ${JSON.stringify(unknown)}`, unknown);
|
|
71
|
-
if (!LINK_PATCH_KEYS.some((k) => k in patch))
|
|
72
|
-
badRequest(`a link patch needs one of ${LINK_PATCH_KEYS.join(', ')}`);
|
|
73
|
-
return (0, decode_js_1.decodeCommand)({ ...patch, kind: 'link.update' });
|
|
74
|
-
}
|
|
75
|
-
/** For answers that may hold a link token: no proxy or browser cache may keep one. Set first, so it goes out with any answer the route gives. */
|
|
76
|
-
function noStore(req) {
|
|
77
|
-
req.res?.setHeader('Cache-Control', 'no-store');
|
|
78
|
-
req.res?.setHeader('Pragma', 'no-cache');
|
|
79
|
-
}
|
|
80
|
-
const query = (req) => (req.query ?? {});
|
|
81
|
-
const param = (req, name) => req.params[name];
|
|
82
|
-
const actorOf = (req) => req.storage.Principal;
|
|
83
|
-
const scopeOf = (req) => ({ type: param(req, 'type'), id: param(req, 'id') });
|
|
45
|
+
const asCommand = (c) => (0, decode_js_1.decodeCommand)(c);
|
|
84
46
|
/**
|
|
85
47
|
* Admin routes over the management API of the configured domain (`authz.http.admin.domain`).
|
|
86
48
|
*
|
|
87
49
|
* The routes check authentication only: the actor is always the request principal, and every
|
|
88
|
-
* permission
|
|
89
|
-
*
|
|
90
|
-
* `{ results }`, one entry per command.
|
|
50
|
+
* permission and guard check runs in AuthzAdmin, as for an in-process caller (design §6.6.5). The
|
|
51
|
+
* inputs are DTOs checked against their schemas first; a refused request answers
|
|
52
|
+
* `{ error: { code, message, field? } }`, a write `{ results }`, one entry per command.
|
|
91
53
|
*
|
|
92
54
|
* @tags Authz admin
|
|
93
55
|
*/
|
|
94
56
|
let AuthzAdminController = class AuthzAdminController extends http_1.BaseController {
|
|
95
57
|
/**
|
|
96
|
-
* Runs a route on the AuthzAdmin of
|
|
97
|
-
* An AuthzAdminFailure becomes its status with `{ error }`,
|
|
58
|
+
* Runs a route on the AuthzAdmin of `domain` (the one `@AdminDomain()` resolved), `authz.http.admin.domain` without one.
|
|
59
|
+
* An AuthzAdminFailure becomes its status with `{ error }`, anything else propagates.
|
|
98
60
|
*/
|
|
99
|
-
async guarded(fn,
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
admin = (await this.Domains.service(req ? await (0, authz_http_1.resolveAuthzDomain)(req, this.AdminDomain) : this.AdminDomain)).admin();
|
|
103
|
-
}
|
|
104
|
-
catch (e) {
|
|
105
|
-
if (e instanceof authz_http_1.UnknownAuthzDomain)
|
|
106
|
-
return respond(403, { error: { code: 'unknown_domain', message: e.message } });
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
61
|
+
async guarded(fn, domain) {
|
|
62
|
+
const admin = (await this.Domains.service(domain ?? this.AdminDomain)).admin();
|
|
109
63
|
try {
|
|
110
64
|
return await fn(admin);
|
|
111
65
|
}
|
|
112
66
|
catch (e) {
|
|
113
67
|
if (e instanceof authz_1.AuthzAdminFailure)
|
|
114
|
-
return refused(e);
|
|
68
|
+
return (0, answers_js_1.refused)(e);
|
|
115
69
|
throw e;
|
|
116
70
|
}
|
|
117
71
|
}
|
|
118
72
|
/** One batch built from the route, with the options of the query string. */
|
|
119
|
-
single(
|
|
120
|
-
return this.guarded(async (admin) =>
|
|
121
|
-
const opts = (0, query_js_1.readWriteOptions)(query(req));
|
|
122
|
-
return results(await admin.execute(actorOf(req), build(), opts));
|
|
123
|
-
}, req);
|
|
73
|
+
single(domain, actor, options, build) {
|
|
74
|
+
return this.guarded(async (admin) => results(await admin.execute(actor, build(), (0, query_js_1.readWriteOptions)(options))), domain);
|
|
124
75
|
}
|
|
125
|
-
list(
|
|
126
|
-
return this.guarded(async (admin) => respond(200, await admin.list(
|
|
76
|
+
list(domain, actor, build) {
|
|
77
|
+
return this.guarded(async (admin) => (0, answers_js_1.respond)(200, await admin.list(actor, build())), domain);
|
|
127
78
|
}
|
|
128
79
|
/**
|
|
129
80
|
* Run a batch of commands
|
|
@@ -138,16 +89,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
138
89
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
139
90
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
140
91
|
*/
|
|
141
|
-
async commands(
|
|
142
|
-
|
|
143
|
-
return this.guarded(async (admin) => {
|
|
144
|
-
const body = objectBody(req.body, 'an object { commands, reason?, idempotencyKey?, dryRun? }');
|
|
145
|
-
const opts = {};
|
|
146
|
-
for (const key of ['reason', 'idempotencyKey', 'dryRun'])
|
|
147
|
-
if (key in body)
|
|
148
|
-
opts[key] = body[key];
|
|
149
|
-
return results(await admin.execute(actorOf(req), (0, decode_js_1.decodeCommands)(body.commands), opts));
|
|
150
|
-
}, req);
|
|
92
|
+
async commands(domain, actor, batch) {
|
|
93
|
+
return this.guarded(async (admin) => results(await admin.execute(actor, batch.commands, batch.options)), domain);
|
|
151
94
|
}
|
|
152
95
|
/**
|
|
153
96
|
* List assignments
|
|
@@ -158,8 +101,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
158
101
|
* @response 401 Unauthorized: a valid session or token is required
|
|
159
102
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks the read permission at the scope
|
|
160
103
|
*/
|
|
161
|
-
async listAssignments(
|
|
162
|
-
return this.list(
|
|
104
|
+
async listAssignments(domain, actor, query) {
|
|
105
|
+
return this.list(domain, actor, () => (0, query_js_1.readAssignmentsQuery)(query));
|
|
163
106
|
}
|
|
164
107
|
/**
|
|
165
108
|
* List holders
|
|
@@ -170,8 +113,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
170
113
|
* @response 401 Unauthorized: a valid session or token is required
|
|
171
114
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks authz:holders.read at the resource, or the resource is unknown
|
|
172
115
|
*/
|
|
173
|
-
async listHolders(
|
|
174
|
-
return this.list(
|
|
116
|
+
async listHolders(domain, actor, query) {
|
|
117
|
+
return this.list(domain, actor, () => (0, query_js_1.readHoldersQuery)(query));
|
|
175
118
|
}
|
|
176
119
|
/**
|
|
177
120
|
* Grant a role
|
|
@@ -186,8 +129,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
186
129
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
187
130
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
188
131
|
*/
|
|
189
|
-
async grant(
|
|
190
|
-
return this.single(
|
|
132
|
+
async grant(domain, actor, body, options) {
|
|
133
|
+
return this.single(domain, actor, options, () => [asCommand({ ...body, kind: 'assignment.grant' })]);
|
|
191
134
|
}
|
|
192
135
|
/**
|
|
193
136
|
* Change an assignment
|
|
@@ -202,21 +145,14 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
202
145
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
203
146
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
204
147
|
*/
|
|
205
|
-
async patchAssignment(
|
|
206
|
-
return this.single(
|
|
207
|
-
const body = objectBody(req.body, 'an object { tags?, addTags?, removeTags?, expiresAt? }');
|
|
208
|
-
const unknown = Object.keys(body).find((k) => !PATCH_KEYS.includes(k));
|
|
209
|
-
if (unknown !== undefined)
|
|
210
|
-
badRequest(`an assignment patch takes ${PATCH_KEYS.join(', ')}, not ${JSON.stringify(unknown)}`, unknown);
|
|
211
|
-
const id = param(req, 'id');
|
|
148
|
+
async patchAssignment(domain, actor, id, body, options) {
|
|
149
|
+
return this.single(domain, actor, options, () => {
|
|
212
150
|
const commands = [];
|
|
213
151
|
for (const key of ['tags', 'addTags', 'removeTags'])
|
|
214
|
-
if (key
|
|
152
|
+
if (body[key] !== undefined)
|
|
215
153
|
commands.push({ kind: PATCH_KINDS[key], id, tags: body[key] });
|
|
216
|
-
if (
|
|
217
|
-
commands.push((
|
|
218
|
-
if (commands.length === 0)
|
|
219
|
-
badRequest(`an assignment patch needs one of ${PATCH_KEYS.join(', ')}`);
|
|
154
|
+
if (body.expiresAt !== undefined)
|
|
155
|
+
commands.push(asCommand({ kind: 'assignment.setExpiry', id, expiresAt: body.expiresAt }));
|
|
220
156
|
return commands;
|
|
221
157
|
});
|
|
222
158
|
}
|
|
@@ -232,8 +168,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
232
168
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
233
169
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
234
170
|
*/
|
|
235
|
-
async revoke(
|
|
236
|
-
return this.single(
|
|
171
|
+
async revoke(domain, actor, id, options) {
|
|
172
|
+
return this.single(domain, actor, options, () => [byId('assignment.revoke', id)]);
|
|
237
173
|
}
|
|
238
174
|
/**
|
|
239
175
|
* List share links
|
|
@@ -244,8 +180,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
244
180
|
* @response 401 Unauthorized: a valid session or token is required
|
|
245
181
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks the read permission at the scope
|
|
246
182
|
*/
|
|
247
|
-
async listLinks(
|
|
248
|
-
return this.list(
|
|
183
|
+
async listLinks(domain, actor, query) {
|
|
184
|
+
return this.list(domain, actor, () => (0, query_js_1.readPageQuery)('links', query));
|
|
249
185
|
}
|
|
250
186
|
/**
|
|
251
187
|
* Create a share link
|
|
@@ -260,9 +196,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
260
196
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
261
197
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
262
198
|
*/
|
|
263
|
-
async createLink(
|
|
264
|
-
|
|
265
|
-
return this.single(req, () => [(0, decode_js_1.decodeCommand)({ ...objectBody(req.body, 'the fields of link.create'), kind: 'link.create' })]);
|
|
199
|
+
async createLink(domain, actor, body, options) {
|
|
200
|
+
return this.single(domain, actor, options, () => [asCommand({ ...body, kind: 'link.create' })]);
|
|
266
201
|
}
|
|
267
202
|
/**
|
|
268
203
|
* Change a share link
|
|
@@ -277,8 +212,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
277
212
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
278
213
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
279
214
|
*/
|
|
280
|
-
async patchLink(
|
|
281
|
-
return this.single(
|
|
215
|
+
async patchLink(domain, actor, id, body, options) {
|
|
216
|
+
return this.single(domain, actor, options, () => [asCommand({ ...withPathId(body, id), kind: 'link.update' })]);
|
|
282
217
|
}
|
|
283
218
|
/**
|
|
284
219
|
* Revoke a share link
|
|
@@ -292,8 +227,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
292
227
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
293
228
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
294
229
|
*/
|
|
295
|
-
async revokeLink(
|
|
296
|
-
return this.single(
|
|
230
|
+
async revokeLink(domain, actor, id, options) {
|
|
231
|
+
return this.single(domain, actor, options, () => [byId('link.revoke', id)]);
|
|
297
232
|
}
|
|
298
233
|
/**
|
|
299
234
|
* List rules
|
|
@@ -304,8 +239,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
304
239
|
* @response 401 Unauthorized: a valid session or token is required
|
|
305
240
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks the read permission at the scope
|
|
306
241
|
*/
|
|
307
|
-
async listRules(
|
|
308
|
-
return this.list(
|
|
242
|
+
async listRules(domain, actor, query) {
|
|
243
|
+
return this.list(domain, actor, () => (0, query_js_1.readPageQuery)('rules', query));
|
|
309
244
|
}
|
|
310
245
|
/**
|
|
311
246
|
* Put a rule
|
|
@@ -320,8 +255,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
320
255
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
321
256
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
322
257
|
*/
|
|
323
|
-
async putRule(
|
|
324
|
-
return this.single(
|
|
258
|
+
async putRule(domain, actor, id, body, options) {
|
|
259
|
+
return this.single(domain, actor, options, () => [asCommand({ kind: 'rule.put', rule: withPathId(body, id) })]);
|
|
325
260
|
}
|
|
326
261
|
/**
|
|
327
262
|
* Delete a rule
|
|
@@ -335,8 +270,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
335
270
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
336
271
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
337
272
|
*/
|
|
338
|
-
async deleteRule(
|
|
339
|
-
return this.single(
|
|
273
|
+
async deleteRule(domain, actor, id, options) {
|
|
274
|
+
return this.single(domain, actor, options, () => [byId('rule.delete', id)]);
|
|
340
275
|
}
|
|
341
276
|
/**
|
|
342
277
|
* List policies
|
|
@@ -347,8 +282,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
347
282
|
* @response 401 Unauthorized: a valid session or token is required
|
|
348
283
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks the read permission at the scope
|
|
349
284
|
*/
|
|
350
|
-
async listPolicies(
|
|
351
|
-
return this.list(
|
|
285
|
+
async listPolicies(domain, actor, query) {
|
|
286
|
+
return this.list(domain, actor, () => (0, query_js_1.readPageQuery)('policies', query));
|
|
352
287
|
}
|
|
353
288
|
/**
|
|
354
289
|
* Put a policy
|
|
@@ -363,8 +298,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
363
298
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
364
299
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
365
300
|
*/
|
|
366
|
-
async putPolicy(
|
|
367
|
-
return this.single(
|
|
301
|
+
async putPolicy(domain, actor, id, body, options) {
|
|
302
|
+
return this.single(domain, actor, options, () => [asCommand({ kind: 'policy.put', policy: withPathId(body, id) })]);
|
|
368
303
|
}
|
|
369
304
|
/**
|
|
370
305
|
* Delete a policy
|
|
@@ -378,8 +313,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
378
313
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
379
314
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
380
315
|
*/
|
|
381
|
-
async deletePolicy(
|
|
382
|
-
return this.single(
|
|
316
|
+
async deletePolicy(domain, actor, id, options) {
|
|
317
|
+
return this.single(domain, actor, options, () => [byId('policy.delete', id)]);
|
|
383
318
|
}
|
|
384
319
|
/**
|
|
385
320
|
* Read scope attributes
|
|
@@ -389,8 +324,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
389
324
|
* @response 401 Unauthorized: a valid session or token is required
|
|
390
325
|
* @response 403 {AuthzAdminError} forbidden: the caller lacks the read permission at the scope
|
|
391
326
|
*/
|
|
392
|
-
async attributes(
|
|
393
|
-
return this.list(
|
|
327
|
+
async attributes(domain, actor, type, id) {
|
|
328
|
+
return this.list(domain, actor, () => ({ kind: 'attributes', scope: { type, id } }));
|
|
394
329
|
}
|
|
395
330
|
/**
|
|
396
331
|
* Merge scope attributes
|
|
@@ -405,8 +340,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
405
340
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
406
341
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
407
342
|
*/
|
|
408
|
-
async patchAttributes(
|
|
409
|
-
return this.single(
|
|
343
|
+
async patchAttributes(domain, actor, type, id, body, options) {
|
|
344
|
+
return this.single(domain, actor, options, () => [{ kind: 'scope.setAttributes', scope: { type, id }, patch: { ...body } }]);
|
|
410
345
|
}
|
|
411
346
|
/**
|
|
412
347
|
* Replace scope attributes
|
|
@@ -421,8 +356,8 @@ let AuthzAdminController = class AuthzAdminController extends http_1.BaseControl
|
|
|
421
356
|
* @response 409 {AuthzAdminError} conflict: the row changed or exists already
|
|
422
357
|
* @response 500 {AuthzAdminError} hook_error: an action hook threw or timed out
|
|
423
358
|
*/
|
|
424
|
-
async replaceAttributes(
|
|
425
|
-
return this.single(
|
|
359
|
+
async replaceAttributes(domain, actor, type, id, body, options) {
|
|
360
|
+
return this.single(domain, actor, options, () => [{ kind: 'scope.replaceAttributes', scope: { type, id }, attributes: { ...body } }]);
|
|
426
361
|
}
|
|
427
362
|
};
|
|
428
363
|
exports.AuthzAdminController = AuthzAdminController;
|
|
@@ -436,142 +371,204 @@ __decorate([
|
|
|
436
371
|
], AuthzAdminController.prototype, "Domains", void 0);
|
|
437
372
|
__decorate([
|
|
438
373
|
(0, http_1.Post)('commands'),
|
|
439
|
-
|
|
374
|
+
(0, http_1.Middleware)(no_store_js_1.NoStore),
|
|
375
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
376
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
377
|
+
__param(2, (0, args_js_1.AdminBatch)()),
|
|
440
378
|
__metadata("design:type", Function),
|
|
441
|
-
__metadata("design:paramtypes", [Object]),
|
|
379
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
442
380
|
__metadata("design:returntype", Promise)
|
|
443
381
|
], AuthzAdminController.prototype, "commands", null);
|
|
444
382
|
__decorate([
|
|
445
383
|
(0, http_1.Get)('assignments'),
|
|
446
|
-
__param(0, (0,
|
|
384
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
385
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
386
|
+
__param(2, (0, args_js_1.AdminQuery)()),
|
|
447
387
|
__metadata("design:type", Function),
|
|
448
|
-
__metadata("design:paramtypes", [Object]),
|
|
388
|
+
__metadata("design:paramtypes", [String, Object, queries_js_1.AuthzAssignmentsQuery]),
|
|
449
389
|
__metadata("design:returntype", Promise)
|
|
450
390
|
], AuthzAdminController.prototype, "listAssignments", null);
|
|
451
391
|
__decorate([
|
|
452
392
|
(0, http_1.Get)('holders'),
|
|
453
|
-
__param(0, (0,
|
|
393
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
394
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
395
|
+
__param(2, (0, args_js_1.AdminQuery)()),
|
|
454
396
|
__metadata("design:type", Function),
|
|
455
|
-
__metadata("design:paramtypes", [Object]),
|
|
397
|
+
__metadata("design:paramtypes", [String, Object, queries_js_1.AuthzHoldersQuery]),
|
|
456
398
|
__metadata("design:returntype", Promise)
|
|
457
399
|
], AuthzAdminController.prototype, "listHolders", null);
|
|
458
400
|
__decorate([
|
|
459
401
|
(0, http_1.Post)('assignments'),
|
|
460
|
-
__param(0, (0,
|
|
402
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
403
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
404
|
+
__param(2, (0, http_1.Body)({ required: true })),
|
|
405
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
461
406
|
__metadata("design:type", Function),
|
|
462
|
-
__metadata("design:paramtypes", [Object]),
|
|
407
|
+
__metadata("design:paramtypes", [String, Object, assignments_js_1.AuthzAssignmentGrant, queries_js_1.AuthzWriteOptionsQuery]),
|
|
463
408
|
__metadata("design:returntype", Promise)
|
|
464
409
|
], AuthzAdminController.prototype, "grant", null);
|
|
465
410
|
__decorate([
|
|
466
411
|
(0, http_1.Patch)('assignments/:id'),
|
|
467
|
-
__param(0, (0,
|
|
412
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
413
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
414
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
415
|
+
__param(3, (0, http_1.Body)({ required: true })),
|
|
416
|
+
__param(4, (0, args_js_1.AdminQuery)()),
|
|
468
417
|
__metadata("design:type", Function),
|
|
469
|
-
__metadata("design:paramtypes", [Object]),
|
|
418
|
+
__metadata("design:paramtypes", [String, Object, String, assignments_js_1.AuthzAssignmentPatch, queries_js_1.AuthzWriteOptionsQuery]),
|
|
470
419
|
__metadata("design:returntype", Promise)
|
|
471
420
|
], AuthzAdminController.prototype, "patchAssignment", null);
|
|
472
421
|
__decorate([
|
|
473
422
|
(0, http_1.Del)('assignments/:id'),
|
|
474
|
-
__param(0, (0,
|
|
423
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
424
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
425
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
426
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
475
427
|
__metadata("design:type", Function),
|
|
476
|
-
__metadata("design:paramtypes", [Object]),
|
|
428
|
+
__metadata("design:paramtypes", [String, Object, String, queries_js_1.AuthzWriteOptionsQuery]),
|
|
477
429
|
__metadata("design:returntype", Promise)
|
|
478
430
|
], AuthzAdminController.prototype, "revoke", null);
|
|
479
431
|
__decorate([
|
|
480
432
|
(0, http_1.Get)('links'),
|
|
481
|
-
__param(0, (0,
|
|
433
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
434
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
435
|
+
__param(2, (0, args_js_1.AdminQuery)()),
|
|
482
436
|
__metadata("design:type", Function),
|
|
483
|
-
__metadata("design:paramtypes", [Object]),
|
|
437
|
+
__metadata("design:paramtypes", [String, Object, queries_js_1.AuthzListQuery]),
|
|
484
438
|
__metadata("design:returntype", Promise)
|
|
485
439
|
], AuthzAdminController.prototype, "listLinks", null);
|
|
486
440
|
__decorate([
|
|
487
441
|
(0, http_1.Post)('links'),
|
|
488
|
-
|
|
442
|
+
(0, http_1.Middleware)(no_store_js_1.NoStore),
|
|
443
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
444
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
445
|
+
__param(2, (0, http_1.Body)({ required: true })),
|
|
446
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
489
447
|
__metadata("design:type", Function),
|
|
490
|
-
__metadata("design:paramtypes", [Object]),
|
|
448
|
+
__metadata("design:paramtypes", [String, Object, links_js_1.AuthzLinkCreate, queries_js_1.AuthzWriteOptionsQuery]),
|
|
491
449
|
__metadata("design:returntype", Promise)
|
|
492
450
|
], AuthzAdminController.prototype, "createLink", null);
|
|
493
451
|
__decorate([
|
|
494
452
|
(0, http_1.Patch)('links/:id'),
|
|
495
|
-
__param(0, (0,
|
|
453
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
454
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
455
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
456
|
+
__param(3, (0, http_1.Body)({ required: true })),
|
|
457
|
+
__param(4, (0, args_js_1.AdminQuery)()),
|
|
496
458
|
__metadata("design:type", Function),
|
|
497
|
-
__metadata("design:paramtypes", [Object]),
|
|
459
|
+
__metadata("design:paramtypes", [String, Object, String, links_js_1.AuthzLinkPatch, queries_js_1.AuthzWriteOptionsQuery]),
|
|
498
460
|
__metadata("design:returntype", Promise)
|
|
499
461
|
], AuthzAdminController.prototype, "patchLink", null);
|
|
500
462
|
__decorate([
|
|
501
463
|
(0, http_1.Del)('links/:id'),
|
|
502
|
-
__param(0, (0,
|
|
464
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
465
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
466
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
467
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
503
468
|
__metadata("design:type", Function),
|
|
504
|
-
__metadata("design:paramtypes", [Object]),
|
|
469
|
+
__metadata("design:paramtypes", [String, Object, String, queries_js_1.AuthzWriteOptionsQuery]),
|
|
505
470
|
__metadata("design:returntype", Promise)
|
|
506
471
|
], AuthzAdminController.prototype, "revokeLink", null);
|
|
507
472
|
__decorate([
|
|
508
473
|
(0, http_1.Get)('rules'),
|
|
509
|
-
__param(0, (0,
|
|
474
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
475
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
476
|
+
__param(2, (0, args_js_1.AdminQuery)()),
|
|
510
477
|
__metadata("design:type", Function),
|
|
511
|
-
__metadata("design:paramtypes", [Object]),
|
|
478
|
+
__metadata("design:paramtypes", [String, Object, queries_js_1.AuthzListQuery]),
|
|
512
479
|
__metadata("design:returntype", Promise)
|
|
513
480
|
], AuthzAdminController.prototype, "listRules", null);
|
|
514
481
|
__decorate([
|
|
515
482
|
(0, http_1.Put)('rules/:id'),
|
|
516
|
-
__param(0, (0,
|
|
483
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
484
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
485
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
486
|
+
__param(3, (0, http_1.Body)({ required: true })),
|
|
487
|
+
__param(4, (0, args_js_1.AdminQuery)()),
|
|
517
488
|
__metadata("design:type", Function),
|
|
518
|
-
__metadata("design:paramtypes", [Object]),
|
|
489
|
+
__metadata("design:paramtypes", [String, Object, String, rules_js_1.AuthzRuleBody, queries_js_1.AuthzWriteOptionsQuery]),
|
|
519
490
|
__metadata("design:returntype", Promise)
|
|
520
491
|
], AuthzAdminController.prototype, "putRule", null);
|
|
521
492
|
__decorate([
|
|
522
493
|
(0, http_1.Del)('rules/:id'),
|
|
523
|
-
__param(0, (0,
|
|
494
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
495
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
496
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
497
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
524
498
|
__metadata("design:type", Function),
|
|
525
|
-
__metadata("design:paramtypes", [Object]),
|
|
499
|
+
__metadata("design:paramtypes", [String, Object, String, queries_js_1.AuthzWriteOptionsQuery]),
|
|
526
500
|
__metadata("design:returntype", Promise)
|
|
527
501
|
], AuthzAdminController.prototype, "deleteRule", null);
|
|
528
502
|
__decorate([
|
|
529
503
|
(0, http_1.Get)('policies'),
|
|
530
|
-
__param(0, (0,
|
|
504
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
505
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
506
|
+
__param(2, (0, args_js_1.AdminQuery)()),
|
|
531
507
|
__metadata("design:type", Function),
|
|
532
|
-
__metadata("design:paramtypes", [Object]),
|
|
508
|
+
__metadata("design:paramtypes", [String, Object, queries_js_1.AuthzOffsetListQuery]),
|
|
533
509
|
__metadata("design:returntype", Promise)
|
|
534
510
|
], AuthzAdminController.prototype, "listPolicies", null);
|
|
535
511
|
__decorate([
|
|
536
512
|
(0, http_1.Put)('policies/:id'),
|
|
537
|
-
__param(0, (0,
|
|
513
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
514
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
515
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
516
|
+
__param(3, (0, http_1.Body)({ required: true })),
|
|
517
|
+
__param(4, (0, args_js_1.AdminQuery)()),
|
|
538
518
|
__metadata("design:type", Function),
|
|
539
|
-
__metadata("design:paramtypes", [Object]),
|
|
519
|
+
__metadata("design:paramtypes", [String, Object, String, rules_js_1.AuthzPolicyBody, queries_js_1.AuthzWriteOptionsQuery]),
|
|
540
520
|
__metadata("design:returntype", Promise)
|
|
541
521
|
], AuthzAdminController.prototype, "putPolicy", null);
|
|
542
522
|
__decorate([
|
|
543
523
|
(0, http_1.Del)('policies/:id'),
|
|
544
|
-
__param(0, (0,
|
|
524
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
525
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
526
|
+
__param(2, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
527
|
+
__param(3, (0, args_js_1.AdminQuery)()),
|
|
545
528
|
__metadata("design:type", Function),
|
|
546
|
-
__metadata("design:paramtypes", [Object]),
|
|
529
|
+
__metadata("design:paramtypes", [String, Object, String, queries_js_1.AuthzWriteOptionsQuery]),
|
|
547
530
|
__metadata("design:returntype", Promise)
|
|
548
531
|
], AuthzAdminController.prototype, "deletePolicy", null);
|
|
549
532
|
__decorate([
|
|
550
533
|
(0, http_1.Get)('scopes/:type/:id/attributes'),
|
|
551
|
-
__param(0, (0,
|
|
534
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
535
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
536
|
+
__param(2, (0, http_1.Param)(params_js_1.TYPE_PARAM)),
|
|
537
|
+
__param(3, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
552
538
|
__metadata("design:type", Function),
|
|
553
|
-
__metadata("design:paramtypes", [Object]),
|
|
539
|
+
__metadata("design:paramtypes", [String, Object, String, String]),
|
|
554
540
|
__metadata("design:returntype", Promise)
|
|
555
541
|
], AuthzAdminController.prototype, "attributes", null);
|
|
556
542
|
__decorate([
|
|
557
543
|
(0, http_1.Patch)('scopes/:type/:id/attributes'),
|
|
558
|
-
__param(0, (0,
|
|
544
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
545
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
546
|
+
__param(2, (0, http_1.Param)(params_js_1.TYPE_PARAM)),
|
|
547
|
+
__param(3, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
548
|
+
__param(4, (0, args_js_1.AdminBody)()),
|
|
549
|
+
__param(5, (0, args_js_1.AdminQuery)()),
|
|
559
550
|
__metadata("design:type", Function),
|
|
560
|
-
__metadata("design:paramtypes", [Object]),
|
|
551
|
+
__metadata("design:paramtypes", [String, Object, String, String, attributes_js_1.AuthzAttributesPatch, queries_js_1.AuthzWriteOptionsQuery]),
|
|
561
552
|
__metadata("design:returntype", Promise)
|
|
562
553
|
], AuthzAdminController.prototype, "patchAttributes", null);
|
|
563
554
|
__decorate([
|
|
564
555
|
(0, http_1.Put)('scopes/:type/:id/attributes'),
|
|
565
|
-
__param(0, (0,
|
|
556
|
+
__param(0, (0, args_js_1.AdminDomain)()),
|
|
557
|
+
__param(1, (0, authz_http_1.CurrentPrincipal)()),
|
|
558
|
+
__param(2, (0, http_1.Param)(params_js_1.TYPE_PARAM)),
|
|
559
|
+
__param(3, (0, http_1.Param)(params_js_1.ID_PARAM)),
|
|
560
|
+
__param(4, (0, args_js_1.AdminBody)()),
|
|
561
|
+
__param(5, (0, args_js_1.AdminQuery)()),
|
|
566
562
|
__metadata("design:type", Function),
|
|
567
|
-
__metadata("design:paramtypes", [Object]),
|
|
563
|
+
__metadata("design:paramtypes", [String, Object, String, String, attributes_js_1.AuthzAttributesBody, queries_js_1.AuthzWriteOptionsQuery]),
|
|
568
564
|
__metadata("design:returntype", Promise)
|
|
569
565
|
], AuthzAdminController.prototype, "replaceAttributes", null);
|
|
570
566
|
exports.AuthzAdminController = AuthzAdminController = __decorate([
|
|
571
567
|
(0, http_1.Policy)(authz_http_1.IsAuthenticated),
|
|
572
|
-
(0, http_1.BasePath)({ config: 'authz.http.admin.basePath', default: 'authz' })
|
|
568
|
+
(0, http_1.BasePath)({ config: 'authz.http.admin.basePath', default: 'authz' }),
|
|
569
|
+
(0, http_1.OnError)([validation_1.ValidationFailed, exceptions_1.InvalidArgument, authz_1.AuthzAdminFailure, authz_http_1.UnknownAuthzDomain], answers_js_1.adminInputAnswer, { stages: ['arguments'] })
|
|
573
570
|
], AuthzAdminController);
|
|
574
571
|
function results(r) {
|
|
575
|
-
return respond((0, status_js_1.resultsStatus)(r), { results: r });
|
|
572
|
+
return (0, answers_js_1.respond)((0, status_js_1.resultsStatus)(r), { results: r });
|
|
576
573
|
}
|
|
577
574
|
//# sourceMappingURL=AuthzAdminController.js.map
|