@lobb-js/lobb-ext-auth 0.1.66 → 0.2.1
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 +86 -27
- 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 +34 -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 -10
- 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,65 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authNoRolesConfig: 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
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
collections: {
|
|
40
|
+
articles: {
|
|
41
|
+
indexes: {},
|
|
42
|
+
fields: {
|
|
43
|
+
id: {
|
|
44
|
+
type: "integer",
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
type: "string",
|
|
48
|
+
length: 255,
|
|
49
|
+
},
|
|
50
|
+
body: {
|
|
51
|
+
type: "text",
|
|
52
|
+
},
|
|
53
|
+
published: {
|
|
54
|
+
type: "bool",
|
|
55
|
+
},
|
|
56
|
+
number_of_likes: {
|
|
57
|
+
type: "integer",
|
|
58
|
+
},
|
|
59
|
+
user_id: {
|
|
60
|
+
type: "integer",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authPublicFullAccessConfig: 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: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
collections: {
|
|
44
|
+
articles: {
|
|
45
|
+
indexes: {},
|
|
46
|
+
fields: {
|
|
47
|
+
id: {
|
|
48
|
+
type: "integer",
|
|
49
|
+
},
|
|
50
|
+
title: {
|
|
51
|
+
type: "string",
|
|
52
|
+
length: 255,
|
|
53
|
+
},
|
|
54
|
+
body: {
|
|
55
|
+
type: "text",
|
|
56
|
+
},
|
|
57
|
+
published: {
|
|
58
|
+
type: "bool",
|
|
59
|
+
},
|
|
60
|
+
number_of_likes: {
|
|
61
|
+
type: "integer",
|
|
62
|
+
},
|
|
63
|
+
user_id: {
|
|
64
|
+
type: "integer",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authWithDifferentAdminCredsConfig: 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: "123456",
|
|
26
|
+
email: "admin@wow.yey",
|
|
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
|
+
read: true,
|
|
41
|
+
},
|
|
42
|
+
articles: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
author: {
|
|
46
|
+
permissions: {
|
|
47
|
+
articles: {
|
|
48
|
+
create: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
collections: {
|
|
56
|
+
articles: {
|
|
57
|
+
indexes: {},
|
|
58
|
+
fields: {
|
|
59
|
+
id: {
|
|
60
|
+
type: "integer",
|
|
61
|
+
},
|
|
62
|
+
title: {
|
|
63
|
+
type: "string",
|
|
64
|
+
length: 255,
|
|
65
|
+
},
|
|
66
|
+
body: {
|
|
67
|
+
type: "text",
|
|
68
|
+
},
|
|
69
|
+
published: {
|
|
70
|
+
type: "bool",
|
|
71
|
+
},
|
|
72
|
+
number_of_likes: {
|
|
73
|
+
type: "integer",
|
|
74
|
+
},
|
|
75
|
+
user_id: {
|
|
76
|
+
type: "integer",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authWithExtendUsersConfig: 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@example.com",
|
|
27
|
+
},
|
|
28
|
+
roles: {
|
|
29
|
+
public: {
|
|
30
|
+
permissions: {
|
|
31
|
+
auth_users: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
extend_users: {
|
|
36
|
+
fields: {
|
|
37
|
+
name: {
|
|
38
|
+
type: "string",
|
|
39
|
+
length: 255,
|
|
40
|
+
},
|
|
41
|
+
bio: {
|
|
42
|
+
type: "text",
|
|
43
|
+
},
|
|
44
|
+
language: {
|
|
45
|
+
type: "string",
|
|
46
|
+
length: 255,
|
|
47
|
+
validators: {
|
|
48
|
+
enum: ["en", "ar", "tr"],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
collections: {
|
|
56
|
+
articles: {
|
|
57
|
+
indexes: {},
|
|
58
|
+
fields: {
|
|
59
|
+
id: {
|
|
60
|
+
type: "integer",
|
|
61
|
+
},
|
|
62
|
+
title: {
|
|
63
|
+
type: "string",
|
|
64
|
+
length: 255,
|
|
65
|
+
},
|
|
66
|
+
body: {
|
|
67
|
+
type: "text",
|
|
68
|
+
},
|
|
69
|
+
published: {
|
|
70
|
+
type: "bool",
|
|
71
|
+
},
|
|
72
|
+
number_of_likes: {
|
|
73
|
+
type: "integer",
|
|
74
|
+
},
|
|
75
|
+
user_id: {
|
|
76
|
+
type: "integer",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authWithRefreshTokenConfig: 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
|
+
read: true,
|
|
41
|
+
},
|
|
42
|
+
articles: {
|
|
43
|
+
create: true,
|
|
44
|
+
delete: true,
|
|
45
|
+
update: true,
|
|
46
|
+
read: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
author: {
|
|
51
|
+
permissions: {
|
|
52
|
+
articles: {
|
|
53
|
+
create: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
collections: {
|
|
61
|
+
articles: {
|
|
62
|
+
indexes: {},
|
|
63
|
+
fields: {
|
|
64
|
+
id: {
|
|
65
|
+
type: "integer",
|
|
66
|
+
},
|
|
67
|
+
title: {
|
|
68
|
+
type: "string",
|
|
69
|
+
length: 255,
|
|
70
|
+
},
|
|
71
|
+
body: {
|
|
72
|
+
type: "text",
|
|
73
|
+
},
|
|
74
|
+
published: {
|
|
75
|
+
type: "bool",
|
|
76
|
+
},
|
|
77
|
+
number_of_likes: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
},
|
|
80
|
+
user_id: {
|
|
81
|
+
type: "integer",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import { mail } from "@lobb-js/lobb-mail-ext";
|
|
3
|
+
import auth from "../../index.ts";
|
|
4
|
+
|
|
5
|
+
export const authWithShortAccessTokenOnlyConfig: Config = {
|
|
6
|
+
project: {
|
|
7
|
+
name: "Lobb",
|
|
8
|
+
force_sync: true,
|
|
9
|
+
support_email: "support@lobb.com",
|
|
10
|
+
},
|
|
11
|
+
database: {
|
|
12
|
+
host: "localhost",
|
|
13
|
+
port: 5432,
|
|
14
|
+
username: "test",
|
|
15
|
+
password: "test",
|
|
16
|
+
database: "*",
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
web_server: {
|
|
20
|
+
host: "0.0.0.0",
|
|
21
|
+
port: 0,
|
|
22
|
+
},
|
|
23
|
+
extensions: [
|
|
24
|
+
mail({
|
|
25
|
+
transporter: {
|
|
26
|
+
host: "127.0.0.1",
|
|
27
|
+
port: 2525,
|
|
28
|
+
secure: false,
|
|
29
|
+
ignoreTLS: true,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
auth({
|
|
33
|
+
admin: {
|
|
34
|
+
password: "admin",
|
|
35
|
+
email: "admin@test.com",
|
|
36
|
+
},
|
|
37
|
+
extend_users: {
|
|
38
|
+
fields: {
|
|
39
|
+
name: {
|
|
40
|
+
type: "string",
|
|
41
|
+
length: 255,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
roles: {
|
|
46
|
+
public: {
|
|
47
|
+
permissions: {
|
|
48
|
+
auth_users: {
|
|
49
|
+
read: true,
|
|
50
|
+
},
|
|
51
|
+
articles: {
|
|
52
|
+
create: true,
|
|
53
|
+
delete: true,
|
|
54
|
+
update: true,
|
|
55
|
+
read: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
author: {
|
|
60
|
+
permissions: {
|
|
61
|
+
articles: {
|
|
62
|
+
create: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
collections: {
|
|
70
|
+
articles: {
|
|
71
|
+
indexes: {},
|
|
72
|
+
fields: {
|
|
73
|
+
id: {
|
|
74
|
+
type: "integer",
|
|
75
|
+
},
|
|
76
|
+
title: {
|
|
77
|
+
type: "string",
|
|
78
|
+
length: 255,
|
|
79
|
+
},
|
|
80
|
+
body: {
|
|
81
|
+
type: "text",
|
|
82
|
+
},
|
|
83
|
+
published: {
|
|
84
|
+
type: "bool",
|
|
85
|
+
},
|
|
86
|
+
number_of_likes: {
|
|
87
|
+
type: "integer",
|
|
88
|
+
},
|
|
89
|
+
user_id: {
|
|
90
|
+
type: "integer",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const authWithShortTimeRefreshTokenConfig: 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
|
+
read: true,
|
|
41
|
+
},
|
|
42
|
+
articles: {
|
|
43
|
+
create: true,
|
|
44
|
+
delete: true,
|
|
45
|
+
update: true,
|
|
46
|
+
read: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
author: {
|
|
51
|
+
permissions: {
|
|
52
|
+
articles: {
|
|
53
|
+
create: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
collections: {
|
|
61
|
+
articles: {
|
|
62
|
+
indexes: {},
|
|
63
|
+
fields: {
|
|
64
|
+
id: {
|
|
65
|
+
type: "integer",
|
|
66
|
+
},
|
|
67
|
+
title: {
|
|
68
|
+
type: "string",
|
|
69
|
+
length: 255,
|
|
70
|
+
},
|
|
71
|
+
body: {
|
|
72
|
+
type: "text",
|
|
73
|
+
},
|
|
74
|
+
published: {
|
|
75
|
+
type: "bool",
|
|
76
|
+
},
|
|
77
|
+
number_of_likes: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
},
|
|
80
|
+
user_id: {
|
|
81
|
+
type: "integer",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Config } from "@lobb-js/core";
|
|
2
|
+
import auth from "../../index.ts";
|
|
3
|
+
|
|
4
|
+
export const socialBlogConfig: 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: {
|
|
41
|
+
payloadGuard: ({ payload }) => {
|
|
42
|
+
if (payload.role === "author") {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
read: {
|
|
48
|
+
filter: {
|
|
49
|
+
role: "author",
|
|
50
|
+
},
|
|
51
|
+
fields: {
|
|
52
|
+
email: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
articles: {
|
|
57
|
+
read: {
|
|
58
|
+
filter: {
|
|
59
|
+
status: "public",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
author: {
|
|
66
|
+
permissions: {
|
|
67
|
+
auth_users: {
|
|
68
|
+
read: {
|
|
69
|
+
filter: {
|
|
70
|
+
role: "author",
|
|
71
|
+
},
|
|
72
|
+
fields: {
|
|
73
|
+
email: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
articles: {
|
|
78
|
+
create: {
|
|
79
|
+
fields: {
|
|
80
|
+
title: true,
|
|
81
|
+
body: true,
|
|
82
|
+
},
|
|
83
|
+
mutate: {
|
|
84
|
+
author_id: ({ value, user }) => {
|
|
85
|
+
return user ? user.id : value;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
read: {
|
|
90
|
+
filter: {
|
|
91
|
+
$or: [
|
|
92
|
+
{
|
|
93
|
+
status: "public",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
author_id: ({ user }) => {
|
|
97
|
+
return user ? user.id : null;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
],
|
|
109
|
+
collections: {
|
|
110
|
+
articles: {
|
|
111
|
+
indexes: {},
|
|
112
|
+
fields: {
|
|
113
|
+
id: {
|
|
114
|
+
type: "integer",
|
|
115
|
+
},
|
|
116
|
+
image: {
|
|
117
|
+
type: "string",
|
|
118
|
+
length: 255,
|
|
119
|
+
},
|
|
120
|
+
title: {
|
|
121
|
+
type: "string",
|
|
122
|
+
length: 255,
|
|
123
|
+
validators: {
|
|
124
|
+
required: true,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
description: {
|
|
128
|
+
type: "string",
|
|
129
|
+
length: 255,
|
|
130
|
+
},
|
|
131
|
+
body: {
|
|
132
|
+
type: "text",
|
|
133
|
+
validators: {
|
|
134
|
+
required: true,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
status: {
|
|
138
|
+
type: "string",
|
|
139
|
+
length: 255,
|
|
140
|
+
pre_processors: {
|
|
141
|
+
default: "private",
|
|
142
|
+
},
|
|
143
|
+
validators: {
|
|
144
|
+
enum: ["public", "private"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
author_id: {
|
|
148
|
+
type: "integer",
|
|
149
|
+
validators: {
|
|
150
|
+
required: true,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|