Seafile单点登录
概述
从CE版本6.2.3开始,Seafile支持用户通过OAuth登录。参考文档 本文介绍如何配置竹云IDaaS与Seafile的OAuth认证集成。
认证配置
竹云IDaaS 配置
管理员登录企业中心 》资源》应用》新增预集成应用,搜索seafile。


可信域名填写 Seafile的OAuth回调地址:https://{Seafile的域名地址}/oauth/callback/
添加account 属性,映射类型选择账号属性,账号属性名选择accName。

进入应用信息》授权管理》应用账号》添加账号,账号名和Seafile中的登录ID保持一致。


Seafile 配置
Seafile服务器安装第三方包。
shellsudo pip install requests_oauthlib修改Seafile的seahub_settings.py 配置文件,并重启Seafile服务。
pythonENABLE_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"), }参数说明如下:
名称 说明 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 应用认证集成。
登录验证
如下两种方式登录:
通过Seafile登录页发起。

通过竹云IDaaS 用户中心点击应用logo。
