@spinajs/rbac-http-user 2.0.470 → 2.0.471
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/lib/cjs/controllers/LoginController.d.ts +35 -3
- package/lib/cjs/controllers/LoginController.d.ts.map +1 -1
- package/lib/cjs/controllers/LoginController.js +37 -10
- package/lib/cjs/controllers/LoginController.js.map +1 -1
- package/lib/cjs/controllers/TwoFactorAuthController.d.ts +39 -3
- package/lib/cjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
- package/lib/cjs/controllers/TwoFactorAuthController.js +35 -0
- package/lib/cjs/controllers/TwoFactorAuthController.js.map +1 -1
- package/lib/cjs/controllers/UserController.d.ts +37 -3
- package/lib/cjs/controllers/UserController.d.ts.map +1 -1
- package/lib/cjs/controllers/UserController.js +33 -0
- package/lib/cjs/controllers/UserController.js.map +1 -1
- package/lib/cjs/controllers/UserMetadataController.d.ts +134 -11
- package/lib/cjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/cjs/controllers/UserMetadataController.js +130 -8
- package/lib/cjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/cjs/dto/metadata-dto.d.ts +3 -0
- package/lib/cjs/dto/metadata-dto.d.ts.map +1 -1
- package/lib/cjs/dto/metadata-dto.js +3 -3
- package/lib/cjs/dto/metadata-dto.js.map +1 -1
- package/lib/cjs/dto/password-dto.d.ts +3 -0
- package/lib/cjs/dto/password-dto.d.ts.map +1 -1
- package/lib/cjs/dto/password-dto.js +3 -3
- package/lib/cjs/dto/password-dto.js.map +1 -1
- package/lib/cjs/dto/token-dto.d.ts +2 -0
- package/lib/cjs/dto/token-dto.d.ts.map +1 -1
- package/lib/cjs/dto/token-dto.js +2 -1
- package/lib/cjs/dto/token-dto.js.map +1 -1
- package/lib/cjs/dto/userLogin-dto.d.ts +3 -1
- package/lib/cjs/dto/userLogin-dto.d.ts.map +1 -1
- package/lib/cjs/dto/userLogin-dto.js +2 -2
- package/lib/cjs/dto/userLogin-dto.js.map +1 -1
- package/lib/mjs/controllers/LoginController.d.ts +35 -3
- package/lib/mjs/controllers/LoginController.d.ts.map +1 -1
- package/lib/mjs/controllers/LoginController.js +37 -10
- package/lib/mjs/controllers/LoginController.js.map +1 -1
- package/lib/mjs/controllers/TwoFactorAuthController.d.ts +39 -3
- package/lib/mjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
- package/lib/mjs/controllers/TwoFactorAuthController.js +36 -1
- package/lib/mjs/controllers/TwoFactorAuthController.js.map +1 -1
- package/lib/mjs/controllers/UserController.d.ts +37 -3
- package/lib/mjs/controllers/UserController.d.ts.map +1 -1
- package/lib/mjs/controllers/UserController.js +33 -0
- package/lib/mjs/controllers/UserController.js.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.d.ts +134 -11
- package/lib/mjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.js +130 -8
- package/lib/mjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/mjs/dto/metadata-dto.d.ts +3 -0
- package/lib/mjs/dto/metadata-dto.d.ts.map +1 -1
- package/lib/mjs/dto/metadata-dto.js +3 -3
- package/lib/mjs/dto/metadata-dto.js.map +1 -1
- package/lib/mjs/dto/password-dto.d.ts +3 -0
- package/lib/mjs/dto/password-dto.d.ts.map +1 -1
- package/lib/mjs/dto/password-dto.js +3 -3
- package/lib/mjs/dto/password-dto.js.map +1 -1
- package/lib/mjs/dto/token-dto.d.ts +2 -0
- package/lib/mjs/dto/token-dto.d.ts.map +1 -1
- package/lib/mjs/dto/token-dto.js +2 -1
- package/lib/mjs/dto/token-dto.js.map +1 -1
- package/lib/mjs/dto/userLogin-dto.d.ts +3 -1
- package/lib/mjs/dto/userLogin-dto.d.ts.map +1 -1
- package/lib/mjs/dto/userLogin-dto.js +2 -2
- package/lib/mjs/dto/userLogin-dto.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +11 -11
|
@@ -20,29 +20,80 @@ const orm_http_1 = require("@spinajs/orm-http");
|
|
|
20
20
|
const metadata_dto_js_1 = require("../dto/metadata-dto.js");
|
|
21
21
|
const orm_1 = require("@spinajs/orm");
|
|
22
22
|
const FilterableUserMetadata_js_1 = require("../models/FilterableUserMetadata.js");
|
|
23
|
+
/**
|
|
24
|
+
* User metadata management.
|
|
25
|
+
* Provides CRUD operations for key-value metadata entries attached to user accounts.
|
|
26
|
+
* Admin routes operate on any user (identified by UUID), while own routes operate on the
|
|
27
|
+
* currently authenticated user's metadata.
|
|
28
|
+
* @tags User Metadata
|
|
29
|
+
*/
|
|
23
30
|
let UserMetadataController = class UserMetadataController extends http_1.BaseController {
|
|
24
31
|
/**
|
|
25
|
-
*
|
|
32
|
+
* List metadata for a specific user (admin)
|
|
33
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the given user.
|
|
34
|
+
* @security cookieAuth
|
|
35
|
+
* @param user User UUID path parameter
|
|
36
|
+
* @param pagination.page Page number (zero-based)
|
|
37
|
+
* @param pagination.limit Number of entries per page
|
|
38
|
+
* @param order.column Column to sort by (default: Id)
|
|
39
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
40
|
+
* @returns {IUserMetadataEntry[]} Paginated list of metadata entries for the user
|
|
41
|
+
* @response 401 Unauthorized — valid session required
|
|
42
|
+
* @response 403 Forbidden — readAny permission required
|
|
43
|
+
* @response 404 User not found
|
|
26
44
|
*/
|
|
27
45
|
async readUserMeta(user, pagination, order, filter) {
|
|
28
46
|
return new http_1.Ok(FilterableUserMetadata_js_1.FilterableUserMetadata.select().where({
|
|
29
47
|
user_id: user.Id
|
|
30
|
-
}).filter(filter?.filters, filter?.op)
|
|
31
|
-
.take(pagination?.limit ??
|
|
32
|
-
.skip(pagination?.limit * pagination?.page
|
|
48
|
+
}).filter(filter?.filters ?? [], filter?.op)
|
|
49
|
+
.take(pagination?.limit ?? 0)
|
|
50
|
+
.skip((pagination?.limit ?? 0) * (pagination?.page ?? 0))
|
|
33
51
|
.order(order?.column ?? 'Id', order?.order ?? orm_1.SortOrder.DESC));
|
|
34
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Get a single metadata entry for a specific user (admin)
|
|
55
|
+
* Retrieves one metadata entry by key for the given user.
|
|
56
|
+
* @security cookieAuth
|
|
57
|
+
* @param user User UUID path parameter
|
|
58
|
+
* @param key Metadata key to retrieve
|
|
59
|
+
* @returns {IUserMetadataEntry} Single metadata entry for the user
|
|
60
|
+
* @response 401 Unauthorized — valid session required
|
|
61
|
+
* @response 403 Forbidden — readAny permission required
|
|
62
|
+
* @response 404 User or metadata key not found
|
|
63
|
+
*/
|
|
35
64
|
async getUserMeta(user, key) {
|
|
36
65
|
return new http_1.Ok(rbac_1.UserMetadata.where({
|
|
37
66
|
Key: key,
|
|
38
67
|
user_id: user.Id
|
|
39
68
|
}).firstOrFail());
|
|
40
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Add or update metadata for a specific user (admin)
|
|
72
|
+
* Inserts a new metadata entry for the given user, or updates it if the key already exists.
|
|
73
|
+
* @security cookieAuth
|
|
74
|
+
* @param user User UUID path parameter
|
|
75
|
+
* @response 200 Metadata created or updated successfully
|
|
76
|
+
* @response 401 Unauthorized — valid session required
|
|
77
|
+
* @response 403 Forbidden — updateAny permission required
|
|
78
|
+
* @response 404 User not found
|
|
79
|
+
*/
|
|
41
80
|
async addUserMetadata(user, metadata) {
|
|
42
81
|
metadata.User.attach(user);
|
|
43
82
|
await metadata.insert(orm_1.InsertBehaviour.InsertOrUpdate);
|
|
44
83
|
return new http_1.Ok();
|
|
45
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Update a metadata entry for a specific user (admin)
|
|
87
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
88
|
+
* @security cookieAuth
|
|
89
|
+
* @param _user User UUID path parameter (used for authorization scope)
|
|
90
|
+
* @param meta Metadata Id or Key to update
|
|
91
|
+
|
|
92
|
+
* @response 200 Metadata updated successfully
|
|
93
|
+
* @response 401 Unauthorized — valid session required
|
|
94
|
+
* @response 403 Forbidden — updateAny permission required
|
|
95
|
+
* @response 404 User or metadata entry not found
|
|
96
|
+
*/
|
|
46
97
|
async updateUserMetadata(meta, _user, data) {
|
|
47
98
|
await meta.update({
|
|
48
99
|
Key: data.Key,
|
|
@@ -51,6 +102,17 @@ let UserMetadataController = class UserMetadataController extends http_1.BaseCon
|
|
|
51
102
|
});
|
|
52
103
|
return new http_1.Ok();
|
|
53
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Delete a metadata entry for a specific user (admin)
|
|
107
|
+
* Permanently removes a metadata entry by Id from the given user's metadata.
|
|
108
|
+
* @security cookieAuth
|
|
109
|
+
* @param user User UUID path parameter
|
|
110
|
+
* @param meta Metadata Id to delete
|
|
111
|
+
* @response 200 Metadata deleted successfully
|
|
112
|
+
* @response 401 Unauthorized — valid session required
|
|
113
|
+
* @response 403 Forbidden — deleteAny permission required
|
|
114
|
+
* @response 404 User or metadata entry not found
|
|
115
|
+
*/
|
|
54
116
|
async deleteUserMetadata(user, meta) {
|
|
55
117
|
await rbac_1.UserMetadata.destroy().where({
|
|
56
118
|
Id: meta,
|
|
@@ -59,22 +121,72 @@ let UserMetadataController = class UserMetadataController extends http_1.BaseCon
|
|
|
59
121
|
return new http_1.Ok();
|
|
60
122
|
}
|
|
61
123
|
/**
|
|
62
|
-
*
|
|
124
|
+
* List own metadata
|
|
125
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
126
|
+
* @security cookieAuth
|
|
127
|
+
* @param pagination.page Page number (zero-based)
|
|
128
|
+
* @param pagination.limit Number of entries per page
|
|
129
|
+
* @param order.column Column to sort by (default: Id)
|
|
130
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
131
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
132
|
+
* @response 401 Unauthorized — valid session required
|
|
133
|
+
* @response 403 Forbidden — readOwn permission required
|
|
134
|
+
*/
|
|
135
|
+
/**
|
|
136
|
+
* List own metadata
|
|
137
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
138
|
+
* @security cookieAuth
|
|
139
|
+
* @param pagination.page Page number (zero-based)
|
|
140
|
+
* @param pagination.limit Number of entries per page
|
|
141
|
+
* @param order.column Column to sort by (default: Id)
|
|
142
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
143
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
144
|
+
* @response 401 Unauthorized — valid session required
|
|
145
|
+
* @response 403 Forbidden — readOwn permission required
|
|
63
146
|
*/
|
|
64
147
|
async readMeta(pagination, order, filter) {
|
|
65
|
-
return new http_1.Ok(FilterableUserMetadata_js_1.FilterableUserMetadata.select().filter(filter?.filters, filter?.op)
|
|
66
|
-
.take(pagination?.limit ??
|
|
67
|
-
.skip(pagination?.limit * pagination?.page
|
|
148
|
+
return new http_1.Ok(FilterableUserMetadata_js_1.FilterableUserMetadata.select().filter(filter?.filters ?? [], filter?.op)
|
|
149
|
+
.take(pagination?.limit ?? 0)
|
|
150
|
+
.skip((pagination?.limit ?? 0) * (pagination?.page ?? 0))
|
|
68
151
|
.order(order?.column ?? 'Id', order?.order ?? orm_1.SortOrder.DESC));
|
|
69
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Get own metadata entry by key
|
|
155
|
+
* Retrieves a single metadata entry by key for the authenticated user.
|
|
156
|
+
* @security cookieAuth
|
|
157
|
+
* @param key Metadata key to retrieve
|
|
158
|
+
* @returns {IUserMetadataEntry} Single own metadata entry by key
|
|
159
|
+
* @response 401 Unauthorized — valid session required
|
|
160
|
+
* @response 403 Forbidden — readOwn permission required
|
|
161
|
+
* @response 404 Metadata key not found
|
|
162
|
+
*/
|
|
70
163
|
async getMeta(key) {
|
|
71
164
|
return new http_1.Ok(rbac_1.UserMetadata.where({
|
|
72
165
|
Key: key,
|
|
73
166
|
}).firstOrFail());
|
|
74
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Add or update own metadata
|
|
170
|
+
* Inserts a new metadata entry for the authenticated user, or updates it if the key already exists.
|
|
171
|
+
* @security cookieAuth
|
|
172
|
+
* @response 200 Metadata created or updated successfully
|
|
173
|
+
* @response 401 Unauthorized — valid session required
|
|
174
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
175
|
+
*/
|
|
75
176
|
async addMetadata(metadata) {
|
|
76
177
|
await metadata.insert(orm_1.InsertBehaviour.InsertOrUpdate);
|
|
77
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Update own metadata entry
|
|
181
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
182
|
+
* @security cookieAuth
|
|
183
|
+
* @param meta Metadata Id or Key to update
|
|
184
|
+
|
|
185
|
+
* @response 200 Metadata updated successfully
|
|
186
|
+
* @response 401 Unauthorized — valid session required
|
|
187
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
188
|
+
* @response 404 Metadata entry not found
|
|
189
|
+
*/
|
|
78
190
|
async updateMetadata(meta, data) {
|
|
79
191
|
await rbac_1.UserMetadata.update({
|
|
80
192
|
Key: data.Key,
|
|
@@ -83,6 +195,16 @@ let UserMetadataController = class UserMetadataController extends http_1.BaseCon
|
|
|
83
195
|
}).where("Key", meta).orWhere("Id", meta);
|
|
84
196
|
return new http_1.Ok();
|
|
85
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Delete own metadata entry
|
|
200
|
+
* Permanently removes a metadata entry by Id from the authenticated user's metadata.
|
|
201
|
+
* @security cookieAuth
|
|
202
|
+
* @param meta Metadata Id to delete
|
|
203
|
+
* @response 200 Metadata deleted successfully
|
|
204
|
+
* @response 401 Unauthorized — valid session required
|
|
205
|
+
* @response 403 Forbidden — deleteOwn permission required
|
|
206
|
+
* @response 404 Metadata entry not found
|
|
207
|
+
*/
|
|
86
208
|
async deleteMetadata(meta) {
|
|
87
209
|
await rbac_1.UserMetadata.destroy().where({
|
|
88
210
|
Id: meta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAgH;AAChH,wCAAgE;AAChE,kDAA4E;AAC5E,gDAAwG;AACxG,4DAAyD;AACzD,sCAA0D;AAC1D,mFAA6E;
|
|
1
|
+
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAgH;AAChH,wCAAgE;AAChE,kDAA4E;AAC5E,gDAAwG;AACxG,4DAAyD;AACzD,sCAA0D;AAC1D,mFAA6E;AAE7E;;;;;;GAMG;AAII,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,qBAAc;IAEtD;;;;;;;;;;;;;OAaG;IAGU,AAAN,KAAK,CAAC,YAAY,CACc,IAAe,EACzC,UAA0B,EAC1B,KAAgB,EAEzB,MAAuB;QAEvB,OAAO,IAAI,SAAE,CAAC,kDAAsB,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;YAChD,OAAO,EAAE,IAAI,CAAC,EAAE;SACnB,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;aACvC,IAAI,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC,CAAC;aAC5B,IAAI,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;aACxD,KAAK,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,eAAS,CAAC,IAAI,CAAC,CAChE,CAAC;IACN,CAAC;IAGD;;;;;;;;;;OAUG;IAGU,AAAN,KAAK,CAAC,WAAW,CACe,IAAe,EACzC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,EAAC,gBAAgB,CAAC;IACrB,IAAA,sBAAU,EAAC,CAAC,WAAW,CAAC,CAAC;IACG,WAAA,IAAA,YAAK,GAAE,CAAA;;;;4DAMnC;iCA1PQ,sBAAsB;IAHlC,IAAA,eAAQ,EAAC,MAAM,CAAC;IAChB,IAAA,oBAAQ,EAAC,eAAe,CAAC;IACzB,IAAA,aAAM,EAAC,4BAAgB,CAAC;GACZ,sBAAsB,CA2PlC"}
|
|
@@ -7,13 +7,16 @@ export declare const MetadataDtoSchema: {
|
|
|
7
7
|
type: string;
|
|
8
8
|
maxLength: number;
|
|
9
9
|
minLength: number;
|
|
10
|
+
description: string;
|
|
10
11
|
};
|
|
11
12
|
Value: {
|
|
12
13
|
type: string;
|
|
14
|
+
description: string;
|
|
13
15
|
};
|
|
14
16
|
Type: {
|
|
15
17
|
type: string;
|
|
16
18
|
enum: string[];
|
|
19
|
+
description: string;
|
|
17
20
|
};
|
|
18
21
|
};
|
|
19
22
|
required: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"metadata-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;CAU7B,CAAC;AAEF,qBACa,eAAe;IACjB,GAAG,EAAG,MAAM,CAAC;IACb,KAAK,EAAG,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;gBACjE,IAAI,EAAE,GAAG;CAGxB"}
|
|
@@ -16,9 +16,9 @@ exports.MetadataDtoSchema = {
|
|
|
16
16
|
title: 'User metadata DTO',
|
|
17
17
|
type: 'object',
|
|
18
18
|
properties: {
|
|
19
|
-
Key: { type: 'string', maxLength: 255, minLength: 6 },
|
|
20
|
-
Value: { type: 'string' },
|
|
21
|
-
Type: { type:
|
|
19
|
+
Key: { type: 'string', maxLength: 255, minLength: 6, description: 'Metadata key (dot-notation supported, e.g. user:niceName)' },
|
|
20
|
+
Value: { type: 'string', description: 'Metadata value stored as a string regardless of Type' },
|
|
21
|
+
Type: { type: 'string', enum: ['number', 'float', 'string', 'json', 'boolean', 'datetime'], description: 'Declared value type used for serialization/deserialization' },
|
|
22
22
|
},
|
|
23
23
|
required: ['Key', 'Type'],
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-dto.js","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,iBAAiB,GAAG;IAC7B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"metadata-dto.js","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,iBAAiB,GAAG;IAC7B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,2DAA2D,EAAE;QAC/H,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,WAAW,EAAE,4DAA4D,EAAE;KAC1K;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;CAC5B,CAAC;AAGK,IAAM,eAAe,GAArB,MAAM,eAAe;IAIxB,YAAY,IAAS;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;CACJ,CAAA;AAPY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAM,EAAC,yBAAiB,CAAC;;GACb,eAAe,CAO3B"}
|
|
@@ -7,16 +7,19 @@ export declare const PasswordDtoSchema: {
|
|
|
7
7
|
type: string;
|
|
8
8
|
maxLength: number;
|
|
9
9
|
minLength: number;
|
|
10
|
+
description: string;
|
|
10
11
|
};
|
|
11
12
|
Password: {
|
|
12
13
|
type: string;
|
|
13
14
|
maxLength: number;
|
|
14
15
|
minLength: number;
|
|
16
|
+
description: string;
|
|
15
17
|
};
|
|
16
18
|
ConfirmPassword: {
|
|
17
19
|
type: string;
|
|
18
20
|
maxLength: number;
|
|
19
21
|
minLength: number;
|
|
22
|
+
description: string;
|
|
20
23
|
};
|
|
21
24
|
};
|
|
22
25
|
required: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/password-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"password-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/password-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;CAU7B,CAAC;AAEF,qBACa,WAAW;IACf,WAAW,EAAE,MAAM,CAAC;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAEjB,eAAe,EAAE,MAAM,CAAC;gBAEnB,IAAI,EAAE,GAAG;CAGtB"}
|
|
@@ -16,9 +16,9 @@ exports.PasswordDtoSchema = {
|
|
|
16
16
|
title: 'User password DTO',
|
|
17
17
|
type: 'object',
|
|
18
18
|
properties: {
|
|
19
|
-
OldPassword: { type: 'string', maxLength: 32, minLength: 6 },
|
|
20
|
-
Password: { type: 'string', maxLength: 32, minLength: 6 },
|
|
21
|
-
ConfirmPassword: { type: 'string', maxLength: 32, minLength: 6 },
|
|
19
|
+
OldPassword: { type: 'string', maxLength: 32, minLength: 6, description: 'Current password for verification' },
|
|
20
|
+
Password: { type: 'string', maxLength: 32, minLength: 6, description: 'New password (6–32 characters)' },
|
|
21
|
+
ConfirmPassword: { type: 'string', maxLength: 32, minLength: 6, description: 'Must match Password' },
|
|
22
22
|
},
|
|
23
23
|
required: ['OldPassword', 'Password', 'ConfirmPassword'],
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-dto.js","sourceRoot":"","sources":["../../../src/dto/password-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"password-dto.js","sourceRoot":"","sources":["../../../src/dto/password-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,mCAAmC,EAAE;QAC9G,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE;QACxG,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE;KACrG;IACD,QAAQ,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC;CACzD,CAAC;AAGK,IAAM,WAAW,GAAjB,MAAM,WAAW;IAOtB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AAVY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAM,EAAC,yBAAiB,CAAC;;GACb,WAAW,CAUvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/token-dto.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"token-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/token-dto.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc;;;;;;;;;;;;CAQ1B,CAAC;AAEF,qBACa,QAAQ;IACZ,KAAK,EAAE,MAAM,CAAC;gBAET,IAAI,EAAE,GAAG;CAGtB"}
|
package/lib/cjs/dto/token-dto.js
CHANGED
|
@@ -16,8 +16,9 @@ exports.TokenDtoSchema = {
|
|
|
16
16
|
title: 'Token DTO',
|
|
17
17
|
type: 'object',
|
|
18
18
|
properties: {
|
|
19
|
-
Token: { type: 'string', maxLength: 64 },
|
|
19
|
+
Token: { type: 'string', maxLength: 64, description: 'Six-digit TOTP code from the authenticator app' },
|
|
20
20
|
},
|
|
21
|
+
required: ['Token'],
|
|
21
22
|
};
|
|
22
23
|
let TokenDto = class TokenDto {
|
|
23
24
|
constructor(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-dto.js","sourceRoot":"","sources":["../../../src/dto/token-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAChC,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"token-dto.js","sourceRoot":"","sources":["../../../src/dto/token-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAChC,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE;KACxG;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;CACpB,CAAC;AAGK,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAGnB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AANY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,mBAAM,EAAC,sBAAc,CAAC;;GACV,QAAQ,CAMpB"}
|
|
@@ -3,13 +3,15 @@ export declare const UserLoginDtoSchema: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
type: string;
|
|
5
5
|
properties: {
|
|
6
|
-
|
|
6
|
+
Email: {
|
|
7
7
|
type: string;
|
|
8
8
|
format: string;
|
|
9
|
+
description: string;
|
|
9
10
|
};
|
|
10
11
|
Password: {
|
|
11
12
|
type: string;
|
|
12
13
|
maxLength: number;
|
|
14
|
+
description: string;
|
|
13
15
|
};
|
|
14
16
|
};
|
|
15
17
|
required: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userLogin-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/userLogin-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"userLogin-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/userLogin-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAS9B,CAAC;AAEF,qBACa,YAAY;IAChB,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,GAAG;CAGtB"}
|
|
@@ -16,8 +16,8 @@ exports.UserLoginDtoSchema = {
|
|
|
16
16
|
title: 'User login DTO',
|
|
17
17
|
type: 'object',
|
|
18
18
|
properties: {
|
|
19
|
-
|
|
20
|
-
Password: { type: 'string', maxLength: 32 },
|
|
19
|
+
Email: { type: 'string', format: 'email', description: 'User email address' },
|
|
20
|
+
Password: { type: 'string', maxLength: 32, description: 'User password' },
|
|
21
21
|
},
|
|
22
22
|
required: ['Email', 'Password'],
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userLogin-dto.js","sourceRoot":"","sources":["../../../src/dto/userLogin-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"userLogin-dto.js","sourceRoot":"","sources":["../../../src/dto/userLogin-dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA6C;AAEhC,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE;QAC7E,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE;KAC1E;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;CAChC,CAAC;AAGK,IAAM,YAAY,GAAlB,MAAM,YAAY;IAKvB,YAAY,IAAS;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF,CAAA;AARY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAM,EAAC,0BAAkB,CAAC;;GACd,YAAY,CAQxB"}
|
|
@@ -2,7 +2,14 @@ import { UserLoginDto } from '../dto/userLogin-dto.js';
|
|
|
2
2
|
import { BaseController, Ok, Unauthorized } from '@spinajs/http';
|
|
3
3
|
import { AuthProvider, SessionProvider, AccessControl } from '@spinajs/rbac';
|
|
4
4
|
import { Configuration } from '@spinajs/configuration';
|
|
5
|
+
import { ILoginResponse } from '@spinajs/rbac-http';
|
|
5
6
|
import { User } from '@spinajs/rbac';
|
|
7
|
+
/**
|
|
8
|
+
* Authentication endpoints.
|
|
9
|
+
* Handles user login, logout, and current-session inspection.
|
|
10
|
+
* All session state is maintained via the signed `ssid` cookie.
|
|
11
|
+
* @tags Authentication
|
|
12
|
+
*/
|
|
6
13
|
export declare class LoginController extends BaseController {
|
|
7
14
|
protected Configuration: Configuration;
|
|
8
15
|
protected AuthProvider: AuthProvider;
|
|
@@ -12,8 +19,33 @@ export declare class LoginController extends BaseController {
|
|
|
12
19
|
protected TwoFactorAuthForceUser: boolean;
|
|
13
20
|
protected SessionCookieConfig: any;
|
|
14
21
|
protected AC: AccessControl;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Login
|
|
24
|
+
* Authenticates the user with email and password. On success, sets the signed `ssid` session cookie
|
|
25
|
+
* and returns user data with their RBAC grants. When two-factor authentication is enabled and
|
|
26
|
+
* configured for the user, the response instead signals that 2FA verification is required.
|
|
27
|
+
* If the caller already has an active session it is invalidated before creating a new one.
|
|
28
|
+
* @security []
|
|
29
|
+
* @returns {ILoginResponse} On full login: IUserWithGrants. On 2FA required: ITwoFactorAuthRequired. On 2FA setup required: ITwoFactorInitRequired
|
|
30
|
+
* @response 401 Invalid email or password
|
|
31
|
+
*/
|
|
32
|
+
login(logged: User, ssid: string, credentials: UserLoginDto): Promise<Ok<ILoginResponse> | Unauthorized>;
|
|
33
|
+
/**
|
|
34
|
+
* Logout
|
|
35
|
+
* Destroys the current session identified by the `ssid` cookie and clears the cookie on the client.
|
|
36
|
+
* Requires the user to be logged in (session exists), but full authorization (2FA) is not required.
|
|
37
|
+
* @security cookieAuth
|
|
38
|
+
* @response 401 No active session
|
|
39
|
+
*/
|
|
40
|
+
logout(ssid: string): Promise<Ok<any>>;
|
|
41
|
+
/**
|
|
42
|
+
* Get current user
|
|
43
|
+
* Returns the user object associated with the current session.
|
|
44
|
+
* Requires the user to be logged in (session exists), but full authorization (2FA) is not required.
|
|
45
|
+
* @security cookieAuth
|
|
46
|
+
* @returns {IUserProfile} User data from the current session
|
|
47
|
+
* @response 401 No active session
|
|
48
|
+
*/
|
|
49
|
+
whoami(User: User): Promise<Ok<User>>;
|
|
18
50
|
}
|
|
19
51
|
//# sourceMappingURL=LoginController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginController.d.ts","sourceRoot":"","sources":["../../../src/controllers/LoginController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAwB,EAAE,EAAe,YAAY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C;;;;;;;OAOG;IAGU,MAAM,CAAiB,IAAI,EAAE,IAAI;CAK/C"}
|
|
@@ -17,7 +17,23 @@ import { Autoinject } from '@spinajs/di';
|
|
|
17
17
|
import { AutoinjectService, Config, Configuration } from '@spinajs/configuration';
|
|
18
18
|
import { LoggedPolicy, User as UserRouteArg } from '@spinajs/rbac-http';
|
|
19
19
|
import { User } from '@spinajs/rbac';
|
|
20
|
+
/**
|
|
21
|
+
* Authentication endpoints.
|
|
22
|
+
* Handles user login, logout, and current-session inspection.
|
|
23
|
+
* All session state is maintained via the signed `ssid` cookie.
|
|
24
|
+
* @tags Authentication
|
|
25
|
+
*/
|
|
20
26
|
let LoginController = class LoginController extends BaseController {
|
|
27
|
+
/**
|
|
28
|
+
* Login
|
|
29
|
+
* Authenticates the user with email and password. On success, sets the signed `ssid` session cookie
|
|
30
|
+
* and returns user data with their RBAC grants. When two-factor authentication is enabled and
|
|
31
|
+
* configured for the user, the response instead signals that 2FA verification is required.
|
|
32
|
+
* If the caller already has an active session it is invalidated before creating a new one.
|
|
33
|
+
* @security []
|
|
34
|
+
* @returns {ILoginResponse} On full login: IUserWithGrants. On 2FA required: ITwoFactorAuthRequired. On 2FA setup required: ITwoFactorInitRequired
|
|
35
|
+
* @response 401 Invalid email or password
|
|
36
|
+
*/
|
|
21
37
|
async login(logged, ssid, credentials) {
|
|
22
38
|
try {
|
|
23
39
|
// if logged user is already logged in, delete his session
|
|
@@ -42,7 +58,7 @@ let LoginController = class LoginController extends BaseController {
|
|
|
42
58
|
},
|
|
43
59
|
},
|
|
44
60
|
];
|
|
45
|
-
let result
|
|
61
|
+
let result;
|
|
46
62
|
session.Data.set('User', user.Uuid);
|
|
47
63
|
// we have two states for user
|
|
48
64
|
// LOGGED - when user use proper login/password and session is created
|
|
@@ -58,9 +74,7 @@ let LoginController = class LoginController extends BaseController {
|
|
|
58
74
|
});
|
|
59
75
|
session.Data.set('Authorized', false);
|
|
60
76
|
session.Data.set('TwoFactorAuth', true);
|
|
61
|
-
result = {
|
|
62
|
-
TwoFactorInitRequired: true,
|
|
63
|
-
};
|
|
77
|
+
result = { TwoFactorInitRequired: true };
|
|
64
78
|
}
|
|
65
79
|
else if (this.TwoFactorAuthEnabled && user.Metadata['2fa:enabled']) {
|
|
66
80
|
this._log.trace('User logged in, 2fa required', {
|
|
@@ -68,19 +82,17 @@ let LoginController = class LoginController extends BaseController {
|
|
|
68
82
|
});
|
|
69
83
|
session.Data.set('Authorized', false);
|
|
70
84
|
session.Data.set('TwoFactorAuth', true);
|
|
71
|
-
result = {
|
|
72
|
-
TwoFactorAuthRequired: true,
|
|
73
|
-
};
|
|
85
|
+
result = { TwoFactorAuthRequired: true };
|
|
74
86
|
}
|
|
75
87
|
else {
|
|
76
88
|
session.Data.set('Authorized', true);
|
|
77
89
|
const grants = this.AC.getGrants();
|
|
78
90
|
const userGrants = user.Role.map(r => _unwindGrants(r, grants));
|
|
79
91
|
const combinedGrants = Object.assign({}, ...userGrants);
|
|
92
|
+
// dehydrateWithRelations({ dateTimeFormat: 'iso' }) converts DateTime to ISO strings
|
|
93
|
+
// at runtime — the ORM types don't reflect the dateTimeFormat option in generics
|
|
80
94
|
result = {
|
|
81
|
-
...user.dehydrateWithRelations({
|
|
82
|
-
dateTimeFormat: "iso"
|
|
83
|
-
}),
|
|
95
|
+
...user.dehydrateWithRelations({ dateTimeFormat: "iso" }),
|
|
84
96
|
Grants: combinedGrants,
|
|
85
97
|
};
|
|
86
98
|
}
|
|
@@ -102,6 +114,13 @@ let LoginController = class LoginController extends BaseController {
|
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Logout
|
|
119
|
+
* Destroys the current session identified by the `ssid` cookie and clears the cookie on the client.
|
|
120
|
+
* Requires the user to be logged in (session exists), but full authorization (2FA) is not required.
|
|
121
|
+
* @security cookieAuth
|
|
122
|
+
* @response 401 No active session
|
|
123
|
+
*/
|
|
105
124
|
async logout(ssid) {
|
|
106
125
|
if (!ssid) {
|
|
107
126
|
return new Ok();
|
|
@@ -124,6 +143,14 @@ let LoginController = class LoginController extends BaseController {
|
|
|
124
143
|
],
|
|
125
144
|
});
|
|
126
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Get current user
|
|
148
|
+
* Returns the user object associated with the current session.
|
|
149
|
+
* Requires the user to be logged in (session exists), but full authorization (2FA) is not required.
|
|
150
|
+
* @security cookieAuth
|
|
151
|
+
* @returns {IUserProfile} User data from the current session
|
|
152
|
+
* @response 401 No active session
|
|
153
|
+
*/
|
|
127
154
|
async whoami(User) {
|
|
128
155
|
// user is taken from session data
|
|
129
156
|
return new Ok(User);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginController.js","sourceRoot":"","sources":["../../../src/controllers/LoginController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,IAAI,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"LoginController.js","sourceRoot":"","sources":["../../../src/controllers/LoginController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAA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C,IAAI,CAAC,CAAA;;;;6CAwBhC;AAYY;IAFZ,GAAG,EAAE;IACL,MAAM,CAAC,YAAY,CAAC;IACA,WAAA,YAAY,EAAE,CAAA;;qCAAO,IAAI;;6CAI7C;AApMU,eAAe;IAD3B,QAAQ,CAAC,MAAM,CAAC;GACJ,eAAe,CAqM3B"}
|
|
@@ -2,12 +2,48 @@ import { TokenDto } from './../dto/token-dto.js';
|
|
|
2
2
|
import { BaseController, Ok, ForbiddenResponse } from '@spinajs/http';
|
|
3
3
|
import { ISession, SessionProvider, User as UserModel, AccessControl } from '@spinajs/rbac';
|
|
4
4
|
import { QueueService } from '@spinajs/queue';
|
|
5
|
+
import { IEnable2faResponse, IUserWithGrants } from "@spinajs/rbac-http";
|
|
6
|
+
/**
|
|
7
|
+
* Two-factor authentication (TOTP) management.
|
|
8
|
+
* Enables, disables, and verifies TOTP-based two-factor authentication for users.
|
|
9
|
+
* All routes are only available when 2FA is enabled in the system configuration.
|
|
10
|
+
* The caller must be logged in but does NOT need to be fully authorized (2FA verified),
|
|
11
|
+
* allowing these routes to be used during the 2FA verification step itself.
|
|
12
|
+
* @tags Two-Factor Authentication
|
|
13
|
+
*/
|
|
5
14
|
export declare class TwoFactorAuthController extends BaseController {
|
|
6
15
|
protected Queue: QueueService;
|
|
7
16
|
protected SessionProvider: SessionProvider;
|
|
8
17
|
protected AC: AccessControl;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Enable two-factor authentication
|
|
20
|
+
* Generates a TOTP secret for the authenticated user and returns the OTP provisioning URI
|
|
21
|
+
* to be scanned by an authenticator app. Throws if 2FA is already enabled for the user.
|
|
22
|
+
* @security cookieAuth
|
|
23
|
+
* @returns {IEnable2faResponse} OTP provisioning URI to scan with an authenticator app
|
|
24
|
+
* @response 400 Two-factor authentication is already enabled for this user
|
|
25
|
+
* @response 401 Unauthorized — valid session required
|
|
26
|
+
*/
|
|
27
|
+
enable2fa(user: UserModel): Promise<Ok<IEnable2faResponse>>;
|
|
28
|
+
/**
|
|
29
|
+
* Disable two-factor authentication
|
|
30
|
+
* Removes the TOTP secret and disables 2FA for the authenticated user.
|
|
31
|
+
* Throws if 2FA is not currently enabled for the user.
|
|
32
|
+
* @security cookieAuth
|
|
33
|
+
* @response 200 Two-factor authentication disabled successfully
|
|
34
|
+
* @response 400 Two-factor authentication is not enabled for this user
|
|
35
|
+
* @response 401 Unauthorized — valid session required
|
|
36
|
+
*/
|
|
37
|
+
disable2Fa(user: UserModel): Promise<Ok<any>>;
|
|
38
|
+
/**
|
|
39
|
+
* Verify TOTP token
|
|
40
|
+
* Validates the provided TOTP token against the user's 2FA secret. On success, marks the session
|
|
41
|
+
* as fully authorized and returns the user profile with RBAC grants — identical to a full login response.
|
|
42
|
+
* @security cookieAuth
|
|
43
|
+
* @returns {IUserWithGrants} User profile merged with RBAC grants on successful 2FA verification
|
|
44
|
+
* @response 403 Invalid or expired TOTP token
|
|
45
|
+
* @response 401 Unauthorized — valid session required
|
|
46
|
+
*/
|
|
47
|
+
verifyToken(logged: UserModel, token: TokenDto, session: ISession): Promise<Ok<IUserWithGrants> | ForbiddenResponse>;
|
|
12
48
|
}
|
|
13
49
|
//# sourceMappingURL=TwoFactorAuthController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwoFactorAuthController.d.ts","sourceRoot":"","sources":["../../../src/controllers/TwoFactorAuthController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAY,EAAE,EAAa,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,IAAI,SAAS,EAAyC,aAAa,EAAE,MAAM,eAAe,CAAC;AAOnI,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"TwoFactorAuthController.d.ts","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