@nocobase/plugin-auth 1.4.0-alpha.6 → 1.4.0-alpha.8
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/README.md +19 -106
- package/dist/externalVersion.js +8 -8
- package/dist/node_modules/cron/package.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,117 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NocoBase
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<video width="100%" controls>
|
|
4
|
+
<source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
|
|
5
|
+
</video>
|
|
4
6
|
|
|
5
|
-
## 使用方法
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
页面:系统设置 - 认证
|
|
8
|
+
## What is NocoBase
|
|
9
9
|
|
|
10
|
+
NocoBase is a scalability-first, open-source no-code development platform.
|
|
11
|
+
Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Homepage:
|
|
14
|
+
https://www.nocobase.com/
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- 认证类型:邮箱密码登录
|
|
16
|
+
Online Demo:
|
|
17
|
+
https://demo.nocobase.com/new
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
Documents:
|
|
20
|
+
https://docs.nocobase.com/
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
Commericial license & plugins:
|
|
23
|
+
https://www.nocobase.com/en/commercial
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
License agreement:
|
|
26
|
+
https://www.nocobase.com/en/agreement
|
|
23
27
|
|
|
24
|
-
<img src="https://s2.loli.net/2023/05/15/CR7UTDt2WzbEfgs.png" width="300px" />
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<img src="https://s2.loli.net/2023/05/15/2utpSHly9fzCKX5.png" width="400px" />
|
|
30
|
-
|
|
31
|
-
#### 配置认证器
|
|
32
|
-
Actions - Edit
|
|
33
|
-
|
|
34
|
-
## 开发一个登录插件
|
|
35
|
-
### 接口
|
|
36
|
-
Nocobase内核提供了扩展登录方式的接入和管理。扩展登录插件的核心逻辑处理,需要继承内核的`Auth`类,并对相应的标准接口进行实现。
|
|
37
|
-
参考`core/auth/auth.ts`
|
|
38
|
-
|
|
39
|
-
```TypeScript
|
|
40
|
-
import { Auth } from '@nocobase/auth';
|
|
41
|
-
|
|
42
|
-
class CustomAuth extends Auth {
|
|
43
|
-
set user(user) {}
|
|
44
|
-
get user() {}
|
|
45
|
-
|
|
46
|
-
async check() {}
|
|
47
|
-
async signIn() {}
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
多数情况下,扩展的用户登录方式也将沿用现有的jwt逻辑来生成用户访问API的凭证,插件也可以继承`BaseAuth`类以便复用部分逻辑代码,如`check`, `signIn`接口。
|
|
52
|
-
|
|
53
|
-
```TypeScript
|
|
54
|
-
import { BaseAuth } from '@nocobase/auth';
|
|
55
|
-
|
|
56
|
-
class CustomAuth extends BaseAuth {
|
|
57
|
-
constructor(config: AuthConfig) {
|
|
58
|
-
const userCollection = config.ctx.db.getCollection('users');
|
|
59
|
-
super({ ...config, userCollection });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async validate() {}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 用户数据
|
|
67
|
-
|
|
68
|
-
`@nocobase/plugin-auth`插件提供了`usersAuthenticators`表来建立users和authenticators,即用户和认证方式的关联。
|
|
69
|
-
通常情况下,扩展登录方式用`users`和`usersAuthenticators`来存储相应的用户数据即可,特殊情况下才需要自己新增Collection.
|
|
70
|
-
`users`存储的是最基础的用户数据,邮箱、昵称和密码。
|
|
71
|
-
`usersAuthenticators`存储扩展登录方式数据
|
|
72
|
-
- uuid: 该种认证方式的用户唯一标识,如手机号、微信openid等
|
|
73
|
-
- meta: JSON字段,其他需要保存的信息
|
|
74
|
-
- userId: 用户id
|
|
75
|
-
- authenticator:认证器名字
|
|
76
|
-
|
|
77
|
-
对于用户操作,`Authenticator`模型也提供了几个封装的方法,可以在`CustomAuth`类中通过`this.authenticator[方法名]`使用:
|
|
78
|
-
- `findUser(uuid: string): UserModel` - 查询用户
|
|
79
|
-
- `newUser(uuid: string, values?: any): UserModel` - 创建新用户
|
|
80
|
-
- `findOrCreateUser(uuid: string, userValues?: any): UserModel` - 查找或创建新用户
|
|
81
|
-
|
|
82
|
-
### 注册
|
|
83
|
-
扩展的登录方式需要向内核注册。
|
|
84
|
-
```TypeScript
|
|
85
|
-
async load() {
|
|
86
|
-
this.app.authManager.registerTypes('custom-auth-type', {
|
|
87
|
-
auth: CustomAuth,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### 客户端API
|
|
93
|
-
#### OptionsComponentProvider
|
|
94
|
-
可供用户配置的认证器配置项
|
|
95
|
-
- authType 认证方式
|
|
96
|
-
- component 配置组件
|
|
97
|
-
```TypeScript
|
|
98
|
-
<OptionsComponentProvider authType="custom-auth-type" component={Options} />
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
`Options`组件使用的值是`authenticator`的`options`字段,如果有需要暴露在前端的配置,应该放在`options.public`字段中。`authenticators:publicList`接口会返回`options.public`字段的值。
|
|
102
|
-
|
|
103
|
-
#### SigninPageProvider
|
|
104
|
-
自定义登录页界面
|
|
105
|
-
- authType 认证方式
|
|
106
|
-
- tabTitle 登录页tab标题
|
|
107
|
-
- component 登录页组件
|
|
108
|
-
|
|
109
|
-
#### SignupPageProvider
|
|
110
|
-
自定义注册页界面
|
|
111
|
-
- authType 认证方式
|
|
112
|
-
- component 注册页组件
|
|
113
|
-
|
|
114
|
-
#### SigninPageExtensionProvider
|
|
115
|
-
自定义登录页下方的扩展内容
|
|
116
|
-
- authType 认证方式
|
|
117
|
-
- component 扩展组件
|
|
29
|
+
## Contact Us:
|
|
30
|
+
hello@nocobase.com
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
11
|
+
"@nocobase/client": "1.4.0-alpha.8",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
14
|
-
"@nocobase/auth": "1.4.0-alpha.
|
|
15
|
-
"@nocobase/database": "1.4.0-alpha.
|
|
16
|
-
"@nocobase/cache": "1.4.0-alpha.
|
|
17
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
18
|
-
"@nocobase/test": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/utils": "1.4.0-alpha.8",
|
|
14
|
+
"@nocobase/auth": "1.4.0-alpha.8",
|
|
15
|
+
"@nocobase/database": "1.4.0-alpha.8",
|
|
16
|
+
"@nocobase/cache": "1.4.0-alpha.8",
|
|
17
|
+
"@nocobase/server": "1.4.0-alpha.8",
|
|
18
|
+
"@nocobase/test": "1.4.0-alpha.8",
|
|
19
19
|
"antd": "5.12.8",
|
|
20
20
|
"@formily/react": "2.3.0",
|
|
21
21
|
"react-router-dom": "6.21.0",
|
|
@@ -23,5 +23,5 @@ module.exports = {
|
|
|
23
23
|
"react-i18next": "11.18.6",
|
|
24
24
|
"@emotion/css": "11.13.0",
|
|
25
25
|
"@ant-design/icons": "5.2.6",
|
|
26
|
-
"@nocobase/actions": "1.4.0-alpha.
|
|
26
|
+
"@nocobase/actions": "1.4.0-alpha.8"
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","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","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","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","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"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","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-11-
|
|
1
|
+
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","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","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","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","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"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","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-11-11T04:25:23.987Z"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.8",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/auth",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/auth",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"displayName.zh-CN": "用户认证",
|
|
27
27
|
"description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
|
|
28
28
|
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "aa36bd20b2028c5e133a59e922c2f1ab22c86dde",
|
|
30
30
|
"keywords": [
|
|
31
31
|
"Authentication"
|
|
32
32
|
]
|