Nextcloud
Nextcloud uses OkYouIn as its SAML 2.0 identity provider through the SSO & SAML
authentication app (user_saml). Users sign in on OkYouIn’s page with their password and
second factor and land in Nextcloud. For OkYouIn’s SAML IdP in general, see
SAML 2.0.
Verified on
Section titled “Verified on”| Product | Version | Modes | What was verified |
|---|---|---|---|
Nextcloud (Docker image nextcloud:34.0.5-apache), user_saml 8.5.0 | 34.0.5 | password + MFA | Sign-in with TOTP (local and Active Directory users); single sign-on into GitLab without a prompt; MFA asked again after the session lifetime; policy deny; single logout with OkYouIn confirmation; groups as SAML_<group>; signing Response and assertion; certificate rotation |
What works
Section titled “What works”- Second factor: TOTP was verified. Push and e-mail MFA were not tested with Nextcloud.
- Users and groups: the user ID, display name, e-mail and groups come from OkYouIn at every sign-in.
- Not supported: IdP-initiated sign-in (
user_samlneeds its own request) — keep IdP-initiated sign-in off. Making a SAML user a Nextcloud admin through a group is not possible (see below).
Before you start
Section titled “Before you start”- Nextcloud must be served over HTTPS. OkYouIn posts the SAML Response only to an
httpsACS URL. - OkYouIn’s public URL (Settings ▸ General) must be an
https://address. - Create the application in Access ▸ Applications ▸ Add application ▸ Nextcloud. The
template sends
uid(username),email,displayNameandgroups(multi-valued), NameID format Unspecified with the username as NameID value, signed with the global certificate. - The application’s SAML slug —
nextcloudin the examples — is part of every IdP URL. The Connect tab shows the commands with your real slug and host.
Configure
Section titled “Configure”-
Register Nextcloud in OkYouIn. The easiest way is to import its SP metadata: open
https://cloud.example.com/apps/user_saml/saml/metadata?idp=1in a browser, save it, and use Import SP metadata on the application’s Settings tab. Or enter the values by hand:Setting Value SP Entity ID https://cloud.example.com/apps/user_saml/saml/metadataACS endpoints https://cloud.example.com/apps/user_saml/saml/acsSP single logout URL https://cloud.example.com/apps/user_saml/saml/sls, binding HTTP-RedirectUse the URLs as the browser sees them.
occ saml:metadataprints/index.php/URLs, which do not match the requests of a Nextcloud with pretty URLs. -
Install and configure user_saml with
occ, run as the web server user (provider1on a fresh install). The IdP certificate is read straight from OkYouIn:Terminal window occ() { sudo -u www-data php /var/www/html/occ "$@"; }occ app:install user_samlocc config:app:set user_saml type --value=samlocc saml:config:createocc saml:config:set 1 \--general-idp0_display_name="OkYouIn" \--general-uid_mapping=uid \--idp-entityId="https://mfa.example.com/saml/nextcloud" \--idp-singleSignOnService.url="https://mfa.example.com/saml/nextcloud/sso" \--idp-singleLogoutService.url="https://mfa.example.com/saml/nextcloud/slo" \--idp-x509cert="$(curl -fsS https://mfa.example.com/saml/nextcloud/certificate.pem)" \--saml-attribute-mapping-email_mapping=email \--saml-attribute-mapping-displayName_mapping=displayName \--saml-attribute-mapping-group_mapping=groups \--sp-name-id-format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" \--security-wantAssertionsSigned=1 \--security-wantMessagesSigned=1 -
Allow the application in the policy.
Users and groups
Section titled “Users and groups”- The
uidattribute (the OkYouIn username) is the Nextcloud user ID. Display name and e-mail are updated at every sign-in. - Groups arrive as
SAML_<group>(user_saml’s group mapping prefix). Use Groups filter on the application to limit which groups are sent. user_samlnever puts a SAML user into Nextcloud’sadmingroup. Grant administration in Nextcloud (admin delegation) to aSAML_group instead.
Signatures
Section titled “Signatures”Keep Sign at Response and assertion together with wantMessagesSigned=1 and
wantAssertionsSigned=1. Nextcloud refuses a Response that lacks a signature it wants, with
“Account not provisioned”. The other two signing modes work only with the matching want… flag
turned off.
Certificate rotation
Section titled “Certificate rotation”Nextcloud holds exactly one IdP certificate and does not read metadata. After Activate
next in OkYouIn, sign-ins fail until Nextcloud has the new certificate, so run the
--idp-x509cert line again right after activating:
occ saml:config:set 1 --idp-x509cert="$(curl -fsS https://mfa.example.com/saml/nextcloud/certificate.pem)"To keep a rotation of the global certificate from touching Nextcloud, switch the application to its own certificate (Signing certificate ▸ Own certificate) and rotate it when it suits you.
Sign-out
Section titled “Sign-out”Nextcloud’s Log out sends a LogoutRequest. OkYouIn asks “Sign out?” (the request is unsigned), ends its session and returns to Nextcloud. Other applications of the same SSO session stay signed in — OkYouIn does not propagate a logout to them. Revoking a session in Logging ▸ SSO sessions makes the next sign-in ask for the password, but does not end a Nextcloud session that is already open.
Verify
Section titled “Verify”- In a private window, open Nextcloud and choose OkYouIn; sign in with password and code.
- In Nextcloud, check the user’s display name, e-mail and
SAML_groups. - Logging ▸ SSO sign-in log shows the SAML sign-in with the MFA round and the allow.
- Preview for a user on the application shows the NameID and attributes a user would get, without signing in.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause |
|---|---|
| ”Account not provisioned” | Nextcloud’s message for every refused Response: a missing signature it wants, a policy deny, or a certificate mismatch. Check the SSO sign-in log first. |
| OkYouIn refuses the request (bad request, issuer) | The SP Entity ID in OkYouIn has /index.php/ while Nextcloud sends the pretty URL, or the other way round. Import the metadata from the browser URL. |
| Sign-ins fail right after a rotation | Nextcloud still holds the old certificate. Re-run the --idp-x509cert line. |
| IdP-initiated sign-in lands on the login page | Not supported by user_saml. Turn IdP-initiated sign-in off. |