@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
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import Database, { Repository } from '@nocobase/database';
|
|
2
|
-
import { mockServer, MockServer } from '@nocobase/test';
|
|
3
|
-
import AuthPlugin from '../';
|
|
4
|
-
import UsersPlugin from '@nocobase/plugin-users';
|
|
5
|
-
|
|
6
|
-
describe('actions', () => {
|
|
7
|
-
describe('authenticators', () => {
|
|
8
|
-
let app: MockServer;
|
|
9
|
-
let db: Database;
|
|
10
|
-
let repo: Repository;
|
|
11
|
-
let agent;
|
|
12
|
-
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
app = mockServer();
|
|
15
|
-
app.plugin(AuthPlugin);
|
|
16
|
-
await app.loadAndInstall({ clean: true });
|
|
17
|
-
db = app.db;
|
|
18
|
-
repo = db.getRepository('authenticators');
|
|
19
|
-
|
|
20
|
-
agent = app.agent();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
afterEach(async () => {
|
|
24
|
-
await repo.destroy({
|
|
25
|
-
truncate: true,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
afterAll(async () => {
|
|
30
|
-
await db.close();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should list authenticator types', async () => {
|
|
34
|
-
const res = await agent.resource('authenticators').listTypes();
|
|
35
|
-
expect(res.body.data).toEqual(['Email/Password']);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should return enabled authenticators with public options', async () => {
|
|
39
|
-
await repo.destroy({
|
|
40
|
-
truncate: true,
|
|
41
|
-
});
|
|
42
|
-
await repo.createMany({
|
|
43
|
-
records: [
|
|
44
|
-
{ name: 'test', authType: 'testType', enabled: true, options: { public: { test: 1 }, private: { test: 2 } } },
|
|
45
|
-
{ name: 'test2', authType: 'testType' },
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
const res = await agent.resource('authenticators').publicList();
|
|
49
|
-
expect(res.body.data.length).toBe(1);
|
|
50
|
-
expect(res.body.data[0].name).toBe('test');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should keep at least one authenticator', async () => {
|
|
54
|
-
await repo.createMany({
|
|
55
|
-
records: [{ name: 'test', authType: 'testType', enabled: true }],
|
|
56
|
-
});
|
|
57
|
-
const res = await agent.resource('authenticators').destroy();
|
|
58
|
-
expect(res.statusCode).toBe(400);
|
|
59
|
-
expect(await repo.count()).toBe(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('shoud enable at least one authenticator', async () => {
|
|
63
|
-
await repo.createMany({
|
|
64
|
-
records: [{ name: 'test', authType: 'testType', enabled: true }],
|
|
65
|
-
});
|
|
66
|
-
const res = await agent.resource('authenticators').update({
|
|
67
|
-
filterByTk: 1,
|
|
68
|
-
values: {
|
|
69
|
-
enabled: false,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
expect(res.statusCode).toBe(400);
|
|
73
|
-
expect(await repo.count()).toBe(1);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('auth', () => {
|
|
78
|
-
let app: MockServer;
|
|
79
|
-
let db: Database;
|
|
80
|
-
let agent;
|
|
81
|
-
|
|
82
|
-
beforeAll(async () => {
|
|
83
|
-
app = mockServer();
|
|
84
|
-
process.env.INIT_ROOT_EMAIL = 'test@nocobase.com';
|
|
85
|
-
process.env.INIT_ROOT_PASSWORD = '123456';
|
|
86
|
-
process.env.INIT_ROOT_NICKNAME = 'Test';
|
|
87
|
-
app.plugin(AuthPlugin);
|
|
88
|
-
app.plugin(UsersPlugin, { name: 'users' });
|
|
89
|
-
await app.loadAndInstall({ clean: true });
|
|
90
|
-
db = app.db;
|
|
91
|
-
agent = app.agent();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
afterAll(async () => {
|
|
95
|
-
await db.close();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should sign in with email and password', async () => {
|
|
99
|
-
let res = await agent.resource('auth').check();
|
|
100
|
-
expect(res.body.data.id).toBeUndefined();
|
|
101
|
-
|
|
102
|
-
res = await agent.post('/auth:signIn').set({ 'X-Authenticator': 'basic' }).send({
|
|
103
|
-
email: process.env.INIT_ROOT_EMAIL,
|
|
104
|
-
password: process.env.INIT_ROOT_PASSWORD,
|
|
105
|
-
});
|
|
106
|
-
expect(res.statusCode).toEqual(200);
|
|
107
|
-
const data = res.body.data;
|
|
108
|
-
const token = data.token;
|
|
109
|
-
expect(token).toBeDefined();
|
|
110
|
-
|
|
111
|
-
res = await agent.get('/auth:check').set({ Authorization: `Bearer ${token}`, 'X-Authenticator': 'basic' });
|
|
112
|
-
expect(res.body.data.id).toBeDefined();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should disable sign up', async () => {
|
|
116
|
-
let res = await agent.post('/auth:signUp').set({ 'X-Authenticator': 'basic' }).send({
|
|
117
|
-
email: 'new',
|
|
118
|
-
password: 'new',
|
|
119
|
-
});
|
|
120
|
-
expect(res.statusCode).toEqual(200);
|
|
121
|
-
|
|
122
|
-
const repo = db.getRepository('authenticators');
|
|
123
|
-
await repo.update({
|
|
124
|
-
filter: {
|
|
125
|
-
name: 'basic',
|
|
126
|
-
},
|
|
127
|
-
values: {
|
|
128
|
-
options: {
|
|
129
|
-
public: {
|
|
130
|
-
allowSignUp: false,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
res = await agent.post('/auth:signUp').set({ 'X-Authenticator': 'basic' }).send({
|
|
136
|
-
email: process.env.INIT_ROOT_EMAIL,
|
|
137
|
-
password: process.env.INIT_ROOT_PASSWORD,
|
|
138
|
-
});
|
|
139
|
-
expect(res.statusCode).toEqual(403);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import Database, { Repository } from '@nocobase/database';
|
|
2
|
-
import { MockServer, mockServer } from '@nocobase/test';
|
|
3
|
-
import { TokenBlacklistService } from '../token-blacklist';
|
|
4
|
-
|
|
5
|
-
describe('token-blacklist', () => {
|
|
6
|
-
let app: MockServer;
|
|
7
|
-
let db: Database;
|
|
8
|
-
let repo: Repository;
|
|
9
|
-
let tokenBlacklist: TokenBlacklistService;
|
|
10
|
-
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
app = mockServer({
|
|
13
|
-
plugins: ['auth'],
|
|
14
|
-
});
|
|
15
|
-
await app.loadAndInstall({ clean: true });
|
|
16
|
-
db = app.db;
|
|
17
|
-
repo = db.getRepository('tokenBlacklist');
|
|
18
|
-
tokenBlacklist = new TokenBlacklistService(app.getPlugin('auth'));
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterAll(async () => {
|
|
22
|
-
await db.close();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(async () => {
|
|
26
|
-
await repo.destroy({
|
|
27
|
-
truncate: true,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('add and has correctly', async () => {
|
|
32
|
-
await tokenBlacklist.add({
|
|
33
|
-
token: 'test',
|
|
34
|
-
expiration: new Date(),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
await tokenBlacklist.add({
|
|
38
|
-
token: 'test1',
|
|
39
|
-
expiration: new Date(),
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
expect(tokenBlacklist.has('test')).toBeTruthy();
|
|
43
|
-
expect(tokenBlacklist.has('test1')).toBeTruthy();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('add same token correctly', async () => {
|
|
47
|
-
await tokenBlacklist.add({
|
|
48
|
-
token: 'test',
|
|
49
|
-
expiration: new Date(),
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
await tokenBlacklist.add({
|
|
53
|
-
token: 'test',
|
|
54
|
-
expiration: new Date(),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(tokenBlacklist.has('test')).toBeTruthy();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('delete expired token correctly', async () => {
|
|
61
|
-
await tokenBlacklist.add({
|
|
62
|
-
token: 'should be deleted',
|
|
63
|
-
expiration: new Date('2020-01-01'),
|
|
64
|
-
});
|
|
65
|
-
await tokenBlacklist.add({
|
|
66
|
-
token: 'should not be deleted',
|
|
67
|
-
expiration: new Date('2100-01-01'),
|
|
68
|
-
});
|
|
69
|
-
await tokenBlacklist.deleteByExpiration();
|
|
70
|
-
expect(await tokenBlacklist.has('should be deleted')).not.toBeTruthy();
|
|
71
|
-
expect(await tokenBlacklist.has('should not be deleted')).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Context, Next } from '@nocobase/actions';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
lostPassword: async (ctx: Context, next: Next) => {
|
|
5
|
-
ctx.body = await ctx.auth.lostPassword();
|
|
6
|
-
await next();
|
|
7
|
-
},
|
|
8
|
-
resetPassword: async (ctx: Context, next: Next) => {
|
|
9
|
-
ctx.body = await ctx.auth.resetPassword();
|
|
10
|
-
await next();
|
|
11
|
-
},
|
|
12
|
-
getUserByResetToken: async (ctx: Context, next: Next) => {
|
|
13
|
-
ctx.body = await ctx.auth.getUserByResetToken();
|
|
14
|
-
await next();
|
|
15
|
-
},
|
|
16
|
-
changePassword: async (ctx: Context, next: Next) => {
|
|
17
|
-
ctx.body = await ctx.auth.changePassword();
|
|
18
|
-
await next();
|
|
19
|
-
},
|
|
20
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Context, Next } from '@nocobase/actions';
|
|
2
|
-
import { Model, Repository } from '@nocobase/database';
|
|
3
|
-
import { namespace } from '../../preset';
|
|
4
|
-
|
|
5
|
-
async function checkCount(repository: Repository, id: number[]) {
|
|
6
|
-
// TODO(yangqia): This is a temporary solution, may cause concurrency problem.
|
|
7
|
-
const count = await repository.count({
|
|
8
|
-
filter: {
|
|
9
|
-
enabled: true,
|
|
10
|
-
id: {
|
|
11
|
-
$ne: id,
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
if (count <= 0) {
|
|
16
|
-
throw new Error('Please keep and enable at least one authenticator');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
listTypes: async (ctx: Context, next: Next) => {
|
|
22
|
-
ctx.body = ctx.app.authManager.listTypes();
|
|
23
|
-
await next();
|
|
24
|
-
},
|
|
25
|
-
publicList: async (ctx: Context, next: Next) => {
|
|
26
|
-
const repo = ctx.db.getRepository('authenticators');
|
|
27
|
-
const authenticators = await repo.find({
|
|
28
|
-
fields: ['name', 'authType', 'title', 'options', 'sort'],
|
|
29
|
-
filter: {
|
|
30
|
-
enabled: true,
|
|
31
|
-
},
|
|
32
|
-
sort: 'sort',
|
|
33
|
-
});
|
|
34
|
-
ctx.body = authenticators.map((authenticator: Model) => ({
|
|
35
|
-
name: authenticator.name,
|
|
36
|
-
authType: authenticator.authType,
|
|
37
|
-
title: authenticator.title,
|
|
38
|
-
options: authenticator.options?.public || {},
|
|
39
|
-
}));
|
|
40
|
-
await next();
|
|
41
|
-
},
|
|
42
|
-
destroy: async (ctx: Context, next: Next) => {
|
|
43
|
-
const repository = ctx.db.getRepository('authenticators');
|
|
44
|
-
const { filterByTk, filter } = ctx.action.params;
|
|
45
|
-
try {
|
|
46
|
-
await checkCount(repository, filterByTk);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
ctx.throw(400, ctx.t(err.message, { ns: namespace }));
|
|
49
|
-
}
|
|
50
|
-
const instance = await repository.destroy({
|
|
51
|
-
filter,
|
|
52
|
-
filterByTk,
|
|
53
|
-
context: ctx,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
ctx.body = instance;
|
|
57
|
-
await next();
|
|
58
|
-
},
|
|
59
|
-
update: async (ctx: Context, next: Next) => {
|
|
60
|
-
const repository = ctx.db.getRepository('authenticators');
|
|
61
|
-
const { forceUpdate, filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } =
|
|
62
|
-
ctx.action.params;
|
|
63
|
-
|
|
64
|
-
if (!values.enabled) {
|
|
65
|
-
try {
|
|
66
|
-
await checkCount(repository, values.id);
|
|
67
|
-
} catch (err) {
|
|
68
|
-
ctx.throw(400, ctx.t(err.message, { ns: namespace }));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
ctx.body = await repository.update({
|
|
73
|
-
filterByTk,
|
|
74
|
-
values,
|
|
75
|
-
whitelist,
|
|
76
|
-
blacklist,
|
|
77
|
-
filter,
|
|
78
|
-
updateAssociationValues,
|
|
79
|
-
context: ctx,
|
|
80
|
-
forceUpdate,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
await next();
|
|
84
|
-
},
|
|
85
|
-
};
|
|
File without changes
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Collection for extended authentication methods,
|
|
5
|
-
*/
|
|
6
|
-
export default {
|
|
7
|
-
namespace: 'auth.auth',
|
|
8
|
-
duplicator: 'optional',
|
|
9
|
-
name: 'authenticators',
|
|
10
|
-
sortable: true,
|
|
11
|
-
title: '{{t("Authenticators")}}',
|
|
12
|
-
model: 'AuthModel',
|
|
13
|
-
createdBy: true,
|
|
14
|
-
updatedBy: true,
|
|
15
|
-
logging: true,
|
|
16
|
-
fields: [
|
|
17
|
-
{
|
|
18
|
-
name: 'id',
|
|
19
|
-
type: 'bigInt',
|
|
20
|
-
autoIncrement: true,
|
|
21
|
-
primaryKey: true,
|
|
22
|
-
allowNull: false,
|
|
23
|
-
interface: 'id',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
interface: 'input',
|
|
27
|
-
type: 'string',
|
|
28
|
-
name: 'name',
|
|
29
|
-
allowNull: false,
|
|
30
|
-
unique: true,
|
|
31
|
-
uiSchema: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
title: '{{t("Name")}}',
|
|
34
|
-
'x-component': 'Input',
|
|
35
|
-
required: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
interface: 'input',
|
|
40
|
-
type: 'string',
|
|
41
|
-
name: 'authType',
|
|
42
|
-
allowNull: false,
|
|
43
|
-
uiSchema: {
|
|
44
|
-
type: 'string',
|
|
45
|
-
title: '{{t("Auth Type")}}',
|
|
46
|
-
'x-component': 'Input',
|
|
47
|
-
required: true,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
interface: 'input',
|
|
52
|
-
type: 'string',
|
|
53
|
-
name: 'title',
|
|
54
|
-
uiSchema: {
|
|
55
|
-
type: 'string',
|
|
56
|
-
title: '{{t("Title")}}',
|
|
57
|
-
'x-component': 'Input',
|
|
58
|
-
},
|
|
59
|
-
translation: true,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
interface: 'textarea',
|
|
63
|
-
type: 'string',
|
|
64
|
-
name: 'description',
|
|
65
|
-
allowNull: false,
|
|
66
|
-
defaultValue: '',
|
|
67
|
-
uiSchema: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
title: '{{t("Description")}}',
|
|
70
|
-
'x-component': 'Input',
|
|
71
|
-
required: true,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
type: 'json',
|
|
76
|
-
name: 'options',
|
|
77
|
-
allowNull: false,
|
|
78
|
-
defaultValue: {},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
name: 'enabled',
|
|
83
|
-
defaultValue: false,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
interface: 'm2m',
|
|
87
|
-
type: 'belongsToMany',
|
|
88
|
-
name: 'users',
|
|
89
|
-
target: 'users',
|
|
90
|
-
foreignKey: 'authenticator',
|
|
91
|
-
otherKey: 'userId',
|
|
92
|
-
onDelete: 'CASCADE',
|
|
93
|
-
sourceKey: 'name',
|
|
94
|
-
targetKey: 'id',
|
|
95
|
-
through: 'usersAuthenticators',
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
} as CollectionOptions;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/client';
|
|
2
|
-
|
|
3
|
-
export 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
|
-
} as CollectionOptions;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { CollectionOptions } from '@nocobase/database';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Collection for user information of extended authentication methods,
|
|
5
|
-
* such as saml, oicd, oauth, sms, etc.
|
|
6
|
-
*/
|
|
7
|
-
export default {
|
|
8
|
-
namespace: 'auth.auth',
|
|
9
|
-
duplicator: {
|
|
10
|
-
dumpable: 'optional',
|
|
11
|
-
/**
|
|
12
|
-
* When dump this collection, the users collection is required to be dumped.
|
|
13
|
-
*/
|
|
14
|
-
with: 'users',
|
|
15
|
-
},
|
|
16
|
-
name: 'usersAuthenticators',
|
|
17
|
-
title: '{{t("Users Authenticators")}}',
|
|
18
|
-
model: 'UserAuthModel',
|
|
19
|
-
createdBy: true,
|
|
20
|
-
updatedBy: true,
|
|
21
|
-
logging: true,
|
|
22
|
-
fields: [
|
|
23
|
-
/**
|
|
24
|
-
* uuid:
|
|
25
|
-
* Unique user id of the authentication method, such as wechat openid, phone number, etc.
|
|
26
|
-
*/
|
|
27
|
-
{
|
|
28
|
-
name: 'uuid',
|
|
29
|
-
interface: 'input',
|
|
30
|
-
type: 'string',
|
|
31
|
-
allowNull: false,
|
|
32
|
-
uiSchema: {
|
|
33
|
-
type: 'string',
|
|
34
|
-
title: '{{t("UUID")}}',
|
|
35
|
-
'x-component': 'Input',
|
|
36
|
-
required: true,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
interface: 'input',
|
|
41
|
-
type: 'string',
|
|
42
|
-
name: 'nickname',
|
|
43
|
-
allowNull: false,
|
|
44
|
-
defaultValue: '',
|
|
45
|
-
uiSchema: {
|
|
46
|
-
type: 'string',
|
|
47
|
-
title: '{{t("Nickname")}}',
|
|
48
|
-
'x-component': 'Input',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
interface: 'attachment',
|
|
53
|
-
type: 'string',
|
|
54
|
-
name: 'avatar',
|
|
55
|
-
allowNull: false,
|
|
56
|
-
defaultValue: '',
|
|
57
|
-
uiSchema: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
title: '{{t("Avatar")}}',
|
|
60
|
-
'x-component': 'Upload',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
* meta:
|
|
65
|
-
* Metadata, some other information of the authentication method.
|
|
66
|
-
*/
|
|
67
|
-
{
|
|
68
|
-
type: 'json',
|
|
69
|
-
name: 'meta',
|
|
70
|
-
defaultValue: {},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
} as CollectionOptions;
|
package/src/server/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'The email is incorrect, please re-enter': 'The email is incorrect, please re-enter',
|
|
3
|
-
'Please fill in your email address': 'Please fill in your email address',
|
|
4
|
-
'The password is incorrect, please re-enter': 'The password is incorrect, please re-enter',
|
|
5
|
-
'Not a valid cellphone number, please re-enter': 'Not a valid cellphone number, please re-enter',
|
|
6
|
-
'The phone number has been registered, please login directly':
|
|
7
|
-
'The phone number has been registered, please login directly',
|
|
8
|
-
'The phone number is not registered, please register first':
|
|
9
|
-
'The phone number is not registered, please register first',
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'The email is incorrect, please re-enter': 'L\'email est incorrect, veuillez le saisir à nouveau',
|
|
3
|
-
'Please fill in your email address': 'Veuillez remplir votre adresse e-mail',
|
|
4
|
-
'The password is incorrect, please re-enter': 'Le mot de passe est incorrect, veuillez le saisir à nouveau',
|
|
5
|
-
'Not a valid cellphone number, please re-enter': 'Numéro de téléphone portable non valide, veuillez le saisir à nouveau',
|
|
6
|
-
'The phone number has been registered, please login directly':
|
|
7
|
-
'Le numéro de téléphone a été enregistré, veuillez vous connecter directement',
|
|
8
|
-
'The phone number is not registered, please register first':
|
|
9
|
-
'Le numéro de téléphone n\'est pas enregistré, veuillez vous inscrire d\'abord',
|
|
10
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'The email is incorrect, please re-enter': 'O e-mail está incorreto, por favor, digite novamente',
|
|
3
|
-
'Please fill in your email address': 'Por favor, preencha o seu endereço de e-mail',
|
|
4
|
-
'The password is incorrect, please re-enter': 'A senha está incorreta, por favor, digite novamente',
|
|
5
|
-
'Not a valid cellphone number, please re-enter': 'Número de celular inválido, por favor, digite novamente',
|
|
6
|
-
'The phone number has been registered, please login directly':
|
|
7
|
-
'O número de celular já está registrado, por favor, faça login diretamente',
|
|
8
|
-
'The phone number is not registered, please register first':
|
|
9
|
-
'O número de celular não está registrado, por favor, registre-se primeiro',
|
|
10
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
'The email is incorrect, please re-enter': '邮箱有误,请重新输入',
|
|
3
|
-
'Please fill in your email address': '请填写邮箱',
|
|
4
|
-
'The password is incorrect, please re-enter': '密码有误,请重新输入',
|
|
5
|
-
'Not a valid cellphone number, please re-enter': '不是有效的手机号,请重新输入',
|
|
6
|
-
'The phone number has been registered, please login directly': '手机号已注册,请直接登录',
|
|
7
|
-
'The phone number is not registered, please register first': '手机号未注册,请先注册',
|
|
8
|
-
'Please keep and enable at least one authenticator': '请至少保留并启用一个认证器',
|
|
9
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@nocobase/server';
|
|
2
|
-
import { presetAuthType, presetAuthenticator } from '../../preset';
|
|
3
|
-
|
|
4
|
-
export default class AddBasicAuthMigration extends Migration {
|
|
5
|
-
async up() {
|
|
6
|
-
const repo = this.context.db.getRepository('authenticators');
|
|
7
|
-
const existed = await repo.count();
|
|
8
|
-
if (existed) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
await repo.create({
|
|
12
|
-
values: {
|
|
13
|
-
name: presetAuthenticator,
|
|
14
|
-
authType: presetAuthType,
|
|
15
|
-
description: 'Sign in with email and password.',
|
|
16
|
-
enabled: true,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async down() {}
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@nocobase/server';
|
|
2
|
-
import { presetAuthenticator } from '../../preset';
|
|
3
|
-
|
|
4
|
-
export default class UpdateBasicAuthMigration extends Migration {
|
|
5
|
-
async up() {
|
|
6
|
-
const SystemSetting = this.context.db.getRepository('systemSettings');
|
|
7
|
-
const setting = await SystemSetting.findOne();
|
|
8
|
-
const allowSignUp = setting.get('allowSignUp') ? true : false;
|
|
9
|
-
const repo = this.context.db.getRepository('authenticators');
|
|
10
|
-
await repo.update({
|
|
11
|
-
values: {
|
|
12
|
-
options: {
|
|
13
|
-
public: {
|
|
14
|
-
allowSignUp,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
filter: {
|
|
19
|
-
name: presetAuthenticator,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async down() {}
|
|
25
|
-
}
|