@nocobase/plugin-auth 0.11.1-alpha.5 → 0.12.0-alpha.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/client.d.ts +2 -2
- package/client.js +1 -1
- package/dist/client/index.js +729 -0
- package/dist/index.js +20 -0
- package/dist/locale/zh-CN.js +20 -0
- package/dist/node_modules/cron/LICENSE +8 -0
- package/dist/node_modules/cron/lib/cron.js +1 -0
- package/dist/node_modules/cron/lib/job.js +215 -0
- package/dist/node_modules/cron/lib/time.js +817 -0
- package/dist/node_modules/cron/package.json +1 -0
- package/{lib → dist}/preset.d.ts +1 -1
- package/dist/preset.js +11 -0
- package/dist/server/actions/auth.js +22 -0
- package/dist/server/actions/authenticators.js +83 -0
- package/{src/server/basic-auth.ts → dist/server/basic-auth.js} +41 -42
- package/dist/server/collections/authenticators.js +97 -0
- package/dist/server/collections/token-blacklist.js +21 -0
- package/dist/server/collections/users-authenticators.js +71 -0
- package/dist/server/index.js +21 -0
- package/dist/server/locale/en-US.js +12 -0
- package/dist/server/locale/fr-FR.js +12 -0
- package/dist/server/locale/index.js +26 -0
- package/dist/server/locale/ja-JP.js +8 -0
- package/dist/server/locale/pt-BR.js +12 -0
- package/dist/server/locale/zh-CN.js +13 -0
- package/dist/server/migrations/20230506152253-basic-authenticator.js +26 -0
- package/dist/server/migrations/20230607174500-update-basic.js +29 -0
- package/{src/server/model/authenticator.ts → dist/server/model/authenticator.js} +19 -19
- package/dist/server/plugin.js +93 -0
- package/dist/server/token-blacklist.js +62 -0
- package/package.json +17 -28
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/lib/client/AuthProvider.js +0 -56
- package/lib/client/basic/Options.js +0 -51
- package/lib/client/basic/SigninPage.js +0 -100
- package/lib/client/basic/SignupPage.js +0 -131
- package/lib/client/index.js +0 -27
- package/lib/client/locale/index.js +0 -19
- package/lib/client/settings/Authenticator.js +0 -159
- package/lib/client/settings/Options.js +0 -56
- package/lib/client/settings/authType.js +0 -27
- package/lib/client/settings/schemas/authenticators.js +0 -438
- package/lib/index.js +0 -20
- package/lib/locale/zh-CN.js +0 -23
- package/lib/preset.js +0 -12
- package/lib/server/actions/auth.js +0 -51
- package/lib/server/actions/authenticators.js +0 -131
- package/lib/server/basic-auth.js +0 -183
- package/lib/server/collections/authenticators.js +0 -94
- package/lib/server/collections/token-blacklist.js +0 -21
- package/lib/server/collections/users-authenticators.js +0 -75
- package/lib/server/index.js +0 -20
- package/lib/server/locale/en-US.js +0 -15
- package/lib/server/locale/fr-FR.js +0 -15
- package/lib/server/locale/index.js +0 -27
- package/lib/server/locale/ja-JP.js +0 -11
- package/lib/server/locale/pt-BR.js +0 -15
- package/lib/server/locale/zh-CN.js +0 -16
- package/lib/server/migrations/20230506152253-basic-authenticator.js +0 -40
- package/lib/server/migrations/20230607174500-update-basic.js +0 -43
- package/lib/server/model/authenticator.js +0 -72
- package/lib/server/plugin.js +0 -129
- package/lib/server/token-blacklist.js +0 -82
- package/src/client/AuthProvider.tsx +0 -41
- package/src/client/basic/Options.tsx +0 -31
- package/src/client/basic/SigninPage.tsx +0 -65
- package/src/client/basic/SignupPage.tsx +0 -91
- package/src/client/index.tsx +0 -10
- package/src/client/locale/index.ts +0 -7
- package/src/client/settings/Authenticator.tsx +0 -95
- package/src/client/settings/Options.tsx +0 -34
- package/src/client/settings/authType.ts +0 -18
- package/src/client/settings/schemas/authenticators.ts +0 -402
- package/src/index.ts +0 -1
- package/src/locale/zh-CN.ts +0 -17
- package/src/preset.ts +0 -4
- package/src/server/__tests__/actions.test.ts +0 -142
- package/src/server/__tests__/token-blacklist.test.ts +0 -73
- package/src/server/actions/auth.ts +0 -20
- package/src/server/actions/authenticators.ts +0 -85
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/authenticators.ts +0 -98
- package/src/server/collections/token-blacklist.ts +0 -19
- package/src/server/collections/users-authenticators.ts +0 -73
- package/src/server/index.ts +0 -2
- package/src/server/locale/en-US.ts +0 -10
- package/src/server/locale/fr-FR.ts +0 -10
- package/src/server/locale/index.ts +0 -3
- package/src/server/locale/ja-JP.ts +0 -4
- package/src/server/locale/pt-BR.ts +0 -10
- package/src/server/locale/zh-CN.ts +0 -9
- package/src/server/migrations/20230506152253-basic-authenticator.ts +0 -22
- package/src/server/migrations/20230607174500-update-basic.ts +0 -25
- package/src/server/plugin.ts +0 -92
- package/src/server/token-blacklist.ts +0 -66
- /package/{lib → dist}/client/AuthProvider.d.ts +0 -0
- /package/{lib → dist}/client/basic/Options.d.ts +0 -0
- /package/{lib → dist}/client/basic/SigninPage.d.ts +0 -0
- /package/{lib → dist}/client/basic/SignupPage.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/settings/Authenticator.d.ts +0 -0
- /package/{lib → dist}/client/settings/Options.d.ts +0 -0
- /package/{lib → dist}/client/settings/authType.d.ts +0 -0
- /package/{lib → dist}/client/settings/schemas/authenticators.d.ts +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/actions/auth.d.ts +0 -0
- /package/{lib → dist}/server/actions/authenticators.d.ts +0 -0
- /package/{lib → dist}/server/basic-auth.d.ts +0 -0
- /package/{lib → dist}/server/collections/authenticators.d.ts +0 -0
- /package/{lib → dist}/server/collections/token-blacklist.d.ts +0 -0
- /package/{lib → dist}/server/collections/users-authenticators.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/server/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/server/locale/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/ja-JP.d.ts +0 -0
- /package/{lib → dist}/server/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/server/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230506152253-basic-authenticator.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230607174500-update-basic.d.ts +0 -0
- /package/{lib → dist}/server/model/authenticator.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
- /package/{lib → dist}/server/token-blacklist.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"cron","description":"Cron jobs for your node","version":"2.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage"},"dependencies":{"luxon":"^3.2.1"},"devDependencies":{"chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","jest":"~29.5.x","prettier":"~2.8.x","sinon":"^15.0.x"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2023-08-01T18:36:28.439Z"}
|
package/{lib → dist}/preset.d.ts
RENAMED
package/dist/preset.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var package_json = require('../package.json');
|
|
4
|
+
|
|
5
|
+
const presetAuthType = "Email/Password";
|
|
6
|
+
const presetAuthenticator = "basic";
|
|
7
|
+
const namespace = package_json.name;
|
|
8
|
+
|
|
9
|
+
exports.namespace = namespace;
|
|
10
|
+
exports.presetAuthType = presetAuthType;
|
|
11
|
+
exports.presetAuthenticator = presetAuthenticator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var auth_default = {
|
|
4
|
+
lostPassword: async (ctx, next) => {
|
|
5
|
+
ctx.body = await ctx.auth.lostPassword();
|
|
6
|
+
await next();
|
|
7
|
+
},
|
|
8
|
+
resetPassword: async (ctx, next) => {
|
|
9
|
+
ctx.body = await ctx.auth.resetPassword();
|
|
10
|
+
await next();
|
|
11
|
+
},
|
|
12
|
+
getUserByResetToken: async (ctx, next) => {
|
|
13
|
+
ctx.body = await ctx.auth.getUserByResetToken();
|
|
14
|
+
await next();
|
|
15
|
+
},
|
|
16
|
+
changePassword: async (ctx, next) => {
|
|
17
|
+
ctx.body = await ctx.auth.changePassword();
|
|
18
|
+
await next();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = auth_default;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var preset = require('../../preset');
|
|
4
|
+
|
|
5
|
+
async function checkCount(repository, id) {
|
|
6
|
+
const count = await repository.count({
|
|
7
|
+
filter: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
id: {
|
|
10
|
+
$ne: id
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (count <= 0) {
|
|
15
|
+
throw new Error("Please keep and enable at least one authenticator");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var authenticators_default = {
|
|
19
|
+
listTypes: async (ctx, next) => {
|
|
20
|
+
ctx.body = ctx.app.authManager.listTypes();
|
|
21
|
+
await next();
|
|
22
|
+
},
|
|
23
|
+
publicList: async (ctx, next) => {
|
|
24
|
+
const repo = ctx.db.getRepository("authenticators");
|
|
25
|
+
const authenticators = await repo.find({
|
|
26
|
+
fields: ["name", "authType", "title", "options", "sort"],
|
|
27
|
+
filter: {
|
|
28
|
+
enabled: true
|
|
29
|
+
},
|
|
30
|
+
sort: "sort"
|
|
31
|
+
});
|
|
32
|
+
ctx.body = authenticators.map((authenticator) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return {
|
|
35
|
+
name: authenticator.name,
|
|
36
|
+
authType: authenticator.authType,
|
|
37
|
+
title: authenticator.title,
|
|
38
|
+
options: ((_a = authenticator.options) == null ? void 0 : _a.public) || {}
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
await next();
|
|
42
|
+
},
|
|
43
|
+
destroy: async (ctx, next) => {
|
|
44
|
+
const repository = ctx.db.getRepository("authenticators");
|
|
45
|
+
const { filterByTk, filter } = ctx.action.params;
|
|
46
|
+
try {
|
|
47
|
+
await checkCount(repository, filterByTk);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
ctx.throw(400, ctx.t(err.message, { ns: preset.namespace }));
|
|
50
|
+
}
|
|
51
|
+
const instance = await repository.destroy({
|
|
52
|
+
filter,
|
|
53
|
+
filterByTk,
|
|
54
|
+
context: ctx
|
|
55
|
+
});
|
|
56
|
+
ctx.body = instance;
|
|
57
|
+
await next();
|
|
58
|
+
},
|
|
59
|
+
update: async (ctx, next) => {
|
|
60
|
+
const repository = ctx.db.getRepository("authenticators");
|
|
61
|
+
const { forceUpdate, filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } = ctx.action.params;
|
|
62
|
+
if (!values.enabled) {
|
|
63
|
+
try {
|
|
64
|
+
await checkCount(repository, values.id);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
ctx.throw(400, ctx.t(err.message, { ns: preset.namespace }));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
ctx.body = await repository.update({
|
|
70
|
+
filterByTk,
|
|
71
|
+
values,
|
|
72
|
+
whitelist,
|
|
73
|
+
blacklist,
|
|
74
|
+
filter,
|
|
75
|
+
updateAssociationValues,
|
|
76
|
+
context: ctx,
|
|
77
|
+
forceUpdate
|
|
78
|
+
});
|
|
79
|
+
await next();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
module.exports = authenticators_default;
|
|
@@ -1,82 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
import { PasswordField } from '@nocobase/database';
|
|
3
|
-
import crypto from 'crypto';
|
|
4
|
-
import { namespace } from '../preset';
|
|
1
|
+
'use strict';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var auth = require('@nocobase/auth');
|
|
4
|
+
var crypto = require('crypto');
|
|
5
|
+
var preset = require('../preset');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
10
|
+
|
|
11
|
+
class BasicAuth extends auth.BaseAuth {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
const userCollection = config.ctx.db.getCollection("users");
|
|
9
14
|
super({ ...config, userCollection });
|
|
10
15
|
}
|
|
11
|
-
|
|
12
16
|
async validate() {
|
|
13
17
|
const ctx = this.ctx;
|
|
14
|
-
const { uniqueField =
|
|
15
|
-
|
|
18
|
+
const { uniqueField = "email", values } = ctx.action.params;
|
|
16
19
|
if (!values[uniqueField]) {
|
|
17
|
-
ctx.throw(400, ctx.t(
|
|
20
|
+
ctx.throw(400, ctx.t("Please fill in your email address", { ns: preset.namespace }));
|
|
18
21
|
}
|
|
19
22
|
const user = await this.userRepository.findOne({
|
|
20
23
|
where: {
|
|
21
|
-
[uniqueField]: values[uniqueField]
|
|
22
|
-
}
|
|
24
|
+
[uniqueField]: values[uniqueField]
|
|
25
|
+
}
|
|
23
26
|
});
|
|
24
|
-
|
|
25
27
|
if (!user) {
|
|
26
|
-
ctx.throw(401, ctx.t(
|
|
28
|
+
ctx.throw(401, ctx.t("The email is incorrect, please re-enter", { ns: preset.namespace }));
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
const field = this.userCollection.getField<PasswordField>('password');
|
|
30
|
+
const field = this.userCollection.getField("password");
|
|
30
31
|
const valid = await field.verify(values.password, user.password);
|
|
31
32
|
if (!valid) {
|
|
32
|
-
ctx.throw(401, ctx.t(
|
|
33
|
+
ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: preset.namespace }));
|
|
33
34
|
}
|
|
34
35
|
return user;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
37
|
async signUp() {
|
|
38
|
+
var _a;
|
|
38
39
|
const ctx = this.ctx;
|
|
39
|
-
const options = this.authenticator.options
|
|
40
|
+
const options = ((_a = this.authenticator.options) == null ? void 0 : _a.public) || {};
|
|
40
41
|
if (!options.allowSignUp) {
|
|
41
|
-
ctx.throw(403, ctx.t(
|
|
42
|
+
ctx.throw(403, ctx.t("Not allowed to sign up", { ns: preset.namespace }));
|
|
42
43
|
}
|
|
43
|
-
const User = ctx.db.getRepository(
|
|
44
|
+
const User = ctx.db.getRepository("users");
|
|
44
45
|
const { values } = ctx.action.params;
|
|
45
46
|
const user = await User.create({ values });
|
|
46
47
|
return user;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
49
|
async lostPassword() {
|
|
50
50
|
const ctx = this.ctx;
|
|
51
51
|
const {
|
|
52
|
-
values: { email }
|
|
52
|
+
values: { email }
|
|
53
53
|
} = ctx.action.params;
|
|
54
54
|
if (!email) {
|
|
55
|
-
ctx.throw(400, ctx.t(
|
|
55
|
+
ctx.throw(400, ctx.t("Please fill in your email address", { ns: preset.namespace }));
|
|
56
56
|
}
|
|
57
57
|
const user = await this.userRepository.findOne({
|
|
58
58
|
where: {
|
|
59
|
-
email
|
|
60
|
-
}
|
|
59
|
+
email
|
|
60
|
+
}
|
|
61
61
|
});
|
|
62
62
|
if (!user) {
|
|
63
|
-
ctx.throw(401, ctx.t(
|
|
63
|
+
ctx.throw(401, ctx.t("The email is incorrect, please re-enter", { ns: preset.namespace }));
|
|
64
64
|
}
|
|
65
|
-
user.resetToken =
|
|
65
|
+
user.resetToken = crypto__default.default.randomBytes(20).toString("hex");
|
|
66
66
|
await user.save();
|
|
67
67
|
return user;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
69
|
async resetPassword() {
|
|
71
70
|
const ctx = this.ctx;
|
|
72
71
|
const {
|
|
73
|
-
values: { email, password, resetToken }
|
|
72
|
+
values: { email, password, resetToken }
|
|
74
73
|
} = ctx.action.params;
|
|
75
74
|
const user = await this.userRepository.findOne({
|
|
76
75
|
where: {
|
|
77
76
|
email,
|
|
78
|
-
resetToken
|
|
79
|
-
}
|
|
77
|
+
resetToken
|
|
78
|
+
}
|
|
80
79
|
});
|
|
81
80
|
if (!user) {
|
|
82
81
|
ctx.throw(404);
|
|
@@ -87,25 +86,23 @@ export class BasicAuth extends BaseAuth {
|
|
|
87
86
|
await user.save();
|
|
88
87
|
return user;
|
|
89
88
|
}
|
|
90
|
-
|
|
91
89
|
async getUserByResetToken() {
|
|
92
90
|
const ctx = this.ctx;
|
|
93
91
|
const { token } = ctx.action.params;
|
|
94
92
|
const user = await this.userRepository.findOne({
|
|
95
93
|
where: {
|
|
96
|
-
resetToken: token
|
|
97
|
-
}
|
|
94
|
+
resetToken: token
|
|
95
|
+
}
|
|
98
96
|
});
|
|
99
97
|
if (!user) {
|
|
100
98
|
ctx.throw(401);
|
|
101
99
|
}
|
|
102
100
|
return user;
|
|
103
101
|
}
|
|
104
|
-
|
|
105
102
|
async changePassword() {
|
|
106
103
|
const ctx = this.ctx;
|
|
107
104
|
const {
|
|
108
|
-
values: { oldPassword, newPassword }
|
|
105
|
+
values: { oldPassword, newPassword }
|
|
109
106
|
} = ctx.action.params;
|
|
110
107
|
const currentUser = ctx.auth.user;
|
|
111
108
|
if (!currentUser) {
|
|
@@ -113,16 +110,18 @@ export class BasicAuth extends BaseAuth {
|
|
|
113
110
|
}
|
|
114
111
|
const user = await this.userRepository.findOne({
|
|
115
112
|
where: {
|
|
116
|
-
email: currentUser.email
|
|
117
|
-
}
|
|
113
|
+
email: currentUser.email
|
|
114
|
+
}
|
|
118
115
|
});
|
|
119
|
-
const pwd = this.userCollection.getField
|
|
116
|
+
const pwd = this.userCollection.getField("password");
|
|
120
117
|
const isValid = await pwd.verify(oldPassword, user.password);
|
|
121
118
|
if (!isValid) {
|
|
122
|
-
ctx.throw(401, ctx.t(
|
|
119
|
+
ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: preset.namespace }));
|
|
123
120
|
}
|
|
124
121
|
user.password = newPassword;
|
|
125
122
|
await user.save();
|
|
126
123
|
return currentUser;
|
|
127
124
|
}
|
|
128
125
|
}
|
|
126
|
+
|
|
127
|
+
exports.BasicAuth = BasicAuth;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var authenticators_default = {
|
|
4
|
+
namespace: "auth.auth",
|
|
5
|
+
duplicator: "optional",
|
|
6
|
+
name: "authenticators",
|
|
7
|
+
sortable: true,
|
|
8
|
+
title: '{{t("Authenticators")}}',
|
|
9
|
+
model: "AuthModel",
|
|
10
|
+
createdBy: true,
|
|
11
|
+
updatedBy: true,
|
|
12
|
+
logging: true,
|
|
13
|
+
fields: [
|
|
14
|
+
{
|
|
15
|
+
name: "id",
|
|
16
|
+
type: "bigInt",
|
|
17
|
+
autoIncrement: true,
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
interface: "id"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
interface: "input",
|
|
24
|
+
type: "string",
|
|
25
|
+
name: "name",
|
|
26
|
+
allowNull: false,
|
|
27
|
+
unique: true,
|
|
28
|
+
uiSchema: {
|
|
29
|
+
type: "string",
|
|
30
|
+
title: '{{t("Name")}}',
|
|
31
|
+
"x-component": "Input",
|
|
32
|
+
required: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
interface: "input",
|
|
37
|
+
type: "string",
|
|
38
|
+
name: "authType",
|
|
39
|
+
allowNull: false,
|
|
40
|
+
uiSchema: {
|
|
41
|
+
type: "string",
|
|
42
|
+
title: '{{t("Auth Type")}}',
|
|
43
|
+
"x-component": "Input",
|
|
44
|
+
required: true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
interface: "input",
|
|
49
|
+
type: "string",
|
|
50
|
+
name: "title",
|
|
51
|
+
uiSchema: {
|
|
52
|
+
type: "string",
|
|
53
|
+
title: '{{t("Title")}}',
|
|
54
|
+
"x-component": "Input"
|
|
55
|
+
},
|
|
56
|
+
translation: true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
interface: "textarea",
|
|
60
|
+
type: "string",
|
|
61
|
+
name: "description",
|
|
62
|
+
allowNull: false,
|
|
63
|
+
defaultValue: "",
|
|
64
|
+
uiSchema: {
|
|
65
|
+
type: "string",
|
|
66
|
+
title: '{{t("Description")}}',
|
|
67
|
+
"x-component": "Input",
|
|
68
|
+
required: true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: "json",
|
|
73
|
+
name: "options",
|
|
74
|
+
allowNull: false,
|
|
75
|
+
defaultValue: {}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "boolean",
|
|
79
|
+
name: "enabled",
|
|
80
|
+
defaultValue: false
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
interface: "m2m",
|
|
84
|
+
type: "belongsToMany",
|
|
85
|
+
name: "users",
|
|
86
|
+
target: "users",
|
|
87
|
+
foreignKey: "authenticator",
|
|
88
|
+
otherKey: "userId",
|
|
89
|
+
onDelete: "CASCADE",
|
|
90
|
+
sourceKey: "name",
|
|
91
|
+
targetKey: "id",
|
|
92
|
+
through: "usersAuthenticators"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = authenticators_default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var token_blacklist_default = {
|
|
4
|
+
namespace: "auth.token-black",
|
|
5
|
+
duplicator: "optional",
|
|
6
|
+
name: "tokenBlacklist",
|
|
7
|
+
model: "TokenBlacklistModel",
|
|
8
|
+
fields: [
|
|
9
|
+
{
|
|
10
|
+
type: "string",
|
|
11
|
+
name: "token",
|
|
12
|
+
index: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "date",
|
|
16
|
+
name: "expiration"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = token_blacklist_default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var users_authenticators_default = {
|
|
4
|
+
namespace: "auth.auth",
|
|
5
|
+
duplicator: {
|
|
6
|
+
dumpable: "optional",
|
|
7
|
+
/**
|
|
8
|
+
* When dump this collection, the users collection is required to be dumped.
|
|
9
|
+
*/
|
|
10
|
+
with: "users"
|
|
11
|
+
},
|
|
12
|
+
name: "usersAuthenticators",
|
|
13
|
+
title: '{{t("Users Authenticators")}}',
|
|
14
|
+
model: "UserAuthModel",
|
|
15
|
+
createdBy: true,
|
|
16
|
+
updatedBy: true,
|
|
17
|
+
logging: true,
|
|
18
|
+
fields: [
|
|
19
|
+
/**
|
|
20
|
+
* uuid:
|
|
21
|
+
* Unique user id of the authentication method, such as wechat openid, phone number, etc.
|
|
22
|
+
*/
|
|
23
|
+
{
|
|
24
|
+
name: "uuid",
|
|
25
|
+
interface: "input",
|
|
26
|
+
type: "string",
|
|
27
|
+
allowNull: false,
|
|
28
|
+
uiSchema: {
|
|
29
|
+
type: "string",
|
|
30
|
+
title: '{{t("UUID")}}',
|
|
31
|
+
"x-component": "Input",
|
|
32
|
+
required: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
interface: "input",
|
|
37
|
+
type: "string",
|
|
38
|
+
name: "nickname",
|
|
39
|
+
allowNull: false,
|
|
40
|
+
defaultValue: "",
|
|
41
|
+
uiSchema: {
|
|
42
|
+
type: "string",
|
|
43
|
+
title: '{{t("Nickname")}}',
|
|
44
|
+
"x-component": "Input"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
interface: "attachment",
|
|
49
|
+
type: "string",
|
|
50
|
+
name: "avatar",
|
|
51
|
+
allowNull: false,
|
|
52
|
+
defaultValue: "",
|
|
53
|
+
uiSchema: {
|
|
54
|
+
type: "string",
|
|
55
|
+
title: '{{t("Avatar")}}',
|
|
56
|
+
"x-component": "Upload"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* meta:
|
|
61
|
+
* Metadata, some other information of the authentication method.
|
|
62
|
+
*/
|
|
63
|
+
{
|
|
64
|
+
type: "json",
|
|
65
|
+
name: "meta",
|
|
66
|
+
defaultValue: {}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = users_authenticators_default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var plugin = require('./plugin');
|
|
6
|
+
var authenticator = require('./model/authenticator');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var plugin__default = /*#__PURE__*/_interopDefault(plugin);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Object.defineProperty(exports, 'default', {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return plugin__default.default; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, 'AuthModel', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return authenticator.AuthModel; }
|
|
21
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var en_US_default = {
|
|
4
|
+
"The email is incorrect, please re-enter": "The email is incorrect, please re-enter",
|
|
5
|
+
"Please fill in your email address": "Please fill in your email address",
|
|
6
|
+
"The password is incorrect, please re-enter": "The password is incorrect, please re-enter",
|
|
7
|
+
"Not a valid cellphone number, please re-enter": "Not a valid cellphone number, please re-enter",
|
|
8
|
+
"The phone number has been registered, please login directly": "The phone number has been registered, please login directly",
|
|
9
|
+
"The phone number is not registered, please register first": "The phone number is not registered, please register first"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = en_US_default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fr_FR_default = {
|
|
4
|
+
"The email is incorrect, please re-enter": "L'email est incorrect, veuillez le saisir \xE0 nouveau",
|
|
5
|
+
"Please fill in your email address": "Veuillez remplir votre adresse e-mail",
|
|
6
|
+
"The password is incorrect, please re-enter": "Le mot de passe est incorrect, veuillez le saisir \xE0 nouveau",
|
|
7
|
+
"Not a valid cellphone number, please re-enter": "Num\xE9ro de t\xE9l\xE9phone portable non valide, veuillez le saisir \xE0 nouveau",
|
|
8
|
+
"The phone number has been registered, please login directly": "Le num\xE9ro de t\xE9l\xE9phone a \xE9t\xE9 enregistr\xE9, veuillez vous connecter directement",
|
|
9
|
+
"The phone number is not registered, please register first": "Le num\xE9ro de t\xE9l\xE9phone n'est pas enregistr\xE9, veuillez vous inscrire d'abord"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = fr_FR_default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var enUS = require('./en-US');
|
|
4
|
+
var zhCN = require('./zh-CN');
|
|
5
|
+
var ptBR = require('./pt-BR');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var enUS__default = /*#__PURE__*/_interopDefault(enUS);
|
|
10
|
+
var zhCN__default = /*#__PURE__*/_interopDefault(zhCN);
|
|
11
|
+
var ptBR__default = /*#__PURE__*/_interopDefault(ptBR);
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(exports, 'enUS', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return enUS__default.default; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, 'zhCN', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return zhCN__default.default; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, 'ptBR', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return ptBR__default.default; }
|
|
26
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ja_JP_default = {
|
|
4
|
+
"Please fill in your email address": "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
5
|
+
"The password is incorrect, please re-enter": "\u30D1\u30B9\u30EF\u30FC\u30C9\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\u518D\u5EA6\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
module.exports = ja_JP_default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pt_BR_default = {
|
|
4
|
+
"The email is incorrect, please re-enter": "O e-mail est\xE1 incorreto, por favor, digite novamente",
|
|
5
|
+
"Please fill in your email address": "Por favor, preencha o seu endere\xE7o de e-mail",
|
|
6
|
+
"The password is incorrect, please re-enter": "A senha est\xE1 incorreta, por favor, digite novamente",
|
|
7
|
+
"Not a valid cellphone number, please re-enter": "N\xFAmero de celular inv\xE1lido, por favor, digite novamente",
|
|
8
|
+
"The phone number has been registered, please login directly": "O n\xFAmero de celular j\xE1 est\xE1 registrado, por favor, fa\xE7a login diretamente",
|
|
9
|
+
"The phone number is not registered, please register first": "O n\xFAmero de celular n\xE3o est\xE1 registrado, por favor, registre-se primeiro"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = pt_BR_default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zh_CN_default = {
|
|
4
|
+
"The email is incorrect, please re-enter": "\u90AE\u7BB1\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
|
|
5
|
+
"Please fill in your email address": "\u8BF7\u586B\u5199\u90AE\u7BB1",
|
|
6
|
+
"The password is incorrect, please re-enter": "\u5BC6\u7801\u6709\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
|
|
7
|
+
"Not a valid cellphone number, please re-enter": "\u4E0D\u662F\u6709\u6548\u7684\u624B\u673A\u53F7\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165",
|
|
8
|
+
"The phone number has been registered, please login directly": "\u624B\u673A\u53F7\u5DF2\u6CE8\u518C\uFF0C\u8BF7\u76F4\u63A5\u767B\u5F55",
|
|
9
|
+
"The phone number is not registered, please register first": "\u624B\u673A\u53F7\u672A\u6CE8\u518C\uFF0C\u8BF7\u5148\u6CE8\u518C",
|
|
10
|
+
"Please keep and enable at least one authenticator": "\u8BF7\u81F3\u5C11\u4FDD\u7559\u5E76\u542F\u7528\u4E00\u4E2A\u8BA4\u8BC1\u5668"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = zh_CN_default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var server = require('@nocobase/server');
|
|
4
|
+
var preset = require('../../preset');
|
|
5
|
+
|
|
6
|
+
class AddBasicAuthMigration extends server.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
const repo = this.context.db.getRepository("authenticators");
|
|
9
|
+
const existed = await repo.count();
|
|
10
|
+
if (existed) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
await repo.create({
|
|
14
|
+
values: {
|
|
15
|
+
name: preset.presetAuthenticator,
|
|
16
|
+
authType: preset.presetAuthType,
|
|
17
|
+
description: "Sign in with email and password.",
|
|
18
|
+
enabled: true
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async down() {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = AddBasicAuthMigration;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var server = require('@nocobase/server');
|
|
4
|
+
var preset = require('../../preset');
|
|
5
|
+
|
|
6
|
+
class UpdateBasicAuthMigration extends server.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
const SystemSetting = this.context.db.getRepository("systemSettings");
|
|
9
|
+
const setting = await SystemSetting.findOne();
|
|
10
|
+
const allowSignUp = setting.get("allowSignUp") ? true : false;
|
|
11
|
+
const repo = this.context.db.getRepository("authenticators");
|
|
12
|
+
await repo.update({
|
|
13
|
+
values: {
|
|
14
|
+
options: {
|
|
15
|
+
public: {
|
|
16
|
+
allowSignUp
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
filter: {
|
|
21
|
+
name: preset.presetAuthenticator
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async down() {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = UpdateBasicAuthMigration;
|