ad文件服务器部署,AD 集成 – 配置 ADFS 登陆 - Seafile 服务器用户手册
要求
要想使用 ADFS 登陸到 Seafile,需要以下組件:
1、安裝了 ADFS 的windows服務器。安裝 ADFS 和相關配置詳情請參考 本文。
2、對于 ADFS 服務器的SSL有效證書,在這里我們使用 adfs-server.adfs.com 作為域名示例。
3、對于 seafile 服務器的SSL有效證書,在這里我們使用 demo.seafile.com 作為域名示例。
準備證書文件
1、SP(Service Provider) 的 x.509 證書
可以通過以下方式獲取:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout sp.key -out sp.crt
x.509 證書用來簽署和加密諸如SAML的NameID和Metadata等元素。
然后將這兩個文件復制到 /seahub-data/certs。如果證書文件夾不存在,請創建它。
2、IdP(Identity Provider) 的 x.509 證書
登陸到 ADFS 服務器并且打開 ADFS 管理。
雙擊 Service 并選擇 Certificates。
導出 Token-Signing 證書:
右擊證書并選擇 View Certificate。
選擇 Details 選項卡。
單擊 Copy to File (選擇 DER encoded binary X.509)。
將此證書轉換為PEM格式,重命名為 idp.crt
復制它到 /seahub-data/certs。
準備 IdP 元數據文件
在 seafile 服務器上安裝
對于 Ubuntu 16.04
sudo apt install libxmlsec1
sudo pip install cryptography djangosaml2
配置seafile
添加以下配置到 seahub_settings.py
from os import path
import saml2
import saml2.saml
CERTS_DIR = '/seahub-data/certs'
SP_SERVICE_URL = 'https://demo.seafile.com'
XMLSEC_BINARY = '/usr/local/bin/xmlsec1'
ATTRIBUTE_MAP_DIR = '/seafile-server-latest/seahub-extra/seahub_extra/adfs_auth/attribute-maps'
SAML_ATTRIBUTE_MAPPING = {
'DisplayName': ('display_name', ),
'ContactEmail': ('contact_email', ),
'Deparment': ('department', ),
'Telephone': ('telephone', ),
}
ENABLE_ADFS_LOGIN = True
EXTRA_AUTHENTICATION_BACKENDS = (
'seahub_extra.adfs_auth.backends.Saml2Backend',
)
SAML_USE_NAME_ID_AS_USERNAME = True
LOGIN_REDIRECT_URL = '/saml2/complete/'
SAML_CONFIG = {
# full path to the xmlsec1 binary programm
'xmlsec_binary': XMLSEC_BINARY,
'allow_unknown_attributes': True,
# your entity id, usually your subdomain plus the url to the metadata view
'entityid': SP_SERVICE_URL + '/saml2/metadata/',
# directory with attribute mapping
'attribute_map_dir': ATTRIBUTE_MAP_DIR,
# this block states what services we provide
'service': {
# we are just a lonely SP
'sp' : {
"allow_unsolicited": True,
'name': 'Federated Seafile Service',
'name_id_format': saml2.saml.NAMEID_FORMAT_EMAILADDRESS,
'endpoints': {
# url and binding to the assetion consumer service view
# do not change the binding or service name
'assertion_consumer_service': [
(SP_SERVICE_URL + '/saml2/acs/',
saml2.BINDING_HTTP_POST),
],
# url and binding to the single logout service view
# do not change the binding or service name
'single_logout_service': [
(SP_SERVICE_URL + '/saml2/ls/',
saml2.BINDING_HTTP_REDIRECT),
(SP_SERVICE_URL + '/saml2/ls/post',
saml2.BINDING_HTTP_POST),
],
},
# attributes that this project need to identify a user
'required_attributes': ["uid"],
# attributes that may be useful to have but not required
'optional_attributes': ['eduPersonAffiliation', ],
# in this section the list of IdPs we talk to are defined
'idp': {
# we do not need a WAYF service since there is
# only an IdP defined here. This IdP should be
# present in our metadata
# the keys of this dictionary are entity ids
'https://adfs-server.adfs.com/federationmetadata/2007-06/federationmetadata.xml': {
'single_sign_on_service': {
saml2.BINDING_HTTP_REDIRECT: 'https://adfs-server.adfs.com/adfs/ls/idpinitiatedsignon.aspx',
},
'single_logout_service': {
saml2.BINDING_HTTP_REDIRECT: 'https://adfs-server.adfs.com/adfs/ls/?wa=wsignout1.0',
},
},
},
},
},
# where the remote metadata is stored
'metadata': {
'local': [path.join(CERTS_DIR, 'idp_federation_metadata.xml')],
},
# set to 1 to output debugging information
'debug': 1,
# Signing
'key_file': '',
'cert_file': path.join(CERTS_DIR, 'certs/idp.crt'), # from IdP
# Encryption
'encryption_keypairs': [{
'key_file': path.join(CERTS_DIR, 'certs/sp.key'), # private part
'cert_file': path.join(CERTS_DIR, 'certs/sp.crt'), # public part
}],
'valid_for': 24, # how long is our metadata valid
}
配置 ADFS 服務
添加 Relying Party Trust
Relying Party Trust 是 Seafile 和 ADFS 之間的連接。
登陸到 ADFS 服務器并打開 ADFS 管理界面。
雙擊 Trust Relationships,然后右鍵 Relying Party Trusts,選擇 Add Relying Party Trust…。
選擇 Import data about the relying party published online or one a local network,在 Federation metadata address 中輸入 https://demo.seafile.com/saml2/metadata/
然后 Next 直到 Finish。
添加 Relying Party Claim Rules
Relying Party Claim Rules 是用于windows域中seafile和用戶的通信。
Important:在windows域中的用戶必須要設置了 E-mail 值。
右鍵點擊 relying party trust 并且選擇 Edit Claim Rules…。
在 Issuance Transform Rules Add Rules…
選擇 Send LDAP Attribute as Claims 作為申請規則模版來用。
給 claim 一個名稱,例如:LDAP Attributes。
將 Attribute Store 設置為 Active Directory,LDAP Attribute 設置為 E-Mail-Addresses,Outgoing Claim Type 設置為 E-mail Address。
選擇 Finish。
再次單擊 Add Rule…。
選擇 Transform an Incoming Claim。
給它一個名字例如:Email to Name ID。
輸入的 claim 類型應該是 E-mail Address (它必須跟 rule #1 中的Outgoing Claim Type 相匹配)。
Outgoing claim 的類型是 Name ID (這是seafile配置策略中的要求 'name_id_format': saml2.saml.NAMEID_FORMAT_EMAILADDRESS)。
Outgoing name ID 格式為 Email。
通過所有的 claim 的值 并且單擊 Finish。
測試
重啟服務后,你可以打開一個web瀏覽器并且輸入 https://demo.seafile.com,在登陸對話框中應該有一個 adfs 按鈕。單擊該按鈕將重定向到 ADFS 服務器(adfs-server.adfs.com),如果用戶名密碼正確,你將被重定向到seafile主頁。
對于descktop客戶端,只需要在”Add a new account”窗口點擊”Shibboleth Login”,輸入 https://demo.seafile.com,單擊 OK 按鈕將會打開一個新的窗口顯示ADFS服務的登錄頁面,如果用戶名和密碼正確,窗口將關閉并顯示seafile資料庫面板。
總結
以上是生活随笔為你收集整理的ad文件服务器部署,AD 集成 – 配置 ADFS 登陆 - Seafile 服务器用户手册的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 快捷方式修复_Mac上的屏幕截图不起作用
- 下一篇: rc时间常数公式_你知道RC电路和RL电