这里是 nextcloud 15/16 的略微更新版本:
打开浏览器并转到 https://kc.domain.com 。单击管理控制台。正如您在 docker-compose.yml 中指定的那样,用户名和密码是 admin。
在页面的左上角,您需要创建一个新领域。单击添加。输入 my-realm 作为名称。点击保存。
单击“键”选项卡。查看 RSA 条目。我们将需要复制该行的证书。单击证书并将内容复制粘贴到文本编辑器以供以后使用。
为 Nextcloud 准备私钥和证书
打开终端并发出:
openssl req -nodes -new -x509 -keyout private.key -out public.cert
这将创建两个文件:private.key 和 public.cert,我们稍后将需要它们用于 nextcloud 服务。
配置 Nextcloud
打开浏览器并转到 https://nc.domain.com 。正如您在 docker-compose.yml 中指定的那样,用户名和密码是 admin。
您需要激活默认禁用的 SSO 和 Saml Authenticate。
重要提示 从这里开始,在测试并运行设置之前不要关闭当前的浏览器窗口。如果您在一切正常之前关闭浏览器,您可能无法再更改 nextcloud 中的设置。在这种情况下,您需要停止 nextcloud- 和 nextcloud-db-container,删除它们各自的文件夹,重新创建它们并重新开始。
单击右上角的齿轮符号,然后单击 + 应用程序符号。现在在左侧看到一个带有条目安全性的菜单栏。点击它。您现在可以看到所有安全相关的应用程序。单击 SSO 和 SAML 身份验证应用下方的激活按钮。
再次单击右上角的齿轮符号,然后单击管理员。单击 SSO 和 SAML 身份验证。
使用以下值:
Attribute to map UID to:username
Enable "Use SAML auth for the Nextcloud desktop clients (requires user re-authentication)"
Copy the content ofpublic.cert into the 'X.509 Certificate'-field
Copy the content ofprivate.key into the 'Private key of Service Provider'-field.
Identifier of the IdP: https://kc.domain.com/auth/realms/my-realm
URL Target of the IdP where the SP will send the Authentication Request Message: https://kc.domain.com/auth/realms/my-realm/protocol/saml
URL Location of IdP where the SP will send the SLO Request: https://kc.domain.com/auth/realms/my-realm/protocol/saml
Public X.509 certificate of the IdP: Copy the certificate from Keycloak from the Keys-tab of my-realm. You will need to add '-----BEGIN CERTIFICATE-----' in front of the key and '-----END CERTIFICATE-----' to the end of it.
In Identity Provider Data:
Attribute, displayname: username
Attribute, email adress: email
Attribute, Quota: nextcloudquota
Click Download metadata XML and save the file for the next step.
Security Settings, enable the following options:
Indicates whether the messages sent by this SP will be signed. [Metadata of the SP will offer this info]
Indicates whether the messages sent by this SP will be signed.
Indicates whether the messages sent by this SP will be signed.
Indicates a requirement for the , and elements received by this SP to be signed.
Indicates a requirement for the elements received by this SP to be signed. [Metadata of the SP will offer this info]
Check there is a Metadata valid beside the Download metadata XML-Button
Click the Download metadata XML-Button. This generate and send a XML file. Save it.
配置 Keycloak,客户端
再次访问管理员控制台。单击客户端,然后单击右上角的创建按钮。
在导入旁边,单击选择文件按钮。选择您在 Nextcloud 的最后一步中创建的 XML 文件。
变化:
Client SAML Endpoint: https://kc.domain.com/auth/realms/my-realm
然后点击保存。
您将看到一个新屏幕。更改以下字段:
Name: Nextcloud
Valid Redirect URIs: https://nc.domain.com/ *
Click Save
在选项卡上很重要:
Click Delete-Button on the preassigned role list
Click Create
Name: username
Mapper Type: User Property
Property: username
SAML Attribute Name: username
SAML Attribute NameFormat: Basic
Click Save
Click Create
Name: email
Mapper Type: User Property
Property: email
SAML Attribute Name: email
SAML Attribute NameFormat: Basic
Click Save
点击创建
Name: Roles
Mapper Type: Role List
Role attribute name: Roles
Friendly Name: roles
SAML Attribute NameFormat: Basic
Single Role Attrubute: On
Click Save
点击创建
Name: nextcloudquota
Mapper Type: User Property
Property: nextcloudquota
SAML Attribute Name: nextcloudquota
SAML Attribute NameFormat: Basic
Click Save
配置Keycloak,添加用户
On the left side, click on Users
On the top-right, click Add users
Set the following values:
Username: user
Email: user@domain.com
Click Save
On the tab Credentials:
New Password: user
Password Confirmation: user
Temporary: Off
Click Reset Password
A Window pops up:
Click Change Password