@celljs/oauth2-client 4.6.0 → 4.7.0
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.zh-cn.md +30 -0
- package/package.json +7 -7
package/README.zh-cn.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Cell - OAuth2 客户端组件
|
|
2
|
+
|
|
3
|
+
通过 OAuth 2.0 / OpenID Connect 提供商(GitHub、Google、Okta、Facebook 或任何其他)让用户登录,并获取访问令牌调用 API(支持客户端凭证、密码和刷新令牌授权类型)。集成到 [`@celljs/security`](../security):成功登录就是一个常规的安全登录。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @celljs/oauth2-client @celljs/security
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 通过提供商登录
|
|
10
|
+
|
|
11
|
+
在 `cell.yml` 中注册客户端(服务端专用,与所有配置一样):
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
oauth2:
|
|
15
|
+
client:
|
|
16
|
+
registrations:
|
|
17
|
+
github:
|
|
18
|
+
clientId: "${env.GITHUB_CLIENT_ID}"
|
|
19
|
+
clientSecret: "${env.GITHUB_CLIENT_SECRET}"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- `google`、`github`、`facebook` 和 `okta` 有模板(本包 `cell.yml` 中的 `registrationTemplates`、`providerTemplates`),包含端点和作用域;Okta 和其他提供商需要在 `oauth2.client.providers.<id>` 下配置其 URL(`authorizationUri`、`tokenUri`、`userInfoEndpoint.uri`、`userInfoEndpoint.userNameAttributeName`、`jwkSetUri`、`issuerUri`)。
|
|
23
|
+
- 一个注册包括 `clientId`、`clientSecret`、`scopes`、`authorizationGrantType`、`clientAuthenticationMethod`、`redirectUri`、`provider`(默认:其 id)和 `clientName`。
|
|
24
|
+
- 把浏览器发送到 `/oauth2/authorization/github`(`oauth2.client.authorizationRequestBaseUri`)。提供商重定向回 `/login/oauth2/code/github`;默认重定向 URI 从 `server.endpoint` 构建,所以要设置 `server.endpoint` 为应用的公网 URL。
|
|
25
|
+
- 使用 `openid` 作用域时,登录是 OpenID Connect:ID 令牌用提供商的 JWK 集验证(`@celljs/oauth2-jose`)。
|
|
26
|
+
- 用户属性由 `@celljs/security` 的 `security.userMapperRule.<provider>` 映射。
|
|
27
|
+
|
|
28
|
+
## 用于 API 调用的令牌
|
|
29
|
+
|
|
30
|
+
`AuthorizedClientManager` 用其声明的授权类型(`client_credentials`、`password`、`refresh_token`、`authorization_code`)为注册授权并保管令牌,在过期前 `oauth2.client.clockSkew`(60 秒)刷新。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/oauth2-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@celljs/core": "4.
|
|
37
|
-
"@celljs/http": "4.
|
|
38
|
-
"@celljs/oauth2-core": "4.
|
|
39
|
-
"@celljs/oauth2-jose": "4.
|
|
40
|
-
"@celljs/security": "4.
|
|
41
|
-
"@celljs/web": "4.
|
|
36
|
+
"@celljs/core": "4.7.0",
|
|
37
|
+
"@celljs/http": "4.7.0",
|
|
38
|
+
"@celljs/oauth2-core": "4.7.0",
|
|
39
|
+
"@celljs/oauth2-jose": "4.7.0",
|
|
40
|
+
"@celljs/security": "4.7.0",
|
|
41
|
+
"@celljs/web": "4.7.0",
|
|
42
42
|
"jose": "^4.9.3"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|