免登录页面
#1. 免登录页面
免登录页面可以用于其他平台跳转或者内嵌 DeepFlow 页面。
需要先行获取页面使用的授权码。授权码包括永久授权码模式和短时授权码,其中永久授权码需要在控制器上生成,短时授权码可以通过 API 来请求登录接口,可以在控制器上或者外部请求。短时授权码需要配合刷新 Token 来进行延期。一般情况下,建议使用短时授权码。
K8s 部署方式下,所有操作都是在 front-end 的 pod 下执行,获取 fron-end 的 pod 名称以及进入 pod 方式如下:
kubectl -n deepflow get pod -o wide |grep front-end
kubectl -n deepflow exec -it front-end-xxxx-xxxx-xxxx /bin/sh
2
#1.1 使用永久授权码
#1.1.1 获取永久授权码
提示
注意 6.6 版本中请求永久授权码地址发生变化
- 系统内部访问(K8s 部署方式):
curl -XPOST -H"content-type: application/json" -H"X-User-Id: 1" -H"X-User-Type: 1" -d'{"email":"xxxxx@yunshan.net.cn","password":"xxxxx"}' http://fuser:20824/v1/user/permanent_token
返回值:
{
"OPT_STATUS": "SUCCESS",
"DATA": {
"ACCESS_KEY": "gAAAAABnGhcHkqBxxxxxxxxxxxxxxxx",
"LCUUID": "1d036xxxxxxxxxxxxxxxxxx"
},
"DESCRIPTION": ""
}
2
3
4
5
6
7
8
ACCESS_KEY 值为永久有效的 access_token 值
提示
说明:
1:接口中的 email 和 password 请换成需要获取永久有效 token 的账户信求息
2:返回值请注意保存,Deepflow 不会保存该值明文,系统中保存的是加密后的数据
3:每个账户最多生成一个永久 token,如果想重新生成,请注销后再重新生成
4:该功能需 Deepflow 版本大于等于 6.6
#1.1.2 获取指定 email 的永久授权码 lcuuid
可以通过获取指定 email 的 lcuuid 来进行注销
- 系统内部访问(K8s 部署方式):
curl -XGET -H"content-type: application/json" -H"X-User-Id: 1" -H"X-User-Type: 1" http://fuser:20824/v1/user/permanent_token?email=xxx@xxx.com
返回值:
{
"OPT_STATUS": "SUCCESS",
"DATA": [{ "LCUUID": "xxxxxxxxxxxx" }],
"DESCRIPTION": ""
}
2
3
4
5
#1.1.3 注销永久授权码
- 系统内部访问(K8s 部署方式):
curl -XDELETE -H"content-type: application/json" -H"X-User-Id: 1" -H"X-User-Type: 1" http://fuser:20824/v1/user/permanent_token/<lcuuid>
返回值:
{
"OPT_STATUS": "SUCCESS",
"DATA": true,
"DESCRIPTION": "SUCCESS"
}
2
3
4
5
提示
说明:
请求的 url 中的 <lcuuid> 请换成获取永久有效 token 时一并返回的 lcuuid 值
#1.2 使用短时授权码
#1.2.1 获取短时授权码
- 系统内部访问(K8s 部署方式)
curl -XPOST -H"content-type: application/json" -d'{"account_type":"deepflow","grant_type": "password","password": "dev-pwd","email": "dev@yunshan.net.cn"}' http://fauths:20822/login
- 系统外部访问
curl -XPOST -H"content-type: application/json" -d'{"account_type":"deepflow","grant_type": "password","password": "dev-pwd","email": "dev@yunshan.net.cn"}' http[s]://[controller]/api/fauths/login
2
返回:
{
"OPT_STATUS": "SUCCESS",
"DATA": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE4MjMwNzAsIml",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGc",
"expires_in": 3600,
"token_type": "password",
"email": "dev@yunshan.net.cn",
"license": true
},
"DESCRIPTION": ""
}
2
3
4
5
6
7
8
9
10
11
12
access_token为短期有效 token。expires_in为过期时间,单位:秒。refresh_token为刷新access_token必备的 token,默认该 token 过期时间为30天。
提示
- 授权码的过期时间设置和过期逻辑参见授权码设置 (opens new window)
#1.2.2 刷新授权码
- 系统内部访问(rpm 部署方式)
curl -XPOST -H"content-type: application/json" -d'{"grant_type": "refresh_token","refresh_token": "eyJ0eXAiOiJKV1QiLCJ"}' http://127.0.0.1:20822/refresh_token
- 系统内部访问(K8s 部署方式)
curl -XPOST -H"content-type: application/json" -d'{"grant_type": "refresh_token","refresh_token": "eyJ0eXAiOiJKV1QiLCJ"}' http://fauths:20822/refresh_token
- 系统外部访问
curl -XPOST -H"content-type: application/json" -d'{"grant_type": "refresh_token","refresh_token": "eyJ0eXAiOiJKV1QiLCJ"}' http[s]://[controller]/api/fauths/refresh_token
返回:
{
"OPT_STATUS": "SUCCESS",
"DATA": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOi",
"expires_in": 3600,
"token_type": "refresh_token"
},
"DESCRIPTION": ""
}
2
3
4
5
6
7
8
9
10
access_token为短期有效 token。expires_in为过期时间,单位:秒。refresh_token为刷新access_token必备的 token,默认该 token 过期时间为30天。
#1.2.3 注销授权码
- 系统内部访问(rpm 部署方式)
curl -XPOST -H"content-type: application/json" -H"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI" http://127.0.0.1:20822/logout
- 系统内部访问(k8s 部署方式)
curl -XPOST -H"content-type: application/json" -H"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI" http://fauths:20822/logout
- 外部访问
curl -XPOST -H"content-type: application/json" -H"Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI" http[s]://[controller]/api/fauths/logout
警告
注意事项:
1:上文外部访问使用的 url 其中 http[s] 和 [controller] 请换成正式环境下支持的协议和域名或 ip 地址
2:系统内部访问时可以指定用户 id 和类型,但外部访问不行
#2. 界面使用授权码
提示
免登录参数说明:
- token 和 refreshToken 从上文中获取,其中 access_token 默认有效期为 60 分钟,refresh_token 默认有效期 30 天。access_token 如果过了有效期,refresh_token 还在有效期中时 url 可以保持不变,系统会刷新。如果使用永久授权码,那不需要填写 refresh_token。
警告
注意事项:
- 该方案通过 url 来实现直接登录效果,相当于用户自动完成从界面登录。请务必在安全环境下使用该功能
- 下文 url 地址中
http[s]和[controller]请换成正式环境下支持的协议和域名或 ip 地址
提示
可以根据实际访问的页面 URL + ?token=xxx&refreshToken=xxxx 来实现免登录访问,下面是一些具体的示例。
#3. 访问视图
- 请求地址(默认)
http[s]://[controller]/monitor/list
- 请求地址(免登录)
http[s]://[controller]/monitor/list?token=xxx&refreshToken=xxxx
#4. 访问应用
- 请求地址(默认)
http[s]://[controller]/appPerformance/instance/index?noBack=true
- 请求地址(免登录)
http[s]://[controller]/appPerformance/instance/index?token=xxx&refreshToken=xxxx
#5. 访问网络
- 请求地址(默认)
http[s]://[controller]/platformOverview/instance/index?noBack=true
- 请求地址(免登录)
http[s]://[controller]/appPerformance/instance/index?token=xxx&refreshToken=xxxx