@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
|
@@ -12,20 +12,25 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Security = void 0;
|
|
15
|
+
exports.Security = exports.BanUserDto = exports.ChangePasswordDto = void 0;
|
|
16
|
+
const configuration_1 = require("@spinajs/configuration");
|
|
16
17
|
const http_1 = require("@spinajs/http");
|
|
17
|
-
const orm_http_1 = require("@spinajs/orm-http");
|
|
18
18
|
const rbac_1 = require("@spinajs/rbac");
|
|
19
19
|
const rbac_http_1 = require("@spinajs/rbac-http");
|
|
20
|
+
const orm_http_1 = require("@spinajs/orm-http");
|
|
20
21
|
const validation_1 = require("@spinajs/validation");
|
|
21
22
|
const rbac_http_user_1 = require("@spinajs/rbac-http-user");
|
|
22
|
-
const
|
|
23
|
+
const log_1 = require("@spinajs/log");
|
|
24
|
+
const interfaces_js_1 = require("../../interfaces.js");
|
|
25
|
+
// Side effect only — see the note in Users.ts.
|
|
26
|
+
require("../../services/RoleGuard.js");
|
|
23
27
|
let ChangePasswordDto = class ChangePasswordDto {
|
|
24
28
|
constructor(data) {
|
|
25
29
|
Object.assign(this, data);
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
|
-
ChangePasswordDto =
|
|
32
|
+
exports.ChangePasswordDto = ChangePasswordDto;
|
|
33
|
+
exports.ChangePasswordDto = ChangePasswordDto = __decorate([
|
|
29
34
|
(0, validation_1.Schema)({
|
|
30
35
|
type: 'object',
|
|
31
36
|
$id: 'arrow.common.changePasswordDTO',
|
|
@@ -39,30 +44,52 @@ ChangePasswordDto = __decorate([
|
|
|
39
44
|
if: {
|
|
40
45
|
properties: {
|
|
41
46
|
password: { type: 'string' },
|
|
42
|
-
confirmPassword: { type: 'string' }
|
|
43
|
-
}
|
|
47
|
+
confirmPassword: { type: 'string' },
|
|
48
|
+
},
|
|
44
49
|
},
|
|
45
50
|
then: {
|
|
46
51
|
properties: {
|
|
47
|
-
confirmPassword: { const: { $data: '1/password' } }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
+
confirmPassword: { const: { $data: '1/password' } },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
52
57
|
}),
|
|
53
58
|
__metadata("design:paramtypes", [Object])
|
|
54
59
|
], ChangePasswordDto);
|
|
60
|
+
let BanUserDto = class BanUserDto {
|
|
61
|
+
constructor(data) {
|
|
62
|
+
Object.assign(this, data);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.BanUserDto = BanUserDto;
|
|
66
|
+
exports.BanUserDto = BanUserDto = __decorate([
|
|
67
|
+
(0, validation_1.Schema)({
|
|
68
|
+
type: 'object',
|
|
69
|
+
$id: 'arrow.common.banUserDTO',
|
|
70
|
+
properties: {
|
|
71
|
+
reason: { type: 'string', maxLength: 255, description: 'Why the account is banned. Stored in user metadata.' },
|
|
72
|
+
duration: { type: 'number', minimum: 1, description: 'Ban duration in seconds. Defaults to 24h.' },
|
|
73
|
+
},
|
|
74
|
+
}),
|
|
75
|
+
__metadata("design:paramtypes", [Object])
|
|
76
|
+
], BanUserDto);
|
|
55
77
|
/**
|
|
56
78
|
* User account security management (admin).
|
|
57
|
-
* Administrative controls for user account security:
|
|
58
|
-
*
|
|
79
|
+
* Administrative controls for user account security: passwords, 2FA, account
|
|
80
|
+
* activation, bans, login lockouts and live sessions.
|
|
81
|
+
*
|
|
82
|
+
* Every route that takes an account out of service goes through the configured
|
|
83
|
+
* {@link RoleGuard} first — an administrator must not be able to lock themselves,
|
|
84
|
+
* or the installation, out through this API.
|
|
59
85
|
* @tags Admin Users
|
|
60
86
|
*/
|
|
61
87
|
let Security = class Security extends http_1.BaseController {
|
|
62
88
|
/**
|
|
63
89
|
* Change user password (admin)
|
|
64
90
|
* Sets a new password for the specified user. Both password and confirmPassword must match.
|
|
65
|
-
* Minimum length is 8 characters.
|
|
91
|
+
* Minimum length is 8 characters. Every session of that user is destroyed — the credential
|
|
92
|
+
* they were opened with no longer exists.
|
|
66
93
|
* @security cookieAuth
|
|
67
94
|
* @param user User UUID path parameter
|
|
68
95
|
* @response 200 Password changed successfully
|
|
@@ -75,6 +102,40 @@ let Security = class Security extends http_1.BaseController {
|
|
|
75
102
|
await (0, rbac_1.changePassword)(dto.password)(user);
|
|
76
103
|
return new http_1.Ok();
|
|
77
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Send a password reset link (admin)
|
|
107
|
+
* Issues a single-use reset token into the user's metadata and emits
|
|
108
|
+
* `UserPasswordChangeRequest` so the application can deliver it. The token itself is never
|
|
109
|
+
* returned. This is how a freshly created account is handed over to its owner — the
|
|
110
|
+
* temporary password generated at creation is deliberately discarded.
|
|
111
|
+
* @security cookieAuth
|
|
112
|
+
* @param user User UUID path parameter
|
|
113
|
+
* @response 200 Reset token issued
|
|
114
|
+
* @response 401 Unauthorized — valid session required
|
|
115
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
116
|
+
* @response 404 User not found
|
|
117
|
+
*/
|
|
118
|
+
async requestPasswordReset(user) {
|
|
119
|
+
await (0, rbac_1.passwordChangeRequest)(user);
|
|
120
|
+
return new http_1.Ok();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Expire a user password (admin)
|
|
124
|
+
* Marks the password as expired, which deactivates the account until a new one is set.
|
|
125
|
+
* @security cookieAuth
|
|
126
|
+
* @param user User UUID path parameter
|
|
127
|
+
* @response 200 Password expired
|
|
128
|
+
* @response 401 Unauthorized — valid session required
|
|
129
|
+
* @response 403 Forbidden — deleteAny permission required, or refused by the role guard
|
|
130
|
+
* @response 404 User not found
|
|
131
|
+
*/
|
|
132
|
+
async expireUserPassword(actor, user) {
|
|
133
|
+
// Expiry deactivates the account, so it is guarded like every other way
|
|
134
|
+
// of taking an account out of service.
|
|
135
|
+
await this.RoleGuard.assertCanDisableAccount(actor, user, 'deactivate');
|
|
136
|
+
await (0, rbac_1.expirePassword)(user);
|
|
137
|
+
return new http_1.Ok();
|
|
138
|
+
}
|
|
78
139
|
/**
|
|
79
140
|
* Reset user two-factor authentication (admin)
|
|
80
141
|
* Clears the TOTP secret and disables 2FA for the specified user.
|
|
@@ -90,17 +151,48 @@ let Security = class Security extends http_1.BaseController {
|
|
|
90
151
|
await (0, rbac_http_user_1.resetUser2Fa)(user);
|
|
91
152
|
return new http_1.Ok();
|
|
92
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Enable two-factor authentication for a user (admin)
|
|
156
|
+
* Initializes a TOTP secret for the account. Returns whatever the configured
|
|
157
|
+
* two-factor provider produces for enrolment (an otpauth url for the default provider) —
|
|
158
|
+
* deliver it to the user over a channel you trust.
|
|
159
|
+
* @security cookieAuth
|
|
160
|
+
* @param user User UUID path parameter
|
|
161
|
+
* @response 200 2FA enabled
|
|
162
|
+
* @response 401 Unauthorized — valid session required
|
|
163
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
164
|
+
* @response 404 User not found
|
|
165
|
+
*/
|
|
166
|
+
async enable2Fa(user) {
|
|
167
|
+
return new http_1.Ok(await (0, rbac_http_user_1.enableUser2Fa)(user));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Disable two-factor authentication for a user (admin)
|
|
171
|
+
* Removes the TOTP secret and turns the second factor off for the account.
|
|
172
|
+
* @security cookieAuth
|
|
173
|
+
* @param user User UUID path parameter
|
|
174
|
+
* @response 200 2FA disabled
|
|
175
|
+
* @response 401 Unauthorized — valid session required
|
|
176
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
177
|
+
* @response 404 User not found
|
|
178
|
+
*/
|
|
179
|
+
async disable2Fa(user) {
|
|
180
|
+
await (0, rbac_http_user_1.disableUser2Fa)(user);
|
|
181
|
+
return new http_1.Ok();
|
|
182
|
+
}
|
|
93
183
|
/**
|
|
94
184
|
* Deactivate user account (admin)
|
|
95
|
-
* Marks the user account as inactive, preventing login without
|
|
185
|
+
* Marks the user account as inactive and destroys its sessions, preventing login without
|
|
186
|
+
* deleting the record.
|
|
96
187
|
* @security cookieAuth
|
|
97
188
|
* @param user User UUID path parameter
|
|
98
189
|
* @response 200 Account deactivated successfully
|
|
99
190
|
* @response 401 Unauthorized — valid session required
|
|
100
|
-
* @response 403 Forbidden — deleteAny permission required
|
|
191
|
+
* @response 403 Forbidden — deleteAny permission required, or refused by the role guard
|
|
101
192
|
* @response 404 User not found
|
|
102
193
|
*/
|
|
103
|
-
async deactivateUser(user) {
|
|
194
|
+
async deactivateUser(actor, user) {
|
|
195
|
+
await this.RoleGuard.assertCanDisableAccount(actor, user, 'deactivate');
|
|
104
196
|
await (0, rbac_1.deactivate)(user);
|
|
105
197
|
return new http_1.Ok();
|
|
106
198
|
}
|
|
@@ -111,13 +203,101 @@ let Security = class Security extends http_1.BaseController {
|
|
|
111
203
|
* @param user User UUID path parameter
|
|
112
204
|
* @response 200 Account activated successfully
|
|
113
205
|
* @response 401 Unauthorized — valid session required
|
|
114
|
-
* @response 403 Forbidden —
|
|
206
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
115
207
|
* @response 404 User not found
|
|
116
208
|
*/
|
|
117
209
|
async activateUser(user) {
|
|
118
210
|
await (0, rbac_1.activate)(user);
|
|
119
211
|
return new http_1.Ok();
|
|
120
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Ban a user (admin)
|
|
215
|
+
* Bans the account for `duration` seconds (24h when omitted), records the reason, and
|
|
216
|
+
* destroys every session it holds.
|
|
217
|
+
* @security cookieAuth
|
|
218
|
+
* @param user User UUID path parameter
|
|
219
|
+
* @response 200 Account banned
|
|
220
|
+
* @response 400 Account is already banned
|
|
221
|
+
* @response 401 Unauthorized — valid session required
|
|
222
|
+
* @response 403 Forbidden — deleteAny permission required, or refused by the role guard
|
|
223
|
+
* @response 404 User not found
|
|
224
|
+
*/
|
|
225
|
+
async banUser(actor, user, dto) {
|
|
226
|
+
await this.RoleGuard.assertCanDisableAccount(actor, user, 'ban');
|
|
227
|
+
await (0, rbac_1.ban)(user, dto?.reason, dto?.duration);
|
|
228
|
+
return new http_1.Ok();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Unban a user (admin)
|
|
232
|
+
* Clears the ban metadata from the account.
|
|
233
|
+
* @security cookieAuth
|
|
234
|
+
* @param user User UUID path parameter
|
|
235
|
+
* @response 200 Account unbanned
|
|
236
|
+
* @response 400 Account is not banned
|
|
237
|
+
* @response 401 Unauthorized — valid session required
|
|
238
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
239
|
+
* @response 404 User not found
|
|
240
|
+
*/
|
|
241
|
+
async unbanUser(user) {
|
|
242
|
+
await (0, rbac_1.unban)(user);
|
|
243
|
+
return new http_1.Ok();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Clear a login lockout (admin)
|
|
247
|
+
* Removes the failed-attempt counter and the lockout window opened by the login throttle,
|
|
248
|
+
* letting the user try again immediately. Without this the only remedy is waiting out
|
|
249
|
+
* `rbac.password.lockoutTime`.
|
|
250
|
+
* @security cookieAuth
|
|
251
|
+
* @param user User UUID path parameter
|
|
252
|
+
* @response 200 Lockout cleared
|
|
253
|
+
* @response 401 Unauthorized — valid session required
|
|
254
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
255
|
+
* @response 404 User not found
|
|
256
|
+
*/
|
|
257
|
+
async unlockUser(user) {
|
|
258
|
+
await user.Metadata.delete(rbac_1.USER_COMMON_METADATA.USER_LOGIN_ATTEMPTS);
|
|
259
|
+
await user.Metadata.delete(rbac_1.USER_COMMON_METADATA.USER_LOGIN_LOCKED_UNTIL);
|
|
260
|
+
this.Log.info(`Login lockout cleared`, { User: user.Uuid });
|
|
261
|
+
return new http_1.Ok();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* List sessions of a user (admin)
|
|
265
|
+
* Returns every live session of the account, newest first, identified by an opaque handle.
|
|
266
|
+
* @security cookieAuth
|
|
267
|
+
* @param user User UUID path parameter
|
|
268
|
+
* @returns {IAdminSessionEntry[]} Live sessions of the user
|
|
269
|
+
* @response 401 Unauthorized — valid session required
|
|
270
|
+
* @response 403 Forbidden — readAny permission required on users resource
|
|
271
|
+
* @response 404 User not found
|
|
272
|
+
*/
|
|
273
|
+
async listSessions(user) {
|
|
274
|
+
const sessions = await this.SessionProvider.listByUser(user.Id);
|
|
275
|
+
const entries = sessions.map((s) => this.toEntry(s)).sort((a, b) => (a.Created < b.Created ? 1 : -1));
|
|
276
|
+
return new http_1.Ok(entries, { Headers: [{ Name: 'Cache-Control', Value: 'no-store' }] });
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Revoke one session of a user (admin)
|
|
280
|
+
* Ends a single session, addressed by the handle returned from the listing.
|
|
281
|
+
* @security cookieAuth
|
|
282
|
+
* @param user User UUID path parameter
|
|
283
|
+
* @param handle Session handle as returned by `GET /users/security/sessions/:user`
|
|
284
|
+
* @response 200 Session revoked
|
|
285
|
+
* @response 401 Unauthorized — valid session required
|
|
286
|
+
* @response 403 Forbidden — updateAny permission required on users resource
|
|
287
|
+
* @response 404 No such session for this user
|
|
288
|
+
*/
|
|
289
|
+
async revokeSession(user, handle) {
|
|
290
|
+
// Resolved through THIS user's session list, so a handle belonging to
|
|
291
|
+
// somebody else cannot be revoked through their uuid.
|
|
292
|
+
const sessions = await this.SessionProvider.listByUser(user.Id);
|
|
293
|
+
const match = sessions.find((s) => (0, rbac_1.hashSessionId)(s.SessionId) === handle);
|
|
294
|
+
if (!match) {
|
|
295
|
+
return new http_1.NotFound({ error: { code: 'E_SESSION_NOT_FOUND', message: 'No such session' } });
|
|
296
|
+
}
|
|
297
|
+
await this.SessionProvider.delete(match.SessionId);
|
|
298
|
+
this.Log.info(`Session revoked by administrator`, { Session: handle, User: user.Uuid });
|
|
299
|
+
return new http_1.Ok(null, { Headers: [{ Name: 'Cache-Control', Value: 'no-store' }] });
|
|
300
|
+
}
|
|
121
301
|
/**
|
|
122
302
|
* Force logout user (admin)
|
|
123
303
|
* Invalidates all active sessions for the specified user, immediately ending any current logins.
|
|
@@ -130,51 +310,144 @@ let Security = class Security extends http_1.BaseController {
|
|
|
130
310
|
*/
|
|
131
311
|
async logoutUser(user) {
|
|
132
312
|
await this.SessionProvider.deleteByUser(user.Id);
|
|
133
|
-
|
|
313
|
+
this.Log.info(`All sessions revoked by administrator`, { User: user.Uuid });
|
|
314
|
+
return new http_1.Ok(null, { Headers: [{ Name: 'Cache-Control', Value: 'no-store' }] });
|
|
315
|
+
}
|
|
316
|
+
toEntry(session) {
|
|
317
|
+
return {
|
|
318
|
+
Handle: (0, rbac_1.hashSessionId)(session.SessionId),
|
|
319
|
+
Created: session.Creation?.toISO() ?? '',
|
|
320
|
+
Expires: session.Expiration?.toISO() ?? null,
|
|
321
|
+
};
|
|
134
322
|
}
|
|
135
323
|
};
|
|
136
324
|
exports.Security = Security;
|
|
137
325
|
__decorate([
|
|
138
|
-
(0,
|
|
326
|
+
(0, log_1.Logger)('rbac-admin'),
|
|
327
|
+
__metadata("design:type", log_1.Log)
|
|
328
|
+
], Security.prototype, "Log", void 0);
|
|
329
|
+
__decorate([
|
|
330
|
+
(0, configuration_1.AutoinjectService)('rbac.session'),
|
|
139
331
|
__metadata("design:type", rbac_1.SessionProvider)
|
|
140
332
|
], Security.prototype, "SessionProvider", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
(0, configuration_1.AutoinjectService)('rbac.admin.roleGuard'),
|
|
335
|
+
__metadata("design:type", interfaces_js_1.RoleGuard)
|
|
336
|
+
], Security.prototype, "RoleGuard", void 0);
|
|
141
337
|
__decorate([
|
|
142
338
|
(0, http_1.Patch)('changePassword/:user'),
|
|
143
339
|
(0, rbac_http_1.Permission)(['updateAny']),
|
|
144
|
-
__param(0, (0, orm_http_1.FromModel)({ queryField:
|
|
340
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
145
341
|
__param(1, (0, http_1.Body)()),
|
|
146
342
|
__metadata("design:type", Function),
|
|
147
343
|
__metadata("design:paramtypes", [rbac_1.User, ChangePasswordDto]),
|
|
148
344
|
__metadata("design:returntype", Promise)
|
|
149
345
|
], Security.prototype, "changeUserPassword", null);
|
|
346
|
+
__decorate([
|
|
347
|
+
(0, http_1.Post)('password-reset-request/:user'),
|
|
348
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
349
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
350
|
+
__metadata("design:type", Function),
|
|
351
|
+
__metadata("design:paramtypes", [rbac_1.User]),
|
|
352
|
+
__metadata("design:returntype", Promise)
|
|
353
|
+
], Security.prototype, "requestPasswordReset", null);
|
|
354
|
+
__decorate([
|
|
355
|
+
(0, http_1.Post)('expire-password/:user'),
|
|
356
|
+
(0, rbac_http_1.Permission)(['deleteAny']),
|
|
357
|
+
__param(0, (0, rbac_http_1.User)()),
|
|
358
|
+
__param(1, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
359
|
+
__metadata("design:type", Function),
|
|
360
|
+
__metadata("design:paramtypes", [rbac_1.User, rbac_1.User]),
|
|
361
|
+
__metadata("design:returntype", Promise)
|
|
362
|
+
], Security.prototype, "expireUserPassword", null);
|
|
150
363
|
__decorate([
|
|
151
364
|
(0, http_1.Patch)('reset2fa/:user'),
|
|
152
365
|
(0, rbac_http_1.Permission)(['updateAny']),
|
|
153
|
-
__param(0, (0, orm_http_1.FromModel)({ queryField:
|
|
366
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
154
367
|
__metadata("design:type", Function),
|
|
155
368
|
__metadata("design:paramtypes", [rbac_1.User]),
|
|
156
369
|
__metadata("design:returntype", Promise)
|
|
157
370
|
], Security.prototype, "reset2faToken", null);
|
|
158
371
|
__decorate([
|
|
159
|
-
(0, http_1.
|
|
160
|
-
(0, rbac_http_1.Permission)(['
|
|
161
|
-
__param(0, (0, orm_http_1.FromModel)({ queryField:
|
|
372
|
+
(0, http_1.Post)('2fa/enable/:user'),
|
|
373
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
374
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
162
375
|
__metadata("design:type", Function),
|
|
163
376
|
__metadata("design:paramtypes", [rbac_1.User]),
|
|
164
377
|
__metadata("design:returntype", Promise)
|
|
165
|
-
], Security.prototype, "
|
|
378
|
+
], Security.prototype, "enable2Fa", null);
|
|
166
379
|
__decorate([
|
|
167
|
-
(0, http_1.
|
|
380
|
+
(0, http_1.Post)('2fa/disable/:user'),
|
|
381
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
382
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
383
|
+
__metadata("design:type", Function),
|
|
384
|
+
__metadata("design:paramtypes", [rbac_1.User]),
|
|
385
|
+
__metadata("design:returntype", Promise)
|
|
386
|
+
], Security.prototype, "disable2Fa", null);
|
|
387
|
+
__decorate([
|
|
388
|
+
(0, http_1.Post)('deactivate/:user'),
|
|
168
389
|
(0, rbac_http_1.Permission)(['deleteAny']),
|
|
169
|
-
__param(0, (0,
|
|
390
|
+
__param(0, (0, rbac_http_1.User)()),
|
|
391
|
+
__param(1, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
392
|
+
__metadata("design:type", Function),
|
|
393
|
+
__metadata("design:paramtypes", [rbac_1.User, rbac_1.User]),
|
|
394
|
+
__metadata("design:returntype", Promise)
|
|
395
|
+
], Security.prototype, "deactivateUser", null);
|
|
396
|
+
__decorate([
|
|
397
|
+
(0, http_1.Post)('activate/:user'),
|
|
398
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
399
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
170
400
|
__metadata("design:type", Function),
|
|
171
401
|
__metadata("design:paramtypes", [rbac_1.User]),
|
|
172
402
|
__metadata("design:returntype", Promise)
|
|
173
403
|
], Security.prototype, "activateUser", null);
|
|
174
404
|
__decorate([
|
|
175
|
-
(0, http_1.
|
|
405
|
+
(0, http_1.Post)('ban/:user'),
|
|
406
|
+
(0, rbac_http_1.Permission)(['deleteAny']),
|
|
407
|
+
__param(0, (0, rbac_http_1.User)()),
|
|
408
|
+
__param(1, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
409
|
+
__param(2, (0, http_1.Body)()),
|
|
410
|
+
__metadata("design:type", Function),
|
|
411
|
+
__metadata("design:paramtypes", [rbac_1.User, rbac_1.User, BanUserDto]),
|
|
412
|
+
__metadata("design:returntype", Promise)
|
|
413
|
+
], Security.prototype, "banUser", null);
|
|
414
|
+
__decorate([
|
|
415
|
+
(0, http_1.Post)('unban/:user'),
|
|
416
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
417
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
418
|
+
__metadata("design:type", Function),
|
|
419
|
+
__metadata("design:paramtypes", [rbac_1.User]),
|
|
420
|
+
__metadata("design:returntype", Promise)
|
|
421
|
+
], Security.prototype, "unbanUser", null);
|
|
422
|
+
__decorate([
|
|
423
|
+
(0, http_1.Post)('unlock/:user'),
|
|
424
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
425
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid', include: ['Metadata'] })),
|
|
426
|
+
__metadata("design:type", Function),
|
|
427
|
+
__metadata("design:paramtypes", [rbac_1.User]),
|
|
428
|
+
__metadata("design:returntype", Promise)
|
|
429
|
+
], Security.prototype, "unlockUser", null);
|
|
430
|
+
__decorate([
|
|
431
|
+
(0, http_1.Get)('sessions/:user'),
|
|
432
|
+
(0, rbac_http_1.Permission)(['readAny']),
|
|
433
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid' })),
|
|
434
|
+
__metadata("design:type", Function),
|
|
435
|
+
__metadata("design:paramtypes", [rbac_1.User]),
|
|
436
|
+
__metadata("design:returntype", Promise)
|
|
437
|
+
], Security.prototype, "listSessions", null);
|
|
438
|
+
__decorate([
|
|
439
|
+
(0, http_1.Del)('sessions/:user/:handle'),
|
|
440
|
+
(0, rbac_http_1.Permission)(['updateAny']),
|
|
441
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid' })),
|
|
442
|
+
__param(1, (0, http_1.Param)()),
|
|
443
|
+
__metadata("design:type", Function),
|
|
444
|
+
__metadata("design:paramtypes", [rbac_1.User, String]),
|
|
445
|
+
__metadata("design:returntype", Promise)
|
|
446
|
+
], Security.prototype, "revokeSession", null);
|
|
447
|
+
__decorate([
|
|
448
|
+
(0, http_1.Del)('sessions/:user'),
|
|
176
449
|
(0, rbac_http_1.Permission)(['updateAny']),
|
|
177
|
-
__param(0, (0, orm_http_1.FromModel)({ queryField:
|
|
450
|
+
__param(0, (0, orm_http_1.FromModel)({ queryField: 'Uuid' })),
|
|
178
451
|
__metadata("design:type", Function),
|
|
179
452
|
__metadata("design:paramtypes", [rbac_1.User]),
|
|
180
453
|
__metadata("design:returntype", Promise)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Security.js","sourceRoot":"","sources":["../../../../src/controllers/Users/Security.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Security.js","sourceRoot":"","sources":["../../../../src/controllers/Users/Security.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA2D;AAC3D,wCAAmH;AACnH,wCAAoL;AAEpL,kDAAiG;AACjG,gDAA8C;AAC9C,oDAA6C;AAC7C,4DAAsF;AACtF,sCAA2C;AAE3C,uDAAgD;AAEhD,+CAA+C;AAC/C,uCAAqC;AA0B9B,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAI5B,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AAPY,8CAAiB;4BAAjB,iBAAiB;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3
3
|
import { PasswordProvider, User } from '@spinajs/rbac';
|
|
4
|
-
|
|
4
|
+
import { RoleGuard } from '../../interfaces.js';
|
|
5
|
+
import '../../services/RoleGuard.js';
|
|
6
|
+
export declare class CreateUserDto {
|
|
5
7
|
Login: string;
|
|
6
8
|
Email: string;
|
|
7
9
|
Role: string;
|
|
8
10
|
Metadata?: {
|
|
9
11
|
[key: string]: any;
|
|
10
12
|
};
|
|
11
|
-
constructor(data: Partial<
|
|
13
|
+
constructor(data: Partial<CreateUserDto>);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* PATCH body. Separate from {@link CreateUserDto} because the two have opposite
|
|
17
|
+
* requirements: creation needs all three fields, an update needs none of them.
|
|
18
|
+
* Sharing one schema made every documented partial update fail validation with
|
|
19
|
+
* a 400 before the handler ever ran.
|
|
20
|
+
*
|
|
21
|
+
* Metadata is deliberately absent — it is managed through the dedicated
|
|
22
|
+
* `/user/:uuid/metadata` routes, which validate one entry at a time and can
|
|
23
|
+
* refuse the keys that decide account access.
|
|
24
|
+
*/
|
|
25
|
+
export declare class UpdateUserDto {
|
|
26
|
+
Login?: string;
|
|
27
|
+
Email?: string;
|
|
28
|
+
Role?: string;
|
|
29
|
+
constructor(data: Partial<UpdateUserDto>);
|
|
12
30
|
}
|
|
13
31
|
/**
|
|
14
32
|
* User account management (admin).
|
|
@@ -18,6 +36,7 @@ declare class UserDto {
|
|
|
18
36
|
*/
|
|
19
37
|
export declare class Users extends BaseController {
|
|
20
38
|
protected PasswordProvider: PasswordProvider;
|
|
39
|
+
protected RoleGuard: RoleGuard;
|
|
21
40
|
/**
|
|
22
41
|
* List users (admin)
|
|
23
42
|
* Returns a paginated, sortable, filterable list of all users. Supports optional inclusion
|
|
@@ -28,15 +47,27 @@ export declare class Users extends BaseController {
|
|
|
28
47
|
* user:niceName metadata (eq, neq, like).
|
|
29
48
|
* @security cookieAuth
|
|
30
49
|
* @param pagination.page Page number (zero-based)
|
|
31
|
-
* @param pagination.limit Number of users per page (default: 10)
|
|
32
|
-
* @param order.column Column to sort by (default: CreatedAt)
|
|
50
|
+
* @param pagination.limit Number of users per page (default: 10, max: 100)
|
|
51
|
+
* @param order.column Column to sort by (default: CreatedAt). One of Uuid, Login, Email, Role, IsActive, CreatedAt, LastLoginAt, DeletedAt
|
|
33
52
|
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
34
53
|
* @param include Relations to include — currently supports: Metadata
|
|
35
54
|
* @returns {IUserData[]} Paginated list of user accounts, each with optional Metadata relation
|
|
55
|
+
* @response 400 Sort column is not sortable
|
|
36
56
|
* @response 401 Unauthorized — valid session required
|
|
37
57
|
* @response 403 Forbidden — readAny permission required on users resource
|
|
38
58
|
*/
|
|
39
59
|
list(pagination?: PaginationDTO, order?: OrderDTO, include?: string[], filter?: IFilterRequest): Promise<Ok<import("@spinajs/orm").ModelDataWithRelationData<User>[]>>;
|
|
60
|
+
/**
|
|
61
|
+
* List assignable roles (admin)
|
|
62
|
+
* Returns the roles the calling administrator is allowed to grant, as decided by the
|
|
63
|
+
* configured role guard — the system role and anything granting more than the caller
|
|
64
|
+
* holds are left out, so a UI cannot offer an operation the guard will refuse.
|
|
65
|
+
* @security cookieAuth
|
|
66
|
+
* @returns {string[]} Role names the caller may assign
|
|
67
|
+
* @response 401 Unauthorized — valid session required
|
|
68
|
+
* @response 403 Forbidden — readAny permission required on users resource
|
|
69
|
+
*/
|
|
70
|
+
assignableRoles(actor: User): Promise<Ok<string[]>>;
|
|
40
71
|
/**
|
|
41
72
|
* Get user by UUID (admin)
|
|
42
73
|
* Retrieves a single user record by UUID. Supports optional inclusion of related Metadata.
|
|
@@ -63,30 +94,82 @@ export declare class Users extends BaseController {
|
|
|
63
94
|
getByLogin(user: User, include?: string[]): Promise<Ok<import("@spinajs/orm").ModelDataWithRelationData<User>>>;
|
|
64
95
|
/**
|
|
65
96
|
* Create user (admin)
|
|
66
|
-
* Creates a new user account with a system-generated temporary password.
|
|
67
|
-
*
|
|
97
|
+
* Creates a new user account with a system-generated temporary password. The account is
|
|
98
|
+
* created inactive and the temporary password is never returned — issue a reset link with
|
|
99
|
+
* `POST /users/security/password-reset-request/:user` and activate the account once the
|
|
100
|
+
* user has set their own password.
|
|
68
101
|
* @security cookieAuth
|
|
69
102
|
* @returns {IUserData} Created user account
|
|
70
|
-
* @response 400 Validation error — missing required fields or
|
|
103
|
+
* @response 400 Validation error — missing required fields, invalid format, unknown role or a protected metadata key
|
|
71
104
|
* @response 401 Unauthorized — valid session required
|
|
72
|
-
* @response 403 Forbidden — createAny permission required
|
|
105
|
+
* @response 403 Forbidden — createAny permission required, or the requested role grants more than the caller holds
|
|
73
106
|
* @response 409 Login or email already in use
|
|
74
107
|
*/
|
|
75
|
-
addUser(data:
|
|
108
|
+
addUser(actor: User, data: CreateUserDto): Promise<Ok<import("@spinajs/orm").ModelDataWithRelationData<User>>>;
|
|
76
109
|
/**
|
|
77
110
|
* Update user (admin)
|
|
78
111
|
* Partially updates a user account. All fields are optional — only provided fields are changed.
|
|
79
|
-
* Metadata is
|
|
112
|
+
* Metadata is NOT handled here; use the `/user/:uuid/metadata` routes.
|
|
80
113
|
* @security cookieAuth
|
|
81
114
|
* @param user User UUID path parameter
|
|
82
115
|
* @response 200 User updated successfully
|
|
83
|
-
* @response 400 Validation error — invalid field format
|
|
116
|
+
* @response 400 Validation error — invalid field format or unknown role
|
|
84
117
|
* @response 401 Unauthorized — valid session required
|
|
85
|
-
* @response 403 Forbidden — updateAny permission required
|
|
118
|
+
* @response 403 Forbidden — updateAny permission required, or the role change is refused by the role guard
|
|
86
119
|
* @response 404 User not found
|
|
87
120
|
* @response 409 Login or email already in use by another account
|
|
88
121
|
*/
|
|
89
|
-
updateUser(user: User, data:
|
|
122
|
+
updateUser(actor: User, user: User, data: UpdateUserDto): Promise<Ok<any>>;
|
|
123
|
+
/**
|
|
124
|
+
* Delete user (admin)
|
|
125
|
+
* Soft-deletes the account (`DeletedAt` is stamped, the row is kept) and destroys every
|
|
126
|
+
* session it holds, so a deleted user stops acting immediately rather than when their
|
|
127
|
+
* cookie happens to expire.
|
|
128
|
+
* @security cookieAuth
|
|
129
|
+
* @param user User UUID path parameter
|
|
130
|
+
* @response 200 User deleted
|
|
131
|
+
* @response 401 Unauthorized — valid session required
|
|
132
|
+
* @response 403 Forbidden — deleteAny permission required, or the deletion is refused by the role guard
|
|
133
|
+
* @response 404 User not found
|
|
134
|
+
*/
|
|
135
|
+
removeUser(actor: User, user: User): Promise<Ok<any>>;
|
|
136
|
+
/**
|
|
137
|
+
* Restore a deleted user (admin)
|
|
138
|
+
* Clears `DeletedAt` on a soft-deleted account. The account keeps its previous
|
|
139
|
+
* `IsActive` state — restoring is not activating.
|
|
140
|
+
* @security cookieAuth
|
|
141
|
+
* @param uuid User UUID path parameter
|
|
142
|
+
* @response 200 User restored
|
|
143
|
+
* @response 400 User is not deleted
|
|
144
|
+
* @response 401 Unauthorized — valid session required
|
|
145
|
+
* @response 403 Forbidden — deleteAny permission required on users resource
|
|
146
|
+
* @response 404 User not found
|
|
147
|
+
*/
|
|
148
|
+
restoreUser(uuid: string): Promise<Ok<any>>;
|
|
149
|
+
/**
|
|
150
|
+
* The requested sort column, or the default. Rejects anything outside
|
|
151
|
+
* {@link SORTABLE_COLUMNS}.
|
|
152
|
+
*/
|
|
153
|
+
protected sortColumn(order?: OrderDTO): string;
|
|
154
|
+
/**
|
|
155
|
+
* Refuses metadata keys that decide account access.
|
|
156
|
+
*
|
|
157
|
+
* `user:pwd_reset:token` is a bearer credential for the public reset endpoint
|
|
158
|
+
* and `user:2fa:*` is the second factor itself — writing either through a
|
|
159
|
+
* generic key-value merge hands out an account rather than annotating one.
|
|
160
|
+
* Ban and lockout keys are refused for the same reason bans have their own
|
|
161
|
+
* route: written directly they skip the event, the email and the session
|
|
162
|
+
* revocation that make a ban mean something.
|
|
163
|
+
*/
|
|
164
|
+
protected assertNoProtectedMetadata(metadata?: {
|
|
165
|
+
[key: string]: any;
|
|
166
|
+
}): void;
|
|
167
|
+
/**
|
|
168
|
+
* Rejects a login / email already taken by another account.
|
|
169
|
+
*
|
|
170
|
+
* Soft-deleted rows are included on purpose: they still occupy the unique
|
|
171
|
+
* indexes, so ignoring them would trade this 409 for a driver error and a 500.
|
|
172
|
+
*/
|
|
173
|
+
protected assertUnique(login?: string, email?: string, exceptUserId?: number): Promise<void>;
|
|
90
174
|
}
|
|
91
|
-
export {};
|
|
92
175
|
//# sourceMappingURL=Users.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Users.d.ts","sourceRoot":"","sources":["../../../../src/controllers/Users/Users.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Users.d.ts","sourceRoot":"","sources":["../../../../src/controllers/Users/Users.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAA4B,EAAE,EAAqC,MAAM,eAAe,CAAC;AAGhH,OAAO,EAAyD,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnI,OAAO,EAAsB,gBAAgB,EAAE,IAAI,EAA6C,MAAM,eAAe,CAAC;AAItH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAOhD,OAAO,6BAA6B,CAAC;AAqBrC,qBAgBa,aAAa;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;gBAE7B,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC;CAGzC;AAED;;;;;;;;;GASG;AACH,qBAUa,aAAa;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC;CAGzC;AA2ED;;;;;GAKG;AACH,q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