Seafile 单点登录配置
bccastle 单点登录SSO
# 说明
从 CE 版本 6.2.3 开始,Seafile 支持用户通过OAuth登录。参考文档 (opens new window) 本文介绍如何配置IDaaS与Seafile的OAuth认证集成。
# 认证配置
# IDaaS配置
- 1.添加Seafile 应用
管理员登录企业中心 》资源》应用》新增预集成应用 搜索seafile
可信域名填写 Seafile的OAuth回调地址:https://{Seafile的域名地址}/oauth/callback/
- 2.映射配置 添加account 属性,映射类型选择账号属性,账号属性名选择accName
- 3.用户授权
进入应用信息》授权管理》应用账号》添加账号
账号名和Seafile中的登录ID保持一致
# Seafile 配置
- 1.Seafile服务器安装第三方包
sudo pip install requests_oauthlib
1
- 2.修改Seafile的seahub_settings.py 配置文件,并重启Seafile服务
ENABLE_OAUTH = True
# Usually OAuth works through SSL layer. If your server is not parametrized to allow HTTPS, some method will raise an "oauthlib.oauth2.rfc6749.errors.InsecureTransportError". Set this to `True` to avoid this error.
OAUTH_ENABLE_INSECURE_TRANSPORT = True
# Client id/secret generated by authorization server when you register your client application.
OAUTH_CLIENT_ID = "IDaaS应用的ClientId"
OAUTH_CLIENT_SECRET = "IDaaS应用的ClientSecret"
# Callback url when user authentication succeeded. Note, the redirect url you input when you register your client application MUST be exactly the same as this value.
OAUTH_REDIRECT_URL = 'https://{seafile域名}/oauth/callback/'
# The following should NOT be changed if you are using Github as OAuth provider.
OAUTH_PROVIDER_DOMAIN = '{IDaaS域名}.bccastle.com'
OAUTH_AUTHORIZATION_URL = 'https://{IDaaS域名}.bccastle.com/api/v1/oauth2/authorize'
OAUTH_TOKEN_URL = 'https://{IDaaS域名}.bccastle.com/api/v1/oauth2/token'
OAUTH_USER_INFO_URL = 'https://{IDaaS域名}.bccastle.com/api/v1/oauth2/get_user_info'
OAUTH_SCOPE = ["get_user_info",]
OAUTH_ATTRIBUTE_MAP = {
"id": (True, "account"),
"name": (False, "name"),
"email": (False, "email"),
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
参数说明
名称 | 说明 |
---|---|
ENABLE_OAUTH | True |
OAUTH_ENABLE_INSECURE_TRANSPORT | True |
OAUTH_CLIENT_ID | 应用ID,IDaaS上创建应用后,应用信息里面的ClientId |
OAUTH_CLIENT_SECRET | 应用密钥,IDaaS上创建应用后,应用信息里的ClientSecret |
OAUTH_REDIRECT_URL | Seafile的回调地址,https://your-domain.com/oauth/callback/ |
OAUTH_PROVIDER_DOMAIN | IDaaS租户域名 |
OAUTH_AUTHORIZATION_URL | IDaaS Oauth2.0 获取Authorization Code接口地址 |
OAUTH_TOKEN_URL | IDaaS Oauth2.0 获取Access Token接口地址 |
OAUTH_USER_INFO_URL | IDaaS Oauth2.0 获取用户信息接口地址 |
OAUTH_SCOPE | get_user_info |
OAUTH_ATTRIBUTE_MAP | 属性映射 id,name,email 为seafile用户属性,后面括号里的值对应IDaaS用户属性 |
IDaaS Oauth 2.0接口请参考IDaaS 应用认证集成 (opens new window)
# 登录验证
两种方式,任选其一
- 通过Seafile登录页发起
- 通过IDaaS用户中心点击应用logo