@spinajs/rbac-http-admin 2.0.485 → 2.0.487
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 +104 -5
- package/lib/cjs/config/rbac-http-admin.d.ts +25 -0
- package/lib/cjs/config/rbac-http-admin.d.ts.map +1 -1
- package/lib/cjs/config/rbac-http-admin.js +25 -0
- package/lib/cjs/config/rbac-http-admin.js.map +1 -1
- package/lib/cjs/controllers/Users/Profile.d.ts.map +1 -1
- package/lib/cjs/controllers/Users/Profile.js +3 -1
- package/lib/cjs/controllers/Users/Profile.js.map +1 -1
- package/lib/cjs/controllers/Users/Roles.d.ts +15 -8
- package/lib/cjs/controllers/Users/Roles.d.ts.map +1 -1
- package/lib/cjs/controllers/Users/Roles.js +34 -16
- package/lib/cjs/controllers/Users/Roles.js.map +1 -1
- package/lib/cjs/controllers/Users/Security.d.ts +151 -11
- package/lib/cjs/controllers/Users/Security.d.ts.map +1 -1
- package/lib/cjs/controllers/Users/Security.js +303 -30
- package/lib/cjs/controllers/Users/Security.js.map +1 -1
- package/lib/cjs/controllers/Users/Users.d.ts +97 -14
- package/lib/cjs/controllers/Users/Users.d.ts.map +1 -1
- package/lib/cjs/controllers/Users/Users.js +278 -73
- package/lib/cjs/controllers/Users/Users.js.map +1 -1
- package/lib/cjs/index.d.ts +6 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +5 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +81 -0
- package/lib/cjs/interfaces.d.ts.map +1 -0
- package/lib/cjs/interfaces.js +20 -0
- package/lib/cjs/interfaces.js.map +1 -0
- package/lib/cjs/services/RoleGuard.d.ts +96 -0
- package/lib/cjs/services/RoleGuard.d.ts.map +1 -0
- package/lib/cjs/services/RoleGuard.js +258 -0
- package/lib/cjs/services/RoleGuard.js.map +1 -0
- package/lib/mjs/config/rbac-http-admin.d.ts +25 -0
- package/lib/mjs/config/rbac-http-admin.d.ts.map +1 -1
- package/lib/mjs/config/rbac-http-admin.js +25 -0
- package/lib/mjs/config/rbac-http-admin.js.map +1 -1
- package/lib/mjs/controllers/Users/Profile.d.ts.map +1 -1
- package/lib/mjs/controllers/Users/Profile.js +4 -2
- package/lib/mjs/controllers/Users/Profile.js.map +1 -1
- package/lib/mjs/controllers/Users/Roles.d.ts +15 -8
- package/lib/mjs/controllers/Users/Roles.d.ts.map +1 -1
- package/lib/mjs/controllers/Users/Roles.js +35 -17
- package/lib/mjs/controllers/Users/Roles.js.map +1 -1
- package/lib/mjs/controllers/Users/Security.d.ts +151 -11
- package/lib/mjs/controllers/Users/Security.d.ts.map +1 -1
- package/lib/mjs/controllers/Users/Security.js +304 -31
- package/lib/mjs/controllers/Users/Security.js.map +1 -1
- package/lib/mjs/controllers/Users/Users.d.ts +97 -14
- package/lib/mjs/controllers/Users/Users.d.ts.map +1 -1
- package/lib/mjs/controllers/Users/Users.js +279 -74
- package/lib/mjs/controllers/Users/Users.js.map +1 -1
- package/lib/mjs/index.d.ts +6 -1
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +6 -1
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +81 -0
- package/lib/mjs/interfaces.d.ts.map +1 -0
- package/lib/mjs/interfaces.js +16 -0
- package/lib/mjs/interfaces.js.map +1 -0
- package/lib/mjs/services/RoleGuard.d.ts +96 -0
- package/lib/mjs/services/RoleGuard.d.ts.map +1 -0
- package/lib/mjs/services/RoleGuard.js +252 -0
- package/lib/mjs/services/RoleGuard.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +14 -12
|
@@ -11,21 +11,46 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
import { Autoinject } from '@spinajs/di';
|
|
14
|
-
import {
|
|
14
|
+
import { AutoinjectService } from '@spinajs/configuration';
|
|
15
|
+
import { BaseController, BasePath, Body, Del, Get, Ok, Param, Patch, Policy, Post, Query } from '@spinajs/http';
|
|
16
|
+
import { InvalidArgument, ResourceDuplicated, ResourceNotFound } from '@spinajs/exceptions';
|
|
15
17
|
import { SortOrder, SqlOperator } from '@spinajs/orm';
|
|
16
18
|
import { Filter, FromModel, OrderDTO, PaginationDTO } from '@spinajs/orm-http';
|
|
17
|
-
import { create, PasswordProvider, User } from '@spinajs/rbac';
|
|
18
|
-
import { AuthorizedPolicy, Permission, Resource } from
|
|
19
|
+
import { create, deleteUser, PasswordProvider, User, USER_SECURITY_METADATA_KEYS, _user_update } from '@spinajs/rbac';
|
|
20
|
+
import { AuthorizedPolicy, Permission, Resource, User as CurrentUser } from '@spinajs/rbac-http';
|
|
19
21
|
import { Schema } from '@spinajs/validation';
|
|
20
|
-
|
|
22
|
+
import { RoleGuard } from '../../interfaces.js';
|
|
23
|
+
// Side effect only: registers DefaultRoleGuard under the RoleGuard base so
|
|
24
|
+
// `rbac.admin.roleGuard.service` has something to resolve to. The type import
|
|
25
|
+
// above is erased at compile time, and controllers are loaded by path rather
|
|
26
|
+
// than through the package index, so without this the guard is missing in
|
|
27
|
+
// exactly the deployments that never import the package themselves.
|
|
28
|
+
import '../../services/RoleGuard.js';
|
|
29
|
+
/**
|
|
30
|
+
* Columns a client may sort by.
|
|
31
|
+
*
|
|
32
|
+
* `OrderDTO.column` is a free-form string and reaches the query builder as an
|
|
33
|
+
* identifier. The compiler escapes it, so this is not an injection hole — but an
|
|
34
|
+
* unknown column produced a driver error and a 500 where the request was simply
|
|
35
|
+
* wrong. Whitelisting turns that into a 400 and keeps the sortable surface a
|
|
36
|
+
* deliberate decision rather than "whatever columns the table happens to have".
|
|
37
|
+
*/
|
|
38
|
+
const SORTABLE_COLUMNS = ['Uuid', 'Login', 'Email', 'Role', 'IsActive', 'CreatedAt', 'LastLoginAt', 'DeletedAt'];
|
|
39
|
+
/**
|
|
40
|
+
* Upper bound on `pagination.limit`. An admin list endpoint with no ceiling is
|
|
41
|
+
* a table dump one query string away.
|
|
42
|
+
*/
|
|
43
|
+
const MAX_PAGE_SIZE = 100;
|
|
44
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
45
|
+
let CreateUserDto = class CreateUserDto {
|
|
21
46
|
constructor(data) {
|
|
22
47
|
Object.assign(this, data);
|
|
23
48
|
}
|
|
24
49
|
};
|
|
25
|
-
|
|
50
|
+
CreateUserDto = __decorate([
|
|
26
51
|
Schema({
|
|
27
52
|
type: 'object',
|
|
28
|
-
$id: 'arrow.common.
|
|
53
|
+
$id: 'arrow.common.createUserDto',
|
|
29
54
|
properties: {
|
|
30
55
|
Login: { type: 'string', minLength: 3, maxLength: 32, description: 'Unique login name (3–32 characters)' },
|
|
31
56
|
Email: { type: 'string', format: 'email', description: 'Unique email address' },
|
|
@@ -33,10 +58,6 @@ UserDto = __decorate([
|
|
|
33
58
|
Metadata: {
|
|
34
59
|
type: 'object',
|
|
35
60
|
$id: 'arrow.common.userMetadata',
|
|
36
|
-
properties: {
|
|
37
|
-
Key: { type: 'string', minLength: 1, maxLength: 64, description: 'Metadata key' },
|
|
38
|
-
Value: { type: 'string', minLength: 0, maxLength: 256, description: 'Metadata value' },
|
|
39
|
-
},
|
|
40
61
|
additionalProperties: true,
|
|
41
62
|
description: 'Optional key-value metadata to attach to the user account',
|
|
42
63
|
},
|
|
@@ -44,7 +65,37 @@ UserDto = __decorate([
|
|
|
44
65
|
required: ['Login', 'Email', 'Role'],
|
|
45
66
|
}),
|
|
46
67
|
__metadata("design:paramtypes", [Object])
|
|
47
|
-
],
|
|
68
|
+
], CreateUserDto);
|
|
69
|
+
export { CreateUserDto };
|
|
70
|
+
/**
|
|
71
|
+
* PATCH body. Separate from {@link CreateUserDto} because the two have opposite
|
|
72
|
+
* requirements: creation needs all three fields, an update needs none of them.
|
|
73
|
+
* Sharing one schema made every documented partial update fail validation with
|
|
74
|
+
* a 400 before the handler ever ran.
|
|
75
|
+
*
|
|
76
|
+
* Metadata is deliberately absent — it is managed through the dedicated
|
|
77
|
+
* `/user/:uuid/metadata` routes, which validate one entry at a time and can
|
|
78
|
+
* refuse the keys that decide account access.
|
|
79
|
+
*/
|
|
80
|
+
let UpdateUserDto = class UpdateUserDto {
|
|
81
|
+
constructor(data) {
|
|
82
|
+
Object.assign(this, data);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
UpdateUserDto = __decorate([
|
|
86
|
+
Schema({
|
|
87
|
+
type: 'object',
|
|
88
|
+
$id: 'arrow.common.updateUserDto',
|
|
89
|
+
properties: {
|
|
90
|
+
Login: { type: 'string', minLength: 3, maxLength: 32, description: 'Unique login name (3–32 characters)' },
|
|
91
|
+
Email: { type: 'string', format: 'email', description: 'Unique email address' },
|
|
92
|
+
Role: { type: 'string', minLength: 1, maxLength: 32, description: 'RBAC role to assign to the user' },
|
|
93
|
+
},
|
|
94
|
+
additionalProperties: false,
|
|
95
|
+
}),
|
|
96
|
+
__metadata("design:paramtypes", [Object])
|
|
97
|
+
], UpdateUserDto);
|
|
98
|
+
export { UpdateUserDto };
|
|
48
99
|
/**
|
|
49
100
|
* User model filter
|
|
50
101
|
* We declare it here to not include orm-http in rbac module
|
|
@@ -81,15 +132,15 @@ const USER_FILTER = [
|
|
|
81
132
|
},
|
|
82
133
|
{
|
|
83
134
|
column: 'Role',
|
|
84
|
-
operators: ['eq', 'neq']
|
|
135
|
+
operators: ['eq', 'neq'],
|
|
85
136
|
},
|
|
86
137
|
{
|
|
87
138
|
column: 'user:niceName',
|
|
88
139
|
operators: ['eq', 'neq', 'like', 'b-like', 'e-like'],
|
|
89
140
|
query: (operator, value) => {
|
|
90
141
|
return function () {
|
|
91
|
-
this.whereExist(
|
|
92
|
-
this.where('Key',
|
|
142
|
+
this.whereExist('Metadata', function () {
|
|
143
|
+
this.where('Key', 'user:niceName');
|
|
93
144
|
// NOTE: `operator` is the filter operator coming from the request
|
|
94
145
|
// ( eq / neq / like ... ), NOT an SQL one. It has to be translated
|
|
95
146
|
// before it reaches the query builder, which only understands SQL
|
|
@@ -113,8 +164,8 @@ const USER_FILTER = [
|
|
|
113
164
|
}
|
|
114
165
|
});
|
|
115
166
|
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
167
|
+
},
|
|
168
|
+
},
|
|
118
169
|
];
|
|
119
170
|
/**
|
|
120
171
|
* User account management (admin).
|
|
@@ -133,32 +184,40 @@ let Users = class Users extends BaseController {
|
|
|
133
184
|
* user:niceName metadata (eq, neq, like).
|
|
134
185
|
* @security cookieAuth
|
|
135
186
|
* @param pagination.page Page number (zero-based)
|
|
136
|
-
* @param pagination.limit Number of users per page (default: 10)
|
|
137
|
-
* @param order.column Column to sort by (default: CreatedAt)
|
|
187
|
+
* @param pagination.limit Number of users per page (default: 10, max: 100)
|
|
188
|
+
* @param order.column Column to sort by (default: CreatedAt). One of Uuid, Login, Email, Role, IsActive, CreatedAt, LastLoginAt, DeletedAt
|
|
138
189
|
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
139
190
|
* @param include Relations to include — currently supports: Metadata
|
|
140
191
|
* @returns {IUserData[]} Paginated list of user accounts, each with optional Metadata relation
|
|
192
|
+
* @response 400 Sort column is not sortable
|
|
141
193
|
* @response 401 Unauthorized — valid session required
|
|
142
194
|
* @response 403 Forbidden — readAny permission required on users resource
|
|
143
195
|
*/
|
|
144
196
|
async list(pagination, order, include, filter) {
|
|
197
|
+
// ONE limit for both take and skip. They used to disagree — take fell back
|
|
198
|
+
// to 10 while skip fell back to 0 — so any request that sent a page but no
|
|
199
|
+
// limit silently got page 0 whatever it asked for.
|
|
200
|
+
const limit = Math.min(pagination?.limit || DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
|
|
201
|
+
const column = this.sortColumn(order);
|
|
145
202
|
const result = await User.select()
|
|
146
|
-
.leftJoin(
|
|
203
|
+
.leftJoin('Metadata', function () {
|
|
147
204
|
// TODO: allow to inject custom meta props that need to be selected
|
|
148
205
|
// eg. user:niceName, user:avatar etc.
|
|
149
206
|
// this is used for filtering / sorting by custom meta props
|
|
150
207
|
this.where('Key', 'user:niceName');
|
|
151
208
|
}, function () {
|
|
152
|
-
this.select('Value',
|
|
209
|
+
this.select('Value', 'user:niceName');
|
|
153
210
|
})
|
|
154
211
|
.populate(include ?? [])
|
|
155
|
-
.take(
|
|
156
|
-
.skip(
|
|
157
|
-
.order(
|
|
212
|
+
.take(limit)
|
|
213
|
+
.skip(limit * (pagination?.page ?? 0))
|
|
214
|
+
.order(column, order?.order ?? SortOrder.DESC)
|
|
158
215
|
.filter(filter?.filters ?? [], filter?.op, USER_FILTER);
|
|
159
|
-
const count = await User.query()
|
|
216
|
+
const count = await User.query()
|
|
217
|
+
.filter(filter?.filters ?? [], filter?.op, USER_FILTER)
|
|
218
|
+
.selectCount();
|
|
160
219
|
return new Ok(result.map((x) => x.dehydrateWithRelations({
|
|
161
|
-
dateTimeFormat:
|
|
220
|
+
dateTimeFormat: 'iso',
|
|
162
221
|
})), {
|
|
163
222
|
Headers: [
|
|
164
223
|
{
|
|
@@ -168,6 +227,19 @@ let Users = class Users extends BaseController {
|
|
|
168
227
|
],
|
|
169
228
|
});
|
|
170
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* List assignable roles (admin)
|
|
232
|
+
* Returns the roles the calling administrator is allowed to grant, as decided by the
|
|
233
|
+
* configured role guard — the system role and anything granting more than the caller
|
|
234
|
+
* holds are left out, so a UI cannot offer an operation the guard will refuse.
|
|
235
|
+
* @security cookieAuth
|
|
236
|
+
* @returns {string[]} Role names the caller may assign
|
|
237
|
+
* @response 401 Unauthorized — valid session required
|
|
238
|
+
* @response 403 Forbidden — readAny permission required on users resource
|
|
239
|
+
*/
|
|
240
|
+
async assignableRoles(actor) {
|
|
241
|
+
return new Ok(this.RoleGuard.assignableRoles(actor));
|
|
242
|
+
}
|
|
171
243
|
/**
|
|
172
244
|
* Get user by UUID (admin)
|
|
173
245
|
* Retrieves a single user record by UUID. Supports optional inclusion of related Metadata.
|
|
@@ -202,16 +274,21 @@ let Users = class Users extends BaseController {
|
|
|
202
274
|
}
|
|
203
275
|
/**
|
|
204
276
|
* Create user (admin)
|
|
205
|
-
* Creates a new user account with a system-generated temporary password.
|
|
206
|
-
*
|
|
277
|
+
* Creates a new user account with a system-generated temporary password. The account is
|
|
278
|
+
* created inactive and the temporary password is never returned — issue a reset link with
|
|
279
|
+
* `POST /users/security/password-reset-request/:user` and activate the account once the
|
|
280
|
+
* user has set their own password.
|
|
207
281
|
* @security cookieAuth
|
|
208
282
|
* @returns {IUserData} Created user account
|
|
209
|
-
* @response 400 Validation error — missing required fields or
|
|
283
|
+
* @response 400 Validation error — missing required fields, invalid format, unknown role or a protected metadata key
|
|
210
284
|
* @response 401 Unauthorized — valid session required
|
|
211
|
-
* @response 403 Forbidden — createAny permission required
|
|
285
|
+
* @response 403 Forbidden — createAny permission required, or the requested role grants more than the caller holds
|
|
212
286
|
* @response 409 Login or email already in use
|
|
213
287
|
*/
|
|
214
|
-
async addUser(data) {
|
|
288
|
+
async addUser(actor, data) {
|
|
289
|
+
await this.RoleGuard.assertCanAssignRoles(actor, null, [data.Role]);
|
|
290
|
+
this.assertNoProtectedMetadata(data.Metadata);
|
|
291
|
+
await this.assertUnique(data.Login, data.Email);
|
|
215
292
|
const temporaryPassword = this.PasswordProvider.generate();
|
|
216
293
|
const { User: created } = await create(data.Email, data.Login, temporaryPassword, [data.Role], undefined, data.Metadata);
|
|
217
294
|
// NOTE: create() returns { User, Password } where Password is the plaintext
|
|
@@ -222,57 +299,157 @@ let Users = class Users extends BaseController {
|
|
|
222
299
|
/**
|
|
223
300
|
* Update user (admin)
|
|
224
301
|
* Partially updates a user account. All fields are optional — only provided fields are changed.
|
|
225
|
-
* Metadata is
|
|
302
|
+
* Metadata is NOT handled here; use the `/user/:uuid/metadata` routes.
|
|
226
303
|
* @security cookieAuth
|
|
227
304
|
* @param user User UUID path parameter
|
|
228
305
|
* @response 200 User updated successfully
|
|
229
|
-
* @response 400 Validation error — invalid field format
|
|
306
|
+
* @response 400 Validation error — invalid field format or unknown role
|
|
230
307
|
* @response 401 Unauthorized — valid session required
|
|
231
|
-
* @response 403 Forbidden — updateAny permission required
|
|
308
|
+
* @response 403 Forbidden — updateAny permission required, or the role change is refused by the role guard
|
|
232
309
|
* @response 404 User not found
|
|
233
310
|
* @response 409 Login or email already in use by another account
|
|
234
311
|
*/
|
|
235
|
-
async updateUser(user, data) {
|
|
312
|
+
async updateUser(actor, user, data) {
|
|
313
|
+
if (data.Role) {
|
|
314
|
+
const next = [data.Role];
|
|
315
|
+
const added = next.filter((r) => !user.Role.includes(r));
|
|
316
|
+
const removed = user.Role.filter((r) => !next.includes(r));
|
|
317
|
+
// A role list REPLACEMENT is a grant and a revoke at the same time, and
|
|
318
|
+
// both halves have their own rules — dropping the caller's last privileged
|
|
319
|
+
// role through PATCH must fail exactly as `revoke` does.
|
|
320
|
+
await this.RoleGuard.assertCanAssignRoles(actor, user, added);
|
|
321
|
+
for (const role of removed) {
|
|
322
|
+
await this.RoleGuard.assertCanRevokeRole(actor, user, role);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if ((data.Login && data.Login !== user.Login) || (data.Email && data.Email !== user.Email)) {
|
|
326
|
+
await this.assertUnique(data.Login !== user.Login ? data.Login : undefined, data.Email !== user.Email ? data.Email : undefined, user.Id);
|
|
327
|
+
}
|
|
236
328
|
user.Login = data.Login ?? user.Login;
|
|
237
329
|
user.Email = data.Email ?? user.Email;
|
|
238
|
-
// TODO
|
|
239
|
-
// fix array assign
|
|
240
330
|
user.Role = data.Role ? [data.Role] : user.Role;
|
|
241
|
-
if (data.Metadata) {
|
|
242
|
-
for (const key in data.Metadata) {
|
|
243
|
-
user.Metadata[key] = data.Metadata[key];
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
331
|
await user.update();
|
|
247
|
-
await user.Metadata.update();
|
|
248
332
|
return new Ok();
|
|
249
333
|
}
|
|
250
|
-
};
|
|
251
|
-
__decorate([
|
|
252
|
-
Autoinject(),
|
|
253
|
-
__metadata("design:type", PasswordProvider
|
|
254
334
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* Filterable fields: Uuid (eq), Email (eq, like), Login (eq, like), CreatedAt, LastLoginAt,
|
|
260
|
-
* DeletedAt (eq, gte, lte, lt, gt, isnull, notnull), IsActive (eq), Role (eq, neq),
|
|
261
|
-
* user:niceName metadata (eq, neq, like).
|
|
335
|
+
* Delete user (admin)
|
|
336
|
+
* Soft-deletes the account (`DeletedAt` is stamped, the row is kept) and destroys every
|
|
337
|
+
* session it holds, so a deleted user stops acting immediately rather than when their
|
|
338
|
+
* cookie happens to expire.
|
|
262
339
|
* @security cookieAuth
|
|
263
|
-
* @param
|
|
264
|
-
* @
|
|
265
|
-
* @param order.column Column to sort by (default: CreatedAt)
|
|
266
|
-
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
267
|
-
* @param include Relations to include — currently supports: Metadata
|
|
268
|
-
* @returns {IUserData[]} Paginated list of user accounts, each with optional Metadata relation
|
|
340
|
+
* @param user User UUID path parameter
|
|
341
|
+
* @response 200 User deleted
|
|
269
342
|
* @response 401 Unauthorized — valid session required
|
|
270
|
-
* @response 403 Forbidden —
|
|
343
|
+
* @response 403 Forbidden — deleteAny permission required, or the deletion is refused by the role guard
|
|
344
|
+
* @response 404 User not found
|
|
345
|
+
*/
|
|
346
|
+
async removeUser(actor, user) {
|
|
347
|
+
await this.RoleGuard.assertCanDisableAccount(actor, user, 'delete');
|
|
348
|
+
await deleteUser(user);
|
|
349
|
+
return new Ok();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Restore a deleted user (admin)
|
|
353
|
+
* Clears `DeletedAt` on a soft-deleted account. The account keeps its previous
|
|
354
|
+
* `IsActive` state — restoring is not activating.
|
|
355
|
+
* @security cookieAuth
|
|
356
|
+
* @param uuid User UUID path parameter
|
|
357
|
+
* @response 200 User restored
|
|
358
|
+
* @response 400 User is not deleted
|
|
359
|
+
* @response 401 Unauthorized — valid session required
|
|
360
|
+
* @response 403 Forbidden — deleteAny permission required on users resource
|
|
361
|
+
* @response 404 User not found
|
|
362
|
+
*/
|
|
363
|
+
async restoreUser(uuid) {
|
|
364
|
+
// Loaded by hand rather than through @FromModel: every model query filters
|
|
365
|
+
// soft-deleted rows out by default, so the one row this route exists for is
|
|
366
|
+
// exactly the row @FromModel can never find.
|
|
367
|
+
const user = await User.query().withDeleted().where('Uuid', uuid).first();
|
|
368
|
+
if (!user) {
|
|
369
|
+
throw new ResourceNotFound(`User ${uuid} not found`);
|
|
370
|
+
}
|
|
371
|
+
if (!user.DeletedAt) {
|
|
372
|
+
throw new InvalidArgument(`User ${uuid} is not deleted`);
|
|
373
|
+
}
|
|
374
|
+
await _user_update({ DeletedAt: null })(user);
|
|
375
|
+
return new Ok();
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* The requested sort column, or the default. Rejects anything outside
|
|
379
|
+
* {@link SORTABLE_COLUMNS}.
|
|
380
|
+
*/
|
|
381
|
+
sortColumn(order) {
|
|
382
|
+
const column = order?.column;
|
|
383
|
+
if (!column) {
|
|
384
|
+
return 'CreatedAt';
|
|
385
|
+
}
|
|
386
|
+
if (!SORTABLE_COLUMNS.includes(column)) {
|
|
387
|
+
throw new InvalidArgument(`Cannot sort by '${column}'. Sortable columns are: ${SORTABLE_COLUMNS.join(', ')}`);
|
|
388
|
+
}
|
|
389
|
+
return column;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Refuses metadata keys that decide account access.
|
|
393
|
+
*
|
|
394
|
+
* `user:pwd_reset:token` is a bearer credential for the public reset endpoint
|
|
395
|
+
* and `user:2fa:*` is the second factor itself — writing either through a
|
|
396
|
+
* generic key-value merge hands out an account rather than annotating one.
|
|
397
|
+
* Ban and lockout keys are refused for the same reason bans have their own
|
|
398
|
+
* route: written directly they skip the event, the email and the session
|
|
399
|
+
* revocation that make a ban mean something.
|
|
400
|
+
*/
|
|
401
|
+
assertNoProtectedMetadata(metadata) {
|
|
402
|
+
if (!metadata) {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const offending = Object.keys(metadata).filter((key) => {
|
|
406
|
+
// A glob reaches the metadata relation's setter as a PATTERN and rewrites
|
|
407
|
+
// every matching entry, so `*` alone would overwrite the whole set —
|
|
408
|
+
// including the protected keys listed above.
|
|
409
|
+
if (key.includes('*') || key.includes('?')) {
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
return USER_SECURITY_METADATA_KEYS.includes(key);
|
|
413
|
+
});
|
|
414
|
+
if (offending.length > 0) {
|
|
415
|
+
throw new InvalidArgument(`Metadata keys cannot be set through this endpoint: ${offending.join(', ')}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Rejects a login / email already taken by another account.
|
|
420
|
+
*
|
|
421
|
+
* Soft-deleted rows are included on purpose: they still occupy the unique
|
|
422
|
+
* indexes, so ignoring them would trade this 409 for a driver error and a 500.
|
|
271
423
|
*/
|
|
272
|
-
)
|
|
424
|
+
async assertUnique(login, email, exceptUserId) {
|
|
425
|
+
const clashes = [];
|
|
426
|
+
if (login) {
|
|
427
|
+
const found = await User.query().withDeleted().where('Login', login).first();
|
|
428
|
+
if (found && found.Id !== exceptUserId) {
|
|
429
|
+
clashes.push('Login');
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (email) {
|
|
433
|
+
const found = await User.query().withDeleted().where('Email', email).first();
|
|
434
|
+
if (found && found.Id !== exceptUserId) {
|
|
435
|
+
clashes.push('Email');
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (clashes.length > 0) {
|
|
439
|
+
throw new ResourceDuplicated(`${clashes.join(' and ')} already in use`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
__decorate([
|
|
444
|
+
Autoinject(),
|
|
445
|
+
__metadata("design:type", PasswordProvider)
|
|
273
446
|
], Users.prototype, "PasswordProvider", void 0);
|
|
274
447
|
__decorate([
|
|
275
|
-
|
|
448
|
+
AutoinjectService('rbac.admin.roleGuard'),
|
|
449
|
+
__metadata("design:type", RoleGuard)
|
|
450
|
+
], Users.prototype, "RoleGuard", void 0);
|
|
451
|
+
__decorate([
|
|
452
|
+
Get('/'),
|
|
276
453
|
Permission(['readAny']),
|
|
277
454
|
__param(0, Query()),
|
|
278
455
|
__param(1, Query()),
|
|
@@ -290,8 +467,17 @@ __decorate([
|
|
|
290
467
|
__metadata("design:returntype", Promise)
|
|
291
468
|
], Users.prototype, "list", null);
|
|
292
469
|
__decorate([
|
|
293
|
-
Get(
|
|
294
|
-
|
|
470
|
+
Get('roles'),
|
|
471
|
+
Permission(['readAny']),
|
|
472
|
+
__param(0, CurrentUser()),
|
|
473
|
+
__metadata("design:type", Function),
|
|
474
|
+
__metadata("design:paramtypes", [User]),
|
|
475
|
+
__metadata("design:returntype", Promise)
|
|
476
|
+
], Users.prototype, "assignableRoles", null);
|
|
477
|
+
__decorate([
|
|
478
|
+
Get(':user'),
|
|
479
|
+
Permission(['readAny']),
|
|
480
|
+
__param(0, FromModel({ queryField: 'Uuid' })),
|
|
295
481
|
__param(1, Query({
|
|
296
482
|
type: 'array',
|
|
297
483
|
items: {
|
|
@@ -304,8 +490,9 @@ __decorate([
|
|
|
304
490
|
__metadata("design:returntype", Promise)
|
|
305
491
|
], Users.prototype, "getSingleUser", null);
|
|
306
492
|
__decorate([
|
|
307
|
-
Get(
|
|
308
|
-
|
|
493
|
+
Get('byLogin/:user'),
|
|
494
|
+
Permission(['readAny']),
|
|
495
|
+
__param(0, FromModel({ queryField: 'Login' })),
|
|
309
496
|
__param(1, Query({
|
|
310
497
|
type: 'array',
|
|
311
498
|
items: {
|
|
@@ -318,23 +505,41 @@ __decorate([
|
|
|
318
505
|
__metadata("design:returntype", Promise)
|
|
319
506
|
], Users.prototype, "getByLogin", null);
|
|
320
507
|
__decorate([
|
|
321
|
-
Post(
|
|
508
|
+
Post('/'),
|
|
322
509
|
Permission(['createAny']),
|
|
323
|
-
__param(0,
|
|
510
|
+
__param(0, CurrentUser()),
|
|
511
|
+
__param(1, Body()),
|
|
324
512
|
__metadata("design:type", Function),
|
|
325
|
-
__metadata("design:paramtypes", [
|
|
513
|
+
__metadata("design:paramtypes", [User, CreateUserDto]),
|
|
326
514
|
__metadata("design:returntype", Promise)
|
|
327
515
|
], Users.prototype, "addUser", null);
|
|
328
516
|
__decorate([
|
|
329
|
-
Patch(
|
|
517
|
+
Patch(':user'),
|
|
330
518
|
Permission(['updateAny']),
|
|
331
|
-
__param(0,
|
|
332
|
-
__param(1,
|
|
519
|
+
__param(0, CurrentUser()),
|
|
520
|
+
__param(1, FromModel({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
521
|
+
__param(2, Body()),
|
|
333
522
|
__metadata("design:type", Function),
|
|
334
|
-
__metadata("design:paramtypes", [User,
|
|
335
|
-
UserDto]),
|
|
523
|
+
__metadata("design:paramtypes", [User, User, UpdateUserDto]),
|
|
336
524
|
__metadata("design:returntype", Promise)
|
|
337
525
|
], Users.prototype, "updateUser", null);
|
|
526
|
+
__decorate([
|
|
527
|
+
Del(':user'),
|
|
528
|
+
Permission(['deleteAny']),
|
|
529
|
+
__param(0, CurrentUser()),
|
|
530
|
+
__param(1, FromModel({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
531
|
+
__metadata("design:type", Function),
|
|
532
|
+
__metadata("design:paramtypes", [User, User]),
|
|
533
|
+
__metadata("design:returntype", Promise)
|
|
534
|
+
], Users.prototype, "removeUser", null);
|
|
535
|
+
__decorate([
|
|
536
|
+
Patch(':uuid/restore'),
|
|
537
|
+
Permission(['deleteAny']),
|
|
538
|
+
__param(0, Param()),
|
|
539
|
+
__metadata("design:type", Function),
|
|
540
|
+
__metadata("design:paramtypes", [String]),
|
|
541
|
+
__metadata("design:returntype", Promise)
|
|
542
|
+
], Users.prototype, "restoreUser", null);
|
|
338
543
|
Users = __decorate([
|
|
339
544
|
BasePath('users'),
|
|
340
545
|
Policy(AuthorizedPolicy),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Users.js","sourceRoot":"","sources":["../../../../src/controllers/Users/Users.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,MAAM,EAAuB,SAAS,EAAiC,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnI,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,IAoBM,OAAO,GApBb,MAoBM,OAAO;IAOX,YAAY,IAAsB;QAChC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AAVK,OAAO;IApBZ,MAAM,CAAC;QACN,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,sBAAsB;QAC3B,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE;YAC1G,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,E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AAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;;qCAA/D,IAAI,EAAkE,IAAI;;uCAKvH;AAgBY;IAFZ,KAAK,CAAC,eAAe,CAAC;IACtB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACA,WAAA,KAAK,EAAE,CAAA;;;;wCAiBhC;AA/RU,KAAK;IAHjB,QAAQ,CAAC,OAAO,CAAC;IACjB,MAAM,CAAC,gBAAgB,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC;GACL,KAAK,CA6WjB"}
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './interfaces.js';
|
|
2
|
+
export * from './services/RoleGuard.js';
|
|
3
|
+
export * from './controllers/Users/Users.js';
|
|
4
|
+
export * from './controllers/Users/Roles.js';
|
|
5
|
+
export * from './controllers/Users/Security.js';
|
|
6
|
+
export * from './controllers/Users/Profile.js';
|
|
2
7
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/mjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AAExC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC"}
|
package/lib/mjs/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './interfaces.js';
|
|
2
|
+
export * from './services/RoleGuard.js';
|
|
3
|
+
export * from './controllers/Users/Users.js';
|
|
4
|
+
export * from './controllers/Users/Roles.js';
|
|
5
|
+
export * from './controllers/Users/Security.js';
|
|
6
|
+
export * from './controllers/Users/Profile.js';
|
|
2
7
|
//# sourceMappingURL=index.js.map
|
package/lib/mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AAExC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { User } from '@spinajs/rbac';
|
|
2
|
+
/**
|
|
3
|
+
* What an administrator is allowed to do to roles and to accounts, read from
|
|
4
|
+
* `rbac.admin.roleGuard`.
|
|
5
|
+
*
|
|
6
|
+
* Every check is switchable because the right answer is deployment-specific: a
|
|
7
|
+
* single-tenant back office with two trusted operators wants none of this, a
|
|
8
|
+
* multi-tenant one wants all of it. The shipped defaults are the strict end —
|
|
9
|
+
* an application that needs less has to say so explicitly.
|
|
10
|
+
*/
|
|
11
|
+
export interface IRoleGuardConfig {
|
|
12
|
+
/** Registered name of the {@link RoleGuard} implementation to use. */
|
|
13
|
+
service: string;
|
|
14
|
+
/** Reject role names that are not declared in `rbac.grants` / `rbac.roles`. */
|
|
15
|
+
requireKnownRole: boolean;
|
|
16
|
+
/** Refuse to grant or revoke `rbac.systemRole` over HTTP, whoever is asking. */
|
|
17
|
+
protectSystemRole: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Refuse to grant a role whose resolved grants are not a subset of the
|
|
20
|
+
* caller's own. Without this, `updateAny` on `users` is a path to every other
|
|
21
|
+
* permission in the system — an administrator simply grants themselves more.
|
|
22
|
+
*/
|
|
23
|
+
preventEscalation: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Refuse operations that would strip the CALLER of their own privileged role
|
|
26
|
+
* or of their own account ( self-deactivation, self-deletion, self-ban ).
|
|
27
|
+
*/
|
|
28
|
+
preventSelfLockout: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Refuse operations that would leave zero usable accounts holding a
|
|
31
|
+
* privileged role — the "locked out of your own installation" case.
|
|
32
|
+
*/
|
|
33
|
+
preventLastPrivilegedRemoval: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Resource + action that make a role "privileged" for the two guards above.
|
|
36
|
+
* Action is written in accesscontrol grant notation, as it appears in
|
|
37
|
+
* `rbac.grants` ( `update:any`, not `updateAny` ).
|
|
38
|
+
*/
|
|
39
|
+
privilegedResource: string;
|
|
40
|
+
privilegedAction: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Role and account-state guard for the admin API.
|
|
44
|
+
*
|
|
45
|
+
* The checks live here rather than in the controllers because the same rule has
|
|
46
|
+
* to hold on every path that can change what an account may do: granting a role,
|
|
47
|
+
* revoking one, rewriting the whole role list through `PATCH /users/:uuid`, and
|
|
48
|
+
* taking an account out of service. A rule implemented per-controller is a rule
|
|
49
|
+
* that will be missing from the next controller.
|
|
50
|
+
*
|
|
51
|
+
* All methods THROW on refusal ( `Forbidden` / `InvalidArgument`, which the http
|
|
52
|
+
* error map turns into 403 / 400 ) and return normally when the operation is
|
|
53
|
+
* allowed.
|
|
54
|
+
*/
|
|
55
|
+
export declare abstract class RoleGuard {
|
|
56
|
+
/**
|
|
57
|
+
* May `actor` put `roles` on `target`?
|
|
58
|
+
*
|
|
59
|
+
* @param actor - the authenticated administrator making the request
|
|
60
|
+
* @param target - the account being changed, or null when it does not exist yet ( creation )
|
|
61
|
+
* @param roles - roles that would be assigned
|
|
62
|
+
*/
|
|
63
|
+
abstract assertCanAssignRoles(actor: User, target: User | null, roles: string[]): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* May `actor` take `role` away from `target`?
|
|
66
|
+
*/
|
|
67
|
+
abstract assertCanRevokeRole(actor: User, target: User, role: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* May `actor` take `target` out of service ( deactivate / delete / ban )?
|
|
70
|
+
*/
|
|
71
|
+
abstract assertCanDisableAccount(actor: User, target: User, action: AccountDisableAction): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Roles `actor` is allowed to hand out, for populating an admin UI. Returning
|
|
74
|
+
* this rather than the full role list keeps the UI from offering an operation
|
|
75
|
+
* the guard will refuse.
|
|
76
|
+
*/
|
|
77
|
+
abstract assignableRoles(actor: User): string[];
|
|
78
|
+
}
|
|
79
|
+
/** Operations that end an account's ability to act. */
|
|
80
|
+
export type AccountDisableAction = 'deactivate' | 'delete' | 'ban';
|
|
81
|
+
//# sourceMappingURL=interfaces.d.ts.map
|