@lobb-js/lobb-ext-auth 0.1.67 → 0.2.2
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/.vscode/settings.json +5 -0
- package/CHANGELOG.md +90 -31
- package/README.md +1 -1
- package/extensions/auth/collections/activityFeed.ts +53 -0
- package/extensions/auth/collections/collections.ts +43 -0
- package/extensions/auth/collections/sessions.ts +34 -0
- package/extensions/auth/collections/users.ts +44 -0
- package/extensions/auth/config/extensionConfigSchema.ts +47 -0
- package/extensions/auth/config/permissionsAction/create.ts +20 -0
- package/extensions/auth/config/permissionsAction/delete.ts +3 -0
- package/extensions/auth/config/permissionsAction/read.ts +10 -0
- package/extensions/auth/config/permissionsAction/update.ts +20 -0
- package/extensions/auth/database/init.ts +51 -0
- package/extensions/auth/database/migrations.ts +3 -0
- package/extensions/auth/database/utils.ts +36 -0
- package/extensions/auth/index.ts +19 -0
- package/extensions/auth/meta/meta.ts +11 -0
- package/extensions/auth/openapi.ts +469 -0
- package/extensions/auth/studio/tests/login.spec.ts +34 -0
- package/extensions/auth/studio/tests/package.json +1 -0
- package/extensions/auth/studio/tests/playwright.config.cjs +27 -0
- package/extensions/auth/tests/collections/extend_users_collection.test.ts +61 -0
- package/extensions/auth/tests/configs/auth.ts +73 -0
- package/extensions/auth/tests/configs/auth_no_roles.ts +65 -0
- package/extensions/auth/tests/configs/auth_public_full_access.ts +69 -0
- package/extensions/auth/tests/configs/auth_with_different_admin_creds.ts +81 -0
- package/extensions/auth/tests/configs/auth_with_extend_users.ts +81 -0
- package/extensions/auth/tests/configs/auth_with_refresh_token.ts +86 -0
- package/extensions/auth/tests/configs/auth_with_short_access_token_only.ts +95 -0
- package/extensions/auth/tests/configs/auth_with_short_time_refresh_token.ts +86 -0
- package/extensions/auth/tests/configs/social_blog.ts +156 -0
- package/extensions/auth/tests/controllers/change_password.test.ts +113 -0
- package/extensions/auth/tests/controllers/dashboardAccessRoles.test.ts +29 -0
- package/extensions/auth/tests/controllers/login.test.ts +101 -0
- package/extensions/auth/tests/controllers/logout.test.ts +89 -0
- package/extensions/auth/tests/controllers/me.test.ts +272 -0
- package/extensions/auth/tests/controllers/register.test.ts +45 -0
- package/extensions/auth/tests/database/db.test.ts +64 -0
- package/extensions/auth/tests/database/differentAdminCreds.test.ts +51 -0
- package/extensions/auth/tests/middlewares/adminAuthGuard.test.ts +157 -0
- package/extensions/auth/tests/middlewares/publicAllowBasic.test.ts +137 -0
- package/extensions/auth/tests/middlewares/publicPreventBasic.test.ts +108 -0
- package/extensions/auth/tests/socialBlog.test.ts +253 -0
- package/extensions/auth/tests/utils/addArticles.ts +22 -0
- package/extensions/auth/tests/utils/addSocialBlogArticles.ts +52 -0
- package/extensions/auth/tests/utils/data/articles.ts +65 -0
- package/extensions/auth/tests/utils/data/socialBlogArticles.ts +56 -0
- package/extensions/auth/utils.ts +17 -0
- package/extensions/auth/workflows/baseWorkflow.ts +159 -0
- package/extensions/auth/workflows/hashHandlerWorkflows.ts +29 -0
- package/extensions/auth/workflows/index.ts +29 -0
- package/extensions/auth/workflows/meAliasWorkflows.ts +48 -0
- package/extensions/auth/workflows/policiesWorkflows.ts +240 -0
- package/extensions/auth/workflows/utils.ts +306 -0
- package/lobb.ts +108 -0
- package/package.json +33 -6
- package/public/public/vite.svg +1 -0
- package/scripts/postpublish.sh +12 -0
- package/scripts/prepublish.sh +17 -0
- package/studio/app.html +12 -0
- package/studio/routes/+layout.svelte +7 -0
- package/studio/routes/+layout.ts +1 -0
- package/studio/routes/[...path]/+page.svelte +6 -0
- package/svelte.config.js +23 -7
- package/todo.md +37 -0
- package/tsconfig.app.json +3 -3
- package/tsconfig.json +9 -10
- package/vite.config.ts +4 -8
- package/.env +0 -1
- package/components.json +0 -16
- package/index.html +0 -13
- package/src/app.css +0 -124
- package/src/main.ts +0 -14
- /package/{src → extensions/auth/studio}/auth.ts +0 -0
- /package/{src → extensions/auth/studio}/index.ts +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/loginPage/index.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/settings/index.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/activityFeed.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/rolesAndPermissions.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/settings/pages/users.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/components/account.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/components/profile.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/components/pages/userSettings/index.svelte +0 -0
- /package/{src → extensions/auth/studio}/lib/index.ts +0 -0
- /package/{src → extensions/auth/studio}/lib/utils.ts +0 -0
- /package/{src → extensions/auth/studio}/onStartup.ts +0 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
export const openapi = {
|
|
2
|
+
components: {
|
|
3
|
+
email_provider: {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
provider: {
|
|
7
|
+
type: "string",
|
|
8
|
+
default: "email",
|
|
9
|
+
required: false,
|
|
10
|
+
},
|
|
11
|
+
email: {
|
|
12
|
+
type: "string",
|
|
13
|
+
example: "admin@test.com",
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
password: {
|
|
17
|
+
type: "string",
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
firebase_provider: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
provider: {
|
|
26
|
+
type: "string",
|
|
27
|
+
const: "firebase",
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
token: {
|
|
31
|
+
type: "string",
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
paths: {
|
|
38
|
+
"/api/extensions/auth/login": {
|
|
39
|
+
post: {
|
|
40
|
+
tags: [
|
|
41
|
+
"auth",
|
|
42
|
+
],
|
|
43
|
+
summary: `Login a user`,
|
|
44
|
+
description:
|
|
45
|
+
`This is used to login a user by email or any other adapter`,
|
|
46
|
+
requestBody: {
|
|
47
|
+
required: true,
|
|
48
|
+
content: {
|
|
49
|
+
"application/json": {
|
|
50
|
+
schema: {
|
|
51
|
+
oneOf: [
|
|
52
|
+
{
|
|
53
|
+
"$ref": "#/components/schemas/email_provider",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"$ref": "#/components/schemas/firebase_provider",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
responses: {
|
|
64
|
+
"200": {
|
|
65
|
+
description: "Successful operation",
|
|
66
|
+
content: {
|
|
67
|
+
"application/json": {
|
|
68
|
+
schema: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
access_token: {
|
|
72
|
+
type: "object",
|
|
73
|
+
example: {
|
|
74
|
+
id: 67,
|
|
75
|
+
email: "admin@test.com",
|
|
76
|
+
password:
|
|
77
|
+
"$argon2id$v=19$m=65536,t=3,p=4$861dgvjWHc9Lizr5YAHTTg$Nl7kRBPz4X4M5s46f286obEL4S7SrMtYPvmkUpo++kk",
|
|
78
|
+
role: "admin",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
user: {
|
|
82
|
+
type: "object",
|
|
83
|
+
example: {
|
|
84
|
+
token:
|
|
85
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NjcsImVtYWlsIjoiYWRtaW5AdGVzdC5jb20iLCJwYXNzd29yZCI6IiRhcmdvbjJpZCR2PTE5JG09NjU1MzYsdD0zLHA9NCQ4NjFkZ3ZqV0hjOUxpenI1WUFIVFRnJE5sN2tSQlB6NFg0TTVzNDZmMjg2b2JFTDRTN1NyTXRZUHZta1Vwbysra2siLCJyb2xlIjoiYWRtaW4iLCJpc0F1dGhlbnRpY2F0ZWQiOnRydWUsImlhdCI6MTc0MjQ2OTkyMiwiZXhwIjoxNzQzNzY1OTIyfQ.wpyYRLgAE5atrSS8PHyXaSGQENiw4s-KjwPKaZ_ptB8",
|
|
86
|
+
expires_in: 1743765922,
|
|
87
|
+
issued_at: 1742469922,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
"500": {
|
|
96
|
+
description: "Internal Error",
|
|
97
|
+
content: {
|
|
98
|
+
"application/json": {
|
|
99
|
+
schema: {
|
|
100
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
"/api/extensions/auth/me": {
|
|
109
|
+
get: {
|
|
110
|
+
tags: [
|
|
111
|
+
"auth",
|
|
112
|
+
],
|
|
113
|
+
summary: `Get current user`,
|
|
114
|
+
description: `This is used to get information of the logged in user`,
|
|
115
|
+
responses: {
|
|
116
|
+
"200": {
|
|
117
|
+
description: "Successful operation",
|
|
118
|
+
content: {
|
|
119
|
+
"application/json": {
|
|
120
|
+
schema: {
|
|
121
|
+
type: "object",
|
|
122
|
+
example: {
|
|
123
|
+
email: "admin@test.com",
|
|
124
|
+
role: "admin",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
"400": {
|
|
131
|
+
description: "Bad Request",
|
|
132
|
+
content: {
|
|
133
|
+
"application/json": {
|
|
134
|
+
schema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
example: {
|
|
137
|
+
"status": 400,
|
|
138
|
+
"code": "BAD_REQUEST",
|
|
139
|
+
"message": "You need to provide an access token.",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
"401": {
|
|
146
|
+
description: "Unauthorized",
|
|
147
|
+
content: {
|
|
148
|
+
"application/json": {
|
|
149
|
+
schema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
example: {
|
|
152
|
+
"status": 401,
|
|
153
|
+
"code": "UNAUTHORIZED",
|
|
154
|
+
"message":
|
|
155
|
+
"The password provided is incorrect. Please verify and try again.",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
"500": {
|
|
162
|
+
description: "Internal Error",
|
|
163
|
+
content: {
|
|
164
|
+
"application/json": {
|
|
165
|
+
schema: {
|
|
166
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
"/api/extensions/auth/refresh": {
|
|
175
|
+
post: {
|
|
176
|
+
tags: [
|
|
177
|
+
"auth",
|
|
178
|
+
],
|
|
179
|
+
summary: `Refresh Token`,
|
|
180
|
+
description: `This endpoint is used to refresh your access token`,
|
|
181
|
+
parameters: [
|
|
182
|
+
{
|
|
183
|
+
"name": "lobb_refresh_token",
|
|
184
|
+
"in": "cookie",
|
|
185
|
+
"required": true,
|
|
186
|
+
"description": "The refresh token cookie.",
|
|
187
|
+
"schema": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"example":
|
|
190
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
responses: {
|
|
195
|
+
"200": {
|
|
196
|
+
description: "Successful operation",
|
|
197
|
+
content: {
|
|
198
|
+
"application/json": {
|
|
199
|
+
schema: {
|
|
200
|
+
type: "object",
|
|
201
|
+
example: {
|
|
202
|
+
access_token: {
|
|
203
|
+
token:
|
|
204
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAxLCJlbWFpbCI6ImFkbWluQHRlc3QuY29tIiwicGFzc3dvcmQiOiIkYXJnb24yaWQkdj0xOSRtPTY1NTM2LHQ9MyxwPTQkYVEvR3ZTbk5uL21wU3ZwZVhDbWNTQSRZNkk2S0h2L1BtTGRyQUp0QnUzRnZlS0JoTGpzVXpIWWgveWh2UnlxYklRIiwicm9sZSI6ImFkbWluIiwiaXNBdXRoZW50aWNhdGVkIjpmYWxzZSwiaWF0IjoxNzQyNDgwODcyLCJleHAiOjE3NDI0ODA4NzJ9.gGo65nmYi6-88JEG-zVJ8C65yo5dNqR5ATJPZJZZu0c",
|
|
205
|
+
expires_in: 1742480872,
|
|
206
|
+
issued_at: 1742480872,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
"500": {
|
|
214
|
+
description: "Internal Error",
|
|
215
|
+
content: {
|
|
216
|
+
"application/json": {
|
|
217
|
+
schema: {
|
|
218
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
"/api/extensions/auth/logout": {
|
|
227
|
+
delete: {
|
|
228
|
+
tags: [
|
|
229
|
+
"auth",
|
|
230
|
+
],
|
|
231
|
+
summary: `Logout`,
|
|
232
|
+
description: `This endpoint is used to delete the refresh token`,
|
|
233
|
+
parameters: [
|
|
234
|
+
{
|
|
235
|
+
"name": "lobb_refresh_token",
|
|
236
|
+
"in": "cookie",
|
|
237
|
+
"required": true,
|
|
238
|
+
"description": "The refresh token cookie.",
|
|
239
|
+
"schema": {
|
|
240
|
+
"type": "string",
|
|
241
|
+
"example":
|
|
242
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U",
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
responses: {
|
|
247
|
+
"200": {
|
|
248
|
+
description: "Successful operation",
|
|
249
|
+
content: {
|
|
250
|
+
"application/json": {
|
|
251
|
+
schema: {
|
|
252
|
+
type: "object",
|
|
253
|
+
example: {
|
|
254
|
+
message: "Successfully logged out",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
"500": {
|
|
261
|
+
description: "Internal Error",
|
|
262
|
+
content: {
|
|
263
|
+
"application/json": {
|
|
264
|
+
schema: {
|
|
265
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
"/api/extensions/auth/reset_password_request": {
|
|
274
|
+
post: {
|
|
275
|
+
tags: [
|
|
276
|
+
"auth",
|
|
277
|
+
],
|
|
278
|
+
summary: `Reset password request`,
|
|
279
|
+
description: `Send a reset password request email to the user`,
|
|
280
|
+
requestBody: {
|
|
281
|
+
required: true,
|
|
282
|
+
content: {
|
|
283
|
+
"application/json": {
|
|
284
|
+
schema: {
|
|
285
|
+
type: "object",
|
|
286
|
+
example: {
|
|
287
|
+
email: "admin@test.com",
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
responses: {
|
|
294
|
+
"200": {
|
|
295
|
+
description: "Successful operation",
|
|
296
|
+
content: {
|
|
297
|
+
"application/json": {
|
|
298
|
+
schema: {
|
|
299
|
+
type: "object",
|
|
300
|
+
example: {
|
|
301
|
+
message: "Successfully logged out",
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
"500": {
|
|
308
|
+
description: "Internal Error",
|
|
309
|
+
content: {
|
|
310
|
+
"application/json": {
|
|
311
|
+
schema: {
|
|
312
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
"/api/extensions/auth/reset_password": {
|
|
321
|
+
post: {
|
|
322
|
+
tags: [
|
|
323
|
+
"auth",
|
|
324
|
+
],
|
|
325
|
+
summary: `Reset password`,
|
|
326
|
+
description: `Send a reset password request to the user's email`,
|
|
327
|
+
requestBody: {
|
|
328
|
+
required: true,
|
|
329
|
+
content: {
|
|
330
|
+
"application/json": {
|
|
331
|
+
schema: {
|
|
332
|
+
type: "object",
|
|
333
|
+
example: {
|
|
334
|
+
token: "non_valid_token",
|
|
335
|
+
new_password: "new_pass",
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
responses: {
|
|
342
|
+
"200": {
|
|
343
|
+
description: "Successful operation",
|
|
344
|
+
content: {
|
|
345
|
+
"application/json": {
|
|
346
|
+
schema: {
|
|
347
|
+
type: "object",
|
|
348
|
+
example: {
|
|
349
|
+
message: "The reset token is not valid",
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
"500": {
|
|
356
|
+
description: "Internal Error",
|
|
357
|
+
content: {
|
|
358
|
+
"application/json": {
|
|
359
|
+
schema: {
|
|
360
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
get: {
|
|
368
|
+
tags: [
|
|
369
|
+
"auth",
|
|
370
|
+
],
|
|
371
|
+
summary: `Reset password html Page`,
|
|
372
|
+
description: `Returns an html UI page`,
|
|
373
|
+
parameters: [
|
|
374
|
+
{
|
|
375
|
+
"name": "reset_token",
|
|
376
|
+
"in": "query",
|
|
377
|
+
"required": true,
|
|
378
|
+
"description": "The token thats used to reset the password.",
|
|
379
|
+
"schema": {
|
|
380
|
+
"type": "string",
|
|
381
|
+
"example":
|
|
382
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U",
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
responses: {
|
|
387
|
+
"200": {
|
|
388
|
+
description: "Successful operation",
|
|
389
|
+
content: {
|
|
390
|
+
"text/html": {
|
|
391
|
+
schema: {
|
|
392
|
+
type: "string",
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
"500": {
|
|
398
|
+
description: "Internal Error",
|
|
399
|
+
content: {
|
|
400
|
+
"application/json": {
|
|
401
|
+
schema: {
|
|
402
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
"/api/extensions/auth/change_password": {
|
|
411
|
+
post: {
|
|
412
|
+
tags: [
|
|
413
|
+
"auth",
|
|
414
|
+
],
|
|
415
|
+
summary: `Change Password`,
|
|
416
|
+
description: "This is used for the current user to change his password",
|
|
417
|
+
"parameters": [
|
|
418
|
+
{
|
|
419
|
+
"in": "header",
|
|
420
|
+
"name": "Authorization",
|
|
421
|
+
"schema": {
|
|
422
|
+
"type": "string",
|
|
423
|
+
},
|
|
424
|
+
"required": true,
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
requestBody: {
|
|
428
|
+
required: true,
|
|
429
|
+
content: {
|
|
430
|
+
"application/json": {
|
|
431
|
+
schema: {
|
|
432
|
+
type: "object",
|
|
433
|
+
example: {
|
|
434
|
+
old_password: "admin",
|
|
435
|
+
new_password: "new_pass",
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
responses: {
|
|
442
|
+
"200": {
|
|
443
|
+
description: "Successful operation",
|
|
444
|
+
content: {
|
|
445
|
+
"application/json": {
|
|
446
|
+
schema: {
|
|
447
|
+
type: "object",
|
|
448
|
+
example: {
|
|
449
|
+
message: "The password was changed successfully",
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
"500": {
|
|
456
|
+
description: "Internal Error",
|
|
457
|
+
content: {
|
|
458
|
+
"application/json": {
|
|
459
|
+
schema: {
|
|
460
|
+
$ref: `#/components/schemas/internalErrorReponse`,
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { test, expect } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const ADMIN_EMAIL = "admin@example.com";
|
|
4
|
+
const ADMIN_PASSWORD = "admin";
|
|
5
|
+
const LOGIN_URL = "/studio/extensions/auth/login_page";
|
|
6
|
+
const STUDIO_URL = "/studio";
|
|
7
|
+
|
|
8
|
+
test.describe("Login page", () => {
|
|
9
|
+
test.beforeEach(async ({ page }) => {
|
|
10
|
+
await page.goto(LOGIN_URL);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("shows the login form", async ({ page }) => {
|
|
14
|
+
await expect(page.getByText("Welcome back")).toBeVisible();
|
|
15
|
+
await expect(page.getByPlaceholder("email@example.com")).toBeVisible();
|
|
16
|
+
await expect(page.getByPlaceholder("••••••••")).toBeVisible();
|
|
17
|
+
await expect(page.getByRole("button", { name: "Sign In" })).toBeVisible();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("logs in with valid credentials and redirects to studio", async ({ page }) => {
|
|
21
|
+
await page.getByPlaceholder("email@example.com").fill(ADMIN_EMAIL);
|
|
22
|
+
await page.getByPlaceholder("••••••••").fill(ADMIN_PASSWORD);
|
|
23
|
+
await page.getByRole("button", { name: "Sign In" }).click();
|
|
24
|
+
|
|
25
|
+
await page.waitForURL(STUDIO_URL);
|
|
26
|
+
expect(page.url()).toContain(STUDIO_URL);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("shows error toast on empty form submission", async ({ page }) => {
|
|
30
|
+
await page.getByRole("button", { name: "Sign In" }).click();
|
|
31
|
+
|
|
32
|
+
await expect(page.getByText("Please complete all fields")).toBeVisible();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "commonjs"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { defineConfig, devices } = require("@playwright/test");
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
testDir: __dirname,
|
|
5
|
+
testMatch: "**/*.spec.ts",
|
|
6
|
+
fullyParallel: true,
|
|
7
|
+
retries: 0,
|
|
8
|
+
expect: { timeout: 15000 },
|
|
9
|
+
use: {
|
|
10
|
+
baseURL: "http://localhost:3000",
|
|
11
|
+
trace: "on-first-retry",
|
|
12
|
+
headless: true,
|
|
13
|
+
},
|
|
14
|
+
projects: [
|
|
15
|
+
{
|
|
16
|
+
name: "chromium",
|
|
17
|
+
use: { ...devices["Desktop Chrome"] },
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
// Automatically start the dev server before running tests
|
|
21
|
+
webServer: {
|
|
22
|
+
command: "bun run dev",
|
|
23
|
+
url: "http://localhost:3000/studio",
|
|
24
|
+
reuseExistingServer: true,
|
|
25
|
+
cwd: "../../../../", // packages/auth-ext root
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Lobb } from "@lobb-js/core";
|
|
2
|
+
import { afterAll, beforeAll, describe, it, expect } from "bun:test";
|
|
3
|
+
import { authWithExtendUsersConfig } from "../configs/auth_with_extend_users.ts";
|
|
4
|
+
|
|
5
|
+
describe("extend users collection", () => {
|
|
6
|
+
let lobb: Lobb;
|
|
7
|
+
let baseUrl: string;
|
|
8
|
+
|
|
9
|
+
beforeAll(async () => {
|
|
10
|
+
lobb = await Lobb.init(authWithExtendUsersConfig);
|
|
11
|
+
baseUrl = `http://127.0.0.1:${lobb.webServer.port}`;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
await lobb.collectionService.deleteMany({
|
|
16
|
+
collectionName: "auth_users",
|
|
17
|
+
filter: {},
|
|
18
|
+
force: true,
|
|
19
|
+
});
|
|
20
|
+
await lobb.close();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should return a result with all the additional fields that exists in the (extend_users)", async () => {
|
|
24
|
+
const response = await fetch(
|
|
25
|
+
`${baseUrl}/api/collections/auth_users`,
|
|
26
|
+
{
|
|
27
|
+
method: "POST",
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
data: {
|
|
30
|
+
email: "test@test.com",
|
|
31
|
+
password: "test",
|
|
32
|
+
role: "admin",
|
|
33
|
+
name: "test",
|
|
34
|
+
bio: "test",
|
|
35
|
+
language: "ar",
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
await response.json();
|
|
41
|
+
|
|
42
|
+
const response2 = await fetch(
|
|
43
|
+
`${baseUrl}/api/collections/auth_users?sort=id`,
|
|
44
|
+
{
|
|
45
|
+
method: "GET",
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
const result2 = await response2.json();
|
|
49
|
+
|
|
50
|
+
expect(response2.status).toEqual(200);
|
|
51
|
+
expect(
|
|
52
|
+
result2.data[1],
|
|
53
|
+
).toMatchObject({
|
|
54
|
+
role: "admin",
|
|
55
|
+
email: "test@test.com",
|
|
56
|
+
name: "test",
|
|
57
|
+
bio: "test",
|
|
58
|
+
language: "ar",
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authConfig: Config = {
|
|
5
|
+
project: {
|
|
6
|
+
name: "Lobb",
|
|
7
|
+
force_sync: true,
|
|
8
|
+
support_email: "support@lobb.com",
|
|
9
|
+
},
|
|
10
|
+
database: {
|
|
11
|
+
host: "localhost",
|
|
12
|
+
port: 5432,
|
|
13
|
+
username: "test",
|
|
14
|
+
password: "test",
|
|
15
|
+
database: "*",
|
|
16
|
+
|
|
17
|
+
},
|
|
18
|
+
web_server: {
|
|
19
|
+
host: "0.0.0.0",
|
|
20
|
+
port: 0,
|
|
21
|
+
},
|
|
22
|
+
extensions: [
|
|
23
|
+
auth({
|
|
24
|
+
admin: {
|
|
25
|
+
password: "admin",
|
|
26
|
+
email: "admin@test.com",
|
|
27
|
+
},
|
|
28
|
+
extend_users: {
|
|
29
|
+
fields: {
|
|
30
|
+
name: {
|
|
31
|
+
type: "string",
|
|
32
|
+
length: 255,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
roles: {
|
|
37
|
+
public: {
|
|
38
|
+
permissions: {
|
|
39
|
+
auth_users: {
|
|
40
|
+
create: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
collections: {
|
|
48
|
+
articles: {
|
|
49
|
+
indexes: {},
|
|
50
|
+
fields: {
|
|
51
|
+
id: {
|
|
52
|
+
type: "integer",
|
|
53
|
+
},
|
|
54
|
+
title: {
|
|
55
|
+
type: "string",
|
|
56
|
+
length: 255,
|
|
57
|
+
},
|
|
58
|
+
body: {
|
|
59
|
+
type: "text",
|
|
60
|
+
},
|
|
61
|
+
published: {
|
|
62
|
+
type: "bool",
|
|
63
|
+
},
|
|
64
|
+
number_of_likes: {
|
|
65
|
+
type: "integer",
|
|
66
|
+
},
|
|
67
|
+
user_id: {
|
|
68
|
+
type: "integer",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|