@nocobase/plugin-auth 0.13.0-alpha.4 → 0.13.0-alpha.6
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/dist/client/index.js +2 -744
- package/dist/index.js +36 -18
- package/dist/locale/zh-CN.js +22 -4
- package/dist/node_modules/cron/lib/cron.js +1 -1
- package/dist/node_modules/cron/package.json +1 -1
- package/dist/preset.js +32 -9
- package/dist/server/actions/auth.js +22 -4
- package/dist/server/actions/authenticators.js +25 -8
- package/dist/server/basic-auth.js +49 -22
- package/dist/server/collections/authenticators.js +22 -4
- package/dist/server/collections/token-blacklist.js +22 -4
- package/dist/server/collections/users-authenticators.js +22 -4
- package/dist/server/index.js +37 -19
- package/dist/server/locale/en-US.js +22 -4
- package/dist/server/locale/fr-FR.js +22 -4
- package/dist/server/locale/index.js +41 -24
- package/dist/server/locale/ja-JP.js +22 -4
- package/dist/server/locale/pt-BR.js +22 -4
- package/dist/server/locale/zh-CN.js +22 -4
- package/dist/server/migrations/20230506152253-basic-authenticator.js +27 -10
- package/dist/server/migrations/20230607174500-update-basic.js +26 -9
- package/dist/server/model/authenticator.js +28 -7
- package/dist/server/plugin.js +60 -36
- package/dist/server/token-blacklist.js +26 -4
- package/dist/swagger/index.js +22 -4
- package/package.json +2 -2
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var basic_authenticator_exports = {};
|
|
19
|
+
__export(basic_authenticator_exports, {
|
|
20
|
+
default: () => AddBasicAuthMigration
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(basic_authenticator_exports);
|
|
23
|
+
var import_server = require("@nocobase/server");
|
|
24
|
+
var import_preset = require("../../preset");
|
|
25
|
+
class AddBasicAuthMigration extends import_server.Migration {
|
|
7
26
|
async up() {
|
|
8
27
|
const repo = this.context.db.getRepository("authenticators");
|
|
9
28
|
const existed = await repo.count();
|
|
@@ -12,8 +31,8 @@ class AddBasicAuthMigration extends server.Migration {
|
|
|
12
31
|
}
|
|
13
32
|
await repo.create({
|
|
14
33
|
values: {
|
|
15
|
-
name:
|
|
16
|
-
authType:
|
|
34
|
+
name: import_preset.presetAuthenticator,
|
|
35
|
+
authType: import_preset.presetAuthType,
|
|
17
36
|
description: "Sign in with username/email.",
|
|
18
37
|
enabled: true
|
|
19
38
|
}
|
|
@@ -22,5 +41,3 @@ class AddBasicAuthMigration extends server.Migration {
|
|
|
22
41
|
async down() {
|
|
23
42
|
}
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
module.exports = AddBasicAuthMigration;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var update_basic_exports = {};
|
|
19
|
+
__export(update_basic_exports, {
|
|
20
|
+
default: () => UpdateBasicAuthMigration
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(update_basic_exports);
|
|
23
|
+
var import_server = require("@nocobase/server");
|
|
24
|
+
var import_preset = require("../../preset");
|
|
25
|
+
class UpdateBasicAuthMigration extends import_server.Migration {
|
|
7
26
|
async up() {
|
|
8
27
|
const SystemSetting = this.context.db.getRepository("systemSettings");
|
|
9
28
|
const setting = await SystemSetting.findOne();
|
|
@@ -18,12 +37,10 @@ class UpdateBasicAuthMigration extends server.Migration {
|
|
|
18
37
|
}
|
|
19
38
|
},
|
|
20
39
|
filter: {
|
|
21
|
-
name:
|
|
40
|
+
name: import_preset.presetAuthenticator
|
|
22
41
|
}
|
|
23
42
|
});
|
|
24
43
|
}
|
|
25
44
|
async down() {
|
|
26
45
|
}
|
|
27
46
|
}
|
|
28
|
-
|
|
29
|
-
module.exports = UpdateBasicAuthMigration;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var authenticator_exports = {};
|
|
19
|
+
__export(authenticator_exports, {
|
|
20
|
+
AuthModel: () => AuthModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(authenticator_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
class AuthModel extends import_database.Model {
|
|
6
25
|
async findUser(uuid) {
|
|
7
26
|
let user;
|
|
8
27
|
const users = await this.getUsers({
|
|
@@ -44,5 +63,7 @@ class AuthModel extends database.Model {
|
|
|
44
63
|
return await this.newUser(uuid, userValues);
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
|
-
|
|
48
|
-
exports
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
AuthModel
|
|
69
|
+
});
|
package/dist/server/plugin.js
CHANGED
|
@@ -1,37 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var plugin_exports = {};
|
|
29
|
+
__export(plugin_exports, {
|
|
30
|
+
AuthPlugin: () => AuthPlugin,
|
|
31
|
+
default: () => plugin_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
var import_server = require("@nocobase/server");
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
var import_preset = require("../preset");
|
|
37
|
+
var import_auth = __toESM(require("./actions/auth"));
|
|
38
|
+
var import_authenticators = __toESM(require("./actions/authenticators"));
|
|
39
|
+
var import_basic_auth = require("./basic-auth");
|
|
40
|
+
var import_locale = require("./locale");
|
|
41
|
+
var import_authenticator = require("./model/authenticator");
|
|
42
|
+
var import_token_blacklist = require("./token-blacklist");
|
|
43
|
+
class AuthPlugin extends import_server.Plugin {
|
|
21
44
|
afterAdd() {
|
|
22
45
|
}
|
|
23
46
|
async beforeLoad() {
|
|
24
|
-
this.app.i18n.addResources("zh-CN",
|
|
25
|
-
this.app.i18n.addResources("en-US",
|
|
26
|
-
this.app.db.registerModels({ AuthModel:
|
|
47
|
+
this.app.i18n.addResources("zh-CN", import_preset.namespace, import_locale.zhCN);
|
|
48
|
+
this.app.i18n.addResources("en-US", import_preset.namespace, import_locale.enUS);
|
|
49
|
+
this.app.db.registerModels({ AuthModel: import_authenticator.AuthModel });
|
|
27
50
|
}
|
|
28
51
|
async load() {
|
|
29
52
|
await this.db.import({
|
|
30
|
-
directory:
|
|
53
|
+
directory: (0, import_path.resolve)(__dirname, "collections")
|
|
31
54
|
});
|
|
32
55
|
this.db.addMigrations({
|
|
33
56
|
namespace: "auth",
|
|
34
|
-
directory:
|
|
57
|
+
directory: (0, import_path.resolve)(__dirname, "migrations"),
|
|
35
58
|
context: {
|
|
36
59
|
plugin: this
|
|
37
60
|
}
|
|
@@ -45,16 +68,16 @@ class AuthPlugin extends server.Plugin {
|
|
|
45
68
|
}
|
|
46
69
|
});
|
|
47
70
|
if (!this.app.authManager.jwt.blacklist) {
|
|
48
|
-
this.app.authManager.setTokenBlacklistService(new
|
|
71
|
+
this.app.authManager.setTokenBlacklistService(new import_token_blacklist.TokenBlacklistService(this));
|
|
49
72
|
}
|
|
50
|
-
this.app.authManager.registerTypes(
|
|
51
|
-
auth:
|
|
73
|
+
this.app.authManager.registerTypes(import_preset.presetAuthType, {
|
|
74
|
+
auth: import_basic_auth.BasicAuth,
|
|
52
75
|
title: "Password"
|
|
53
76
|
});
|
|
54
|
-
Object.entries(
|
|
77
|
+
Object.entries(import_auth.default).forEach(
|
|
55
78
|
([action, handler]) => this.app.resourcer.registerAction(`auth:${action}`, handler)
|
|
56
79
|
);
|
|
57
|
-
Object.entries(
|
|
80
|
+
Object.entries(import_authenticators.default).forEach(
|
|
58
81
|
([action, handler]) => this.app.resourcer.registerAction(`authenticators:${action}`, handler)
|
|
59
82
|
);
|
|
60
83
|
["check", "signIn", "signUp"].forEach((action) => this.app.acl.allow("auth", action));
|
|
@@ -67,14 +90,14 @@ class AuthPlugin extends server.Plugin {
|
|
|
67
90
|
}
|
|
68
91
|
async install(options) {
|
|
69
92
|
const repository = this.db.getRepository("authenticators");
|
|
70
|
-
const exist = await repository.findOne({ filter: { name:
|
|
93
|
+
const exist = await repository.findOne({ filter: { name: import_preset.presetAuthenticator } });
|
|
71
94
|
if (exist) {
|
|
72
95
|
return;
|
|
73
96
|
}
|
|
74
97
|
await repository.create({
|
|
75
98
|
values: {
|
|
76
|
-
name:
|
|
77
|
-
authType:
|
|
99
|
+
name: import_preset.presetAuthenticator,
|
|
100
|
+
authType: import_preset.presetAuthType,
|
|
78
101
|
description: "Sign in with username/email.",
|
|
79
102
|
enabled: true,
|
|
80
103
|
options: {
|
|
@@ -89,6 +112,7 @@ class AuthPlugin extends server.Plugin {
|
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
114
|
var plugin_default = AuthPlugin;
|
|
92
|
-
|
|
93
|
-
exports
|
|
94
|
-
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
AuthPlugin
|
|
118
|
+
});
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var token_blacklist_exports = {};
|
|
19
|
+
__export(token_blacklist_exports, {
|
|
20
|
+
TokenBlacklistService: () => TokenBlacklistService
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(token_blacklist_exports);
|
|
3
23
|
class TokenBlacklistService {
|
|
4
24
|
constructor(plugin) {
|
|
5
25
|
this.plugin = plugin;
|
|
@@ -36,5 +56,7 @@ class TokenBlacklistService {
|
|
|
36
56
|
});
|
|
37
57
|
}
|
|
38
58
|
}
|
|
39
|
-
|
|
40
|
-
exports
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
TokenBlacklistService
|
|
62
|
+
});
|
package/dist/swagger/index.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var swagger_exports = {};
|
|
19
|
+
__export(swagger_exports, {
|
|
20
|
+
default: () => swagger_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
3
23
|
var swagger_default = {
|
|
4
24
|
info: {
|
|
5
25
|
title: "NocoBase API - Auth plugin"
|
|
@@ -713,5 +733,3 @@ var swagger_default = {
|
|
|
713
733
|
}
|
|
714
734
|
}
|
|
715
735
|
};
|
|
716
|
-
|
|
717
|
-
module.exports = swagger_default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "0.13.0-alpha.
|
|
3
|
+
"version": "0.13.0-alpha.6",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@ant-design/icons": "5.x",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"displayName.zh-CN": "用户认证",
|
|
25
25
|
"description": "Basic authentication and authenticator management",
|
|
26
26
|
"description.zh-CN": "提供基础认证功能和扩展认证器管理功能",
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "49ef71c8bdaab986f47c8a84bcf15e2123ba9b59"
|
|
28
28
|
}
|