Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
9f8b6dbc
authored
Apr 21, 2025
by
Finley Ge
Committed by
GitHub
Apr 21, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: sso oauth2.0 standard doc (#4612)
parent
d8fe9806
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
19 deletions
+48
-19
docSite/content/zh-cn/docs/guide/admin/sso.md
+48
-19
No files found.
docSite/content/zh-cn/docs/guide/admin/sso.md
View file @
9f8b6dbc
...
@@ -296,24 +296,46 @@ fastgpt-sso:
...
@@ -296,24 +296,46 @@ fastgpt-sso:
### 标准 OAuth2.0
### 标准 OAuth2.0
我们提供一套 RFC 6749 中鉴权码模式的 OAuth2.0 接入支持。
参考:
-
[
RFC 6749
](
https://datatracker.ietf.org/doc/html/rfc6749
)
文档。
-
[
阮一峰的网络日志
](
https://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html
)
#### 参数需求
#### 参数需求
##### 三个地址
我们提供一套标准的 OAuth2.0 接入流程。需要三个地址:
我们提供一套标准的 OAuth2.0 接入流程。需要三个地址:
1.
登陆鉴权地址(登陆后将 code 传入 redirect_uri)
1.
登陆鉴权地址(用户点击 SSO 按钮后将携带参数直接跳转到该地址), 例如:
`http://example.com/oauth/authorize`
-
需要将地址完整写好,除了 redirect_uri 以外(会自动补全)
```
bash
2.
获取 access_token 的地址,请求为 GET 方法,参数 code
curl
-X
GET
\
"http://example.com/oauth/authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz&redirect_uri=https%3A%2F%2Ffastgpt.cn%2Flogin%2Fprovider"
```
bash
```
http://example.com/oauth/access_token?code
=
xxxx
用户输入账号密码后,会跳转到 redirect_uri 中,并携带 code 参数:
```
`
https://fastgpt.cn/login/provider?code
=
4/P7qD2qAz4&state
=
xyz
`
2. 获取 access_token 的地址,获取到 code 后,通过
*
服务器请求
*
该地址获取 access_token 例如:
`
http://example.com/oauth/access_token
`
3.
获取用户信息的地址
```
bash
curl
-X
POST
\
```
bash
-H
"Content-Type: application/x-www-form-urlencoded"
\
http://example.com/oauth/user_info
"http://example.com/oauth/access_token?grant_type=authorization_code&client_id=s6BhdRkqt3&client_secret=xxx&code=4/P7qD2qAz4&redirect_uri=https%3A%2F%2Ffastgpt.cn%2Flogin%2Fprovider"
```
```
注意:Content-Type 必须是 application/x-www-form-urlencoded, 而不是 application/json
3. 获取用户信息的地址,需要传入 access_token 例如:
`
http://example.com/oauth/user_info
`
```
bash
curl
-X
GET
\
-H
"Authorization: Bearer 4/P7qD2qAz4"
\
"http://example.com/oauth/user_info"
```
注意: access_token 作为 Authorization 头部传入, 格式为 Bearer xxxx
##### 参数配置
- CLIENT_ID: 必须
- CLIENT_SECRET: 非必须,如果没有可以不配置
- SCOPE: 非必须,如果没有可以不配置
>
redirect_uri 参数会根据运行环境自动补全
>
>
其他固定参数如 grant_type, response_type 等会自动补全
#### 配置示例
#### 配置示例
...
@@ -326,14 +348,21 @@ fastgpt-sso:
...
@@ -326,14 +348,21 @@ fastgpt-sso:
-
fastgpt
-
fastgpt
environment:
environment:
# OAuth2.0
# OAuth2.0
-
AUTH_TOKEN
=
xxxxx
# === 请求地址 ===
-
SSO_PROVIDER
=
oauth2
# 1. OAuth2 登陆鉴权地址 (必填)
# OAuth2 重定向地址
-
OAUTH2_AUTHORIZE_URL=
-
OAUTH2_AUTHORIZE_URL=
# OAuth2 获取 AccessToken 地址
# 2. OAuth2 获取 AccessToken 地址 (必填)
-
OAUTH2_TOKEN_URL=
-
OAUTH2_TOKEN_URL=
# OAuth2 获取用户信息地址
# 3. OAuth2 获取用户信息地址 (必填)
-
OAUTH2_USER_INFO_URL=
-
OAUTH2_USER_INFO_URL=
# === 参数 ===
# 1. client_id (必填)
-
OAUTH2_CLIENT_ID=
# 2. client_secret (选填,如果没有则不传)
-
OAUTH2_CLIENT_SECRET=
# 3. scope (选填)
-
OAUTH2_SCOPE=
# === 字段映射 ===
# OAuth2 用户名字段映射(必填)
# OAuth2 用户名字段映射(必填)
-
OAUTH2_USERNAME_MAP=
-
OAUTH2_USERNAME_MAP=
# OAuth2 头像字段映射(选填)
# OAuth2 头像字段映射(选填)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment