update: Keycloak SAML 2.0 in 12.0
|
|
@ -33,7 +33,7 @@ $ openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout sp.key -out sp.cr
|
|||
!!! tip "The `days` option indicates the validity period of the generated certificate. The unit is day. The system admin needs to update the certificate regularly"
|
||||
|
||||
|
||||
## Integration with ADFS/SAML single sign-on
|
||||
## Integrate with Identity Provider
|
||||
|
||||
### Example 1: Microsoft Azure SAML single sign-on app
|
||||
|
||||
|
|
@ -196,3 +196,110 @@ SAML_REMOTE_METADATA_URL = 'https://temp.adfs.com/federationmetadata/2007-06/fed
|
|||
|
||||
|
||||
### Example 3: Keycloak SAML 2.0
|
||||
In this part, we use Keycloak SAML single sign-on app to show how Seafile integrate SAML 2.0. And If you are deploying Seafile in a Docker environment, please refer to this part.
|
||||
|
||||
#### Preparations for SAML 2.0
|
||||
prepare SP(Seafile) certificate directory and SP certificates:
|
||||
|
||||
Create certs dir:
|
||||
|
||||
The default deployment path for Seafile is **/opt/seafile**, and the corresponding default path for seafile-data is **/opt/seafile-data**. If you do not deploy Seafile to this directory, you can check the **SEAFILE_VOLUME** variable in the env to confirm the path of your seafile-data.
|
||||
|
||||
```sh
|
||||
cd /opt/seafile-data/seafile/seahub-data
|
||||
mkdir certs
|
||||
|
||||
```
|
||||
|
||||
The SP certificate can be generated by the openssl command, or you can apply to the certificate manufacturer, it is up to you. For example, generate the SP certs using the following command:
|
||||
|
||||
```sh
|
||||
cd certs
|
||||
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout sp.key -out sp.crt
|
||||
|
||||
```
|
||||
|
||||
The `days` option indicates the validity period of the generated certificate. The unit is day. The system admin needs to update the certificate regularly.
|
||||
|
||||
#### Keycloak SAML single sign-on app
|
||||
|
||||
If you use Keycloak SAML app to achieve single sign-on, please follow the steps below:
|
||||
|
||||
The test domain name here is exemplified by `https://demo.seafile.top`.
|
||||
|
||||
**First**, Create a new Client:
|
||||
|
||||
* Client type: Choose `SAML`;
|
||||
|
||||
* Client ID: Fill in the SAML metadata address of Seafile (e.g.,**https://demo.seafile.top/saml2/metadata/**)
|
||||

|
||||
|
||||
* Root URL and Home URL: Root Directory/Homepage, fill in the Seafile web service address (e.g.,**https://demo.seafile.top/**)
|
||||
|
||||
* Valid redirect URIs: Valid Redirect URIs, fill in all URLs of the Seafile web service (e.g.,**https://demo.seafile.top/***)
|
||||

|
||||
|
||||
**Next**, open the client you just created and make the following modifications; leave all other settings as default.
|
||||
|
||||
* Settings - SAML capabilities: Set the **Name ID Format** to **email**, and only keep **Include AuthnStatement** enabled, disable all other settings.
|
||||

|
||||
|
||||
* Settings - Signature and Encryption: The default encryption algorithm is RSA_SHA256, so no changes are required.
|
||||

|
||||
|
||||
* Keys : Confirm that the Signing keys config is in the disabled state.
|
||||

|
||||
|
||||
* Client scopes: Configure the protocol mapping to map user information.
|
||||

|
||||
|
||||
**Next**, choose the custom configuration **By configuration**:
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
**Next**, ensure that the above two attributes are added. After adding them, the result is as follows:
|
||||

|
||||
|
||||
* Advanced - Fine Grain SAML Endpoint Configuration
|
||||
|
||||
* Assertion Consumer Service POST Binding URL: Send the SAML assertion request to the SP using the POST method, and set it to the SAML ACS address of Seafile (e.g.,**https://demo.seafile.top/saml2/acs/**).
|
||||
|
||||
* Assertion Consumer Service Redirect Binding URL: Send the SAML assertion request to the SP via the redirect method, and set it to Seafile's SAML ACS address (same as the Assertion Consumer Service POST Binding URL).
|
||||
|
||||
* Logout Service POST Binding URL: The address for sending a logout request to the SP via the POST method. Fill in the SAML logout POST address of Seafile (e.g.,**https://demo.seafile.top/saml2/ls/post/**).
|
||||
|
||||
* Logout Service Redirect Binding URL: The address for sending a logout request to the SP via the redirect method. Fill in Seafile's SAML logout address (e.g.,**https://demo.seafile.top/saml2/ls/**).
|
||||

|
||||
|
||||
* Advanced - Authentication flow overrides: Bind the authenticator (the default account-password login uses the `Browser` flow).
|
||||

|
||||
|
||||
#### Seafile configuration
|
||||
|
||||
```sh
|
||||
cd /opt/seafile-data/seafile/conf/
|
||||
vim seahub_settings.py
|
||||
|
||||
|
||||
ENABLE_ADFS_LOGIN = True
|
||||
#SAML_CERTS_DIR is a path inside the container and does not need to be changed.
|
||||
SAML_CERTS_DIR = '/opt/seafile/seahub-data/certs'
|
||||
#The configuration format of SAML_REMOTE_METADATA_URL is '{idp_server_url}/realms/{realm}/protocol/saml/descriptor'
|
||||
#idp_server_url: The URL of the Keycloak service
|
||||
#realm: Realm name
|
||||
SAML_REMOTE_METADATA_URL = 'https://keycloak.seafile.com/realms/haiwen/protocol/saml/descriptor'
|
||||
SAML_ATTRIBUTE_MAPPING = {
|
||||
'name': ('display_name', ),
|
||||
'mail': ('contact_email', ),
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
**Finally**, open the browser and enter the Seafile login page, click Single Sign-On, and use the user assigned to SAML app to perform a SAML login test.
|
||||

|
||||
|
|
|
|||
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 184 KiB |
|
After Width: | Height: | Size: 177 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 226 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 175 KiB |
|
After Width: | Height: | Size: 696 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 164 KiB |