How Keycloak and Nextcloud SSO work together through user_oidc
Organizations running self-hosted Nextcloud that want Keycloak as the single sign-on source use OpenID Connect through the user_oidc app, with Keycloak acting as the identity provider. Nextcloud signs users in by redirecting them to Keycloak, receives the resulting tokens, and creates or updates the local Nextcloud account from the claims in those tokens. Nextcloud's documentation describes OpenID Connect as one of its user authentication backends, alongside its LDAP and SAML options, so the design decision is which backend should own sign-in for each group of users. The integration covers interactive sign-in, automatic user and group provisioning from token claims, soft provisioning for users who already exist in an LDAP or Active Directory directory, bearer token validation for API requests, and backchannel logout so that a session ended in Keycloak also ends in Nextcloud. Each of these depends on claims and client settings that must match between the two systems, so the Keycloak client, its scopes and mappers should be planned together with the Nextcloud side rather than configured afterward.
The integration does not cover Nextcloud's own administration, storage, backup, or app governance, and it does not replace the need to plan which Nextcloud app versions are compatible with the release you run. It also does not decide how Keycloak itself is hosted, which database backs it, or how its high availability is designed; those belong to the Keycloak deployment and high availability topics. Before any configuration, confirm the exact user_oidc settings, claim names and option keys against the app documentation for the Nextcloud version in use, because user_oidc behavior can differ between releases. This page does not list configuration keys, and any key you find in older guides or forum posts should be checked against current documentation first. Nextcloud 35 is the release currently supported with a published end of life of September 2027, so confirm the app's compatibility with that line in the Nextcloud maintenance and release schedule before you commit to a version.
What you need before connecting Nextcloud to Keycloak
Six areas need to be settled before the user_oidc app is configured: the identity provider, the Nextcloud line, the database, the directory, the recovery plan and the trust between browsers, Keycloak and Nextcloud. Each one has an owner, and a gap in any of them usually shows up later as a failed login or an upgrade that cannot be rolled back.
A running Keycloak realm
Confirm that Keycloak is already in production shape, not a development instance. The current release is 26.8.1, and the production guide calls for TLS on all communication, a reverse proxy with path restrictions, and the admin console and Administration REST API on a hostname or context path separate from public frontend URLs. Ask the identity team to confirm the realm that will hold Nextcloud users and the owner of its client registration. Identity platform team owns this.
Production guideA supported Nextcloud line
Choose the Nextcloud major version before building anything, because the upgrade path depends on it. Nextcloud 35 was released on 16 September 2026 and ends in September 2027, Nextcloud 34 is supported until June 2027, and Nextcloud 33 until February 2027. Confirm that the user_oidc app version you plan to use supports the chosen line, and that no older server is left running on a line that is near end of life. Application owner confirms the version.
Release scheduleA supported database
Nextcloud 35 recommends MariaDB 11.8 or PostgreSQL 18, and also supports several older and newer versions. Oracle Database is available only with an enterprise subscription. Confirm the database version against the system requirements page before installation, and confirm that the database is backed up and reachable from every Nextcloud node. The database holds user and group records that the SSO mapping depends on, so its health affects sign-in directly. Database team owns the instance, Nextcloud team owns the requirement.
System requirementsAn LDAP or Active Directory source
Skip this card if users will exist only in Keycloak. If soft provisioning for existing directory users is planned, confirm which directory holds the accounts, which attribute uniquely identifies each user, and whether Keycloak already federates that directory. The directory owner should confirm that a read-only service account is available for the bind. Decide early whether a user who exists in LDAP but not yet in Keycloak can sign in, because that decision shapes the provisioning design. Directory team owns the service account and attributes.
LDAP user authenticationA backup and upgrade plan
Nextcloud does not allow skipping major releases, so each upgrade moves one major version at a time, and third-party apps must be disabled until they are confirmed compatible. Before the first sign-in test, confirm who takes a backup before every upgrade, where it is stored, how a restore is tested, and who approves app compatibility. Keycloak changes, such as a client secret rotation, should be recorded in the same change log so a restore can be matched to the identity configuration. Operations team owns the backups, application owner signs off on upgrades.
Upgrade manualNetwork and certificate trust
Three parties must trust each other: the browser must reach Nextcloud and Keycloak over HTTPS, Nextcloud must reach Keycloak's discovery and token endpoints from the server side, and Nextcloud must trust the certificate authority that signed Keycloak's certificate. Confirm firewall rules for those paths, the public hostnames used in redirect URIs, and whether internal DNS resolves the Keycloak hostname the same way for the browser and the Nextcloud servers. Mismatched hostnames are a common cause of failed redirects. Network team and PKI owner confirm the paths and trust store.
How a Nextcloud login flows through Keycloak
The login starts in the user's browser, which is redirected to Keycloak to authenticate. Keycloak checks credentials itself or passes them to the directory behind it, then returns an authorization code that the user_oidc app on Nextcloud exchanges for tokens over a server-to-server call. Nextcloud reads the claims to create or update the local account and its groups. Check that the browser path and the back-channel path both use the hostnames you expect, and that logout notifications from Keycloak reach Nextcloud directly.
Illustrative flow of the Nextcloud sign-in and logout paths, not a configuration reference.
Keycloak and Nextcloud SSO setup, step by step
This sequence takes a Keycloak realm from a dedicated client to a tested Nextcloud sign-in, with each step closed by a check you can run before moving on. The order matters because the claims Keycloak sends decide how Nextcloud names and groups users.
Confirm or create the Keycloak realm
The Keycloak administrator decides whether Nextcloud uses an existing realm or a dedicated one. A dedicated realm keeps Nextcloud client settings, token lifetimes and login policies separate from other applications. Record the realm name and its OpenID Connect discovery URL, which normally ends in the well-known configuration path for the realm. Done when the discovery URL opens in a browser and returns a JSON document listing the issuer, authorization and token endpoints.
Create a confidential OpenID Connect client
In the realm, create a client for Nextcloud with client authentication enabled so Keycloak issues a client secret. Set the valid redirect URI to the callback path that the user_oidc app documents, built from the public Nextcloud hostname and not an internal address or a load balancer name. Store the secret in your secrets manager. Done when the client appears in the realm with the expected redirect URI and the secret is saved outside the client settings page.
Add the groups and identifier claims
Add a mapper to the client that places group membership into the ID token or userinfo response under a claim name you choose, and add any attribute mappers your account model needs, such as email, display name or a stable username. Keep the claim names consistent with what you will enter in Nextcloud. Done when a test sign-in with a Keycloak user produces a token that, decoded in a token inspector, shows the groups claim and the identifier claim with the expected values.
Install and enable the user_oidc app
A Nextcloud administrator installs the user_oidc app from the Nextcloud app store or through the occ command line tool, then enables it. Check that the app version is compatible with your Nextcloud release before enabling it, because third-party apps can block upgrades. Done when the app appears as enabled in the admin apps list and the Nextcloud admin settings show a new OpenID Connect section.
Register Keycloak as the provider
In the Nextcloud admin settings for user_oidc, add Keycloak as a provider using the discovery URL, client identifier and client secret from the earlier steps. Exact setting names and any provisioning options come from the user_oidc documentation, so confirm them against the version you installed. Done when Nextcloud shows the provider as configured and a sign-in button for Keycloak appears on the Nextcloud login page.
Map the user identifier and group claims
Set the claim Nextcloud uses as the user identifier, and set the claim that carries group membership so that user_oidc can create or update groups from it. Choose an identifier that does not change when a display name changes. Done when a Keycloak user who signs in receives a Nextcloud account whose identifier matches the chosen claim and whose group membership matches the groups assigned in Keycloak.
Test sign-in with a non-admin account
Sign in as a standard Keycloak user who is not in any administrative group, and confirm the account is created in Nextcloud with the expected groups and quota. Repeat with a second user in a different group. Also verify that file access and sharing behave as expected for that user. Done when both test accounts sign in, appear under the correct groups in the Nextcloud user list, and cannot reach admin pages.
Restrict login only after testing succeeds
Once the test accounts work, decide whether to restrict sign-in to a group, disable the local login path for ordinary users, or keep a local administrator for recovery. Make one change at a time and sign in again after each. Keep at least one tested recovery path before disabling local login. Done when a restricted user is refused and an authorized user signs in, and the recovery path has been tested and documented.
How provisioning from token claims and LDAP soft provisioning fit together
Automatic provisioning from token claims means Nextcloud builds or updates the account from the claims Keycloak sends at sign-in. With the user_oidc app, you map claims such as preferred_username, email and a display name to Nextcloud user fields, and you map a groups claim to Nextcloud group membership. The group claim is only as current as the last token Nextcloud received, so a user removed from a Keycloak group may keep that access until a new token arrives. Confirm in the user_oidc documentation for your version whether accounts are created at first sign-in, how often attributes and groups refresh, and what happens to memberships that disappear from the claim. Then make sure the Keycloak client scope and mappers put the group claim in every token Nextcloud requests.
Soft provisioning addresses people who already exist in LDAP or Active Directory and are read into Nextcloud by the LDAP app. The aim is to link the Keycloak sign-in to that existing Nextcloud account so that files, shares and history stay with one user, instead of letting a first Keycloak login create a second account. Confirm in the user_oidc and LDAP documentation which setting controls this linking and which attribute Nextcloud matches on. The LDAP app can also let users sign in with directory credentials, so decide whether that password path stays open alongside Keycloak. Two login paths for one account widen the attack surface and complicate offboarding.
Choose the stable key before the first login. Usernames and email addresses are convenient, but both change through renames, domain moves and directory cleanup. If Nextcloud matches on a value that changes, the same person can appear as a new user, and a reused value can attach a sign-in to the wrong account. Prefer an identifier that the directory and Keycloak do not reassign, and confirm which claim the user_oidc app can use as the unique identifier in your setup. Group membership needs one owner. If LDAP groups and token group claims both write to the same Nextcloud groups, the two sources can disagree, and whichever update runs last wins in ways that are hard to audit. Record one source of truth for each group, usually the directory or Keycloak, before go-live.
Mapping Keycloak claims and groups to Nextcloud accounts
This table compares each Nextcloud account attribute or behavior with the Keycloak token claim, group, attribute or directory field that feeds it, along with who owns the value and what breaks if it changes. Read each row before configuring the client scope and user_oidc settings, because a change on the Keycloak side can silently alter accounts, quotas and admin rights in Nextcloud. Exact claim names and mapper types are confirmed during the build.
| Nextcloud attribute or behavior | Keycloak source | Owner | What breaks if it changes |
|---|---|---|---|
| Unique user identifier | Stable subject or chosen username claim (for example, preferred_username), set through a token mapper in the client scope | Identity team, with the Nextcloud admin confirming the choice | Existing accounts stop matching and Nextcloud may create duplicate users with new data folders and shares |
| Display name | Name claim (for example, name) mapped through the user_oidc attribute settings | Identity team for the source value, Nextcloud admin for the mapping | Display names revert or blank out for all users at next login, which affects sharing lists and audit readability |
| Email address | Email claim with the email_verified status the client scope passes through | Identity team, with mail administrator confirming delivery needs | Notification and password-reset flows fail, and an edited address can route shared-file notices to the wrong person |
| User quota, if set from a claim | Custom user attribute or claim mapped to a quota value, only if the organization chooses this design | Identity team defines the attribute, storage administrator sets the policy | Users may lose access to storage above a reduced quota or receive unlimited space if the claim is empty or malformed |
| Group membership | Groups claim built from Keycloak group membership, using a group mapper that returns group names or paths as the setting requires | Identity team owns the groups, application owner approves which groups Nextcloud reads | Users lose or gain group-based shares and app access, and renamed or moved groups can remove access without warning |
| Admin group designation | A specific Keycloak group named in the admin group setting of the Nextcloud OIDC configuration | Security team approves membership, Nextcloud admin owns the setting | Admin rights can be granted to a wrong group or removed from every administrator, and a broad group name can expose admin access to too many users |
| LDAP-linked identity for soft provisioning | Directory user identifier that Keycloak federates from LDAP or Active Directory, carried as a claim so the existing Nextcloud LDAP account is matched | Directory team owns the source attributes, identity team owns the federation mapping | Soft provisioning links the wrong account or creates a second one, and changes to the directory attribute used for matching can break sign-in for existing users |
Security settings for Nextcloud sign-in through Keycloak
Signing Nextcloud users in through Keycloak moves trust decisions into two systems. The cards below cover the settings that connect them: how the client secret is held, how traffic is encrypted, how API tokens are checked, how sessions end together, where administration lives and how you recover if the identity provider is unavailable.
Confidential client secret handling
The Nextcloud client in Keycloak should be a confidential client, so the client secret is needed at the token exchange. Decide where the secret lives so it is not written into the Nextcloud configuration file in plain text, for example in a secrets store or an environment source your platform controls. Document who can read it, how it is rotated, and how Nextcloud and Keycloak are updated in the same change window so sign-in does not break during rotation.
TLS on every hop
Keycloak's production guide calls for TLS on all communication. Confirm that the Nextcloud hostname, the Keycloak hostname and the reverse proxy in front of each both use valid certificates, and that the redirect URIs and issuer URL in the Nextcloud configuration match the HTTPS addresses exactly. Mixed HTTP and HTTPS URLs are a common cause of failed sign-in and of tokens being sent over unencrypted paths.
Keycloak production guideBearer token validation for API calls
Clients that call Nextcloud APIs with bearer tokens depend on Nextcloud checking the token signature and audience before it accepts the request. Confirm with your own tests that Nextcloud rejects tokens signed by an unexpected key, issued for a different client or intended for another audience. Keep token lifetimes short enough that a stolen token has limited use, and test a revoked session to see how quickly API access stops.
Backchannel logout behavior
Backchannel logout lets Keycloak tell Nextcloud to end its sessions when a Keycloak session ends. The Keycloak 26.8 upgrade notes make signature validation of backchannel logout tokens from external providers mandatory, so confirm that your Nextcloud user_oidc setup accepts only logout tokens Keycloak signs. Test logout from one application and check that the Nextcloud session is closed, including for sessions that were already idle.
Keycloak upgrading guideSeparate administration endpoints
The production guide recommends exposing the Keycloak admin console and Administration REST API on a different hostname or context path from public frontend URLs. Decide which network paths reach the admin hostname, restrict them to administrator networks or VPN access, and confirm that the public hostname returns no admin pages. Nextcloud sign-in itself does not need admin access, so keep these routes out of the public reverse proxy rules.
Tested break-glass administrator
Keep a local administrator account in Nextcloud that does not depend on Keycloak, so an administrator can still sign in if the identity provider, its certificate or the OIDC configuration fails. Store its credentials under your emergency access process, limit who can use it, and test it before go-live by signing in with Keycloak disabled in a non-production copy. Record who approved the test and when the account was last used.
Testing bearer tokens and backchannel logout before go-live
Test the integration end to end before any user depends on it. Start with browser sign-in for one test user from each group that the Keycloak client and mappers expose to Nextcloud. For each sign-in, confirm that the user is created in Nextcloud with the expected display name and email, that the group memberships match the groups claim you configured, and that the user lands in the Nextcloud groups you intended. Repeat with a user who is in no group, and with an existing LDAP user if you use soft provisioning, because that path behaves differently from a new account. Check the claim values in the token itself, not only in the Nextcloud user record, so a mapping error is caught at the source. Keep a short written log of which user, group and expected result you tested so the same checks can be repeated after every change.
Next, test the API path that the user_oidc app is expected to support. Request a token from Keycloak for a test user and call a Nextcloud API endpoint with it as a bearer token. Then repeat the call with a token that has expired, and with a token whose aud value does not match the client Nextcloud expects. Both failing calls should be rejected. If the wrong-audience token is accepted, the validation settings are too loose and must be fixed before go-live. For logout, sign in to Nextcloud, end the Keycloak session through the Keycloak account or admin console, and confirm that the Nextcloud session is closed when you next use it. Confirm that backchannel logout is configured as your design requires, and check that the Keycloak logout URL and the Nextcloud settings match the values in your environment, since the exact fields depend on the app version you deploy.
Rehearse the upgrade before you need it. Nextcloud requires a backup before every upgrade and does not allow skipping major releases, so restore a copy of the production database and data directory into a test environment, then run the upgrade path one major version at a time with third-party apps disabled. Check that user_oidc still signs users in, that provisioning and the bearer token tests still pass, and that logout still behaves as expected. Confirm the supported Nextcloud and database versions against the Nextcloud upgrade manual for the target release. After launch, enable Keycloak metrics at /metrics with --metrics-enabled=true on the management interface and watch for rising sign-in failures, so a broken claim or expired client secret shows up quickly rather than through user reports.
Keycloak and Nextcloud SSO failures and fixes
This table pairs common Keycloak and Nextcloud sign-in symptoms with their likely causes and the first check to run for each. Read it by matching the symptom you see, then working through the cause and check in order, since several symptoms share a root cause such as the public URL or the token contents.
| Symptom | Likely cause | Fix and check to run |
|---|---|---|
| Redirect URI mismatch after a hostname or proxy change | The Keycloak client's valid redirect URIs still point at the old Nextcloud hostname, or the scheme differs from what the browser sees | Compare the redirect URI registered on the Keycloak client with the callback URL shown in the Nextcloud user_oidc provider settings, character for character, including https and any path prefix. Update both sides together. |
| Account created twice after sign-in | The identifier claim sent by Keycloak changed (for example from username to email), or soft provisioning did not match the existing LDAP user to the same identifier | Check which claim user_oidc uses as the unique identifier and confirm it is stable for each user. Review the duplicate accounts and the LDAP user attribute they map to before merging or deleting anything. |
| Groups not applied after sign-in | The groups claim is absent from the ID token or userinfo response, or the group mapper sits in a client scope the Nextcloud client does not request | Decode a test token from the Nextcloud login and confirm the groups claim is present. Check the mapper's token claim name and that its client scope is assigned to the Nextcloud client as a default or requested scope. |
| Bearer API calls rejected | The token audience does not include the Nextcloud client, the signature cannot be verified against the realm keys, or the issuer in the token does not match the configured discovery URL | Inspect the access token's aud, iss and signing algorithm. Add an audience mapper for the Nextcloud client if it is missing, and confirm Nextcloud fetches keys from the same realm discovery endpoint that issued the token. |
| Logout does not end the Nextcloud session | Backchannel logout is not configured on the Keycloak client, the logout URL is unreachable from Keycloak, or the Nextcloud session is kept by a separate cookie or browser session | Confirm the backchannel logout URL on the client points to a URL Keycloak can reach over the network, and test it with a single session. Check the Nextcloud logs for rejected logout tokens and confirm the logout token signature validates. |
| Login loop behind a reverse proxy | The proxy does not forward the public scheme and host, so Nextcloud generates http or internal URLs and the redirect cycle never completes | Check the trusted proxy and overwrite settings in the Nextcloud configuration and confirm the proxy sends the forwarded protocol and host headers. Compare the redirect URLs in the browser with the public address users type. |
| Sign-in fails after a Nextcloud upgrade | The user_oidc app was disabled or incompatible after a major upgrade, or a third-party app that handled login was not confirmed compatible | Check the app status in the Nextcloud admin apps list and review the upgrade log. Re-enable the authentication app only after confirming its version supports the new release, and keep a backup before retrying. |
| Sign-in fails after a Keycloak upgrade | A change in the Keycloak release altered client settings, token contents, or default scopes that Nextcloud depends on | Review the Keycloak upgrade notes for the release you moved to, then compare the client configuration, mappers and scopes with a known working copy. Test sign-in with a non-admin account before reopening access to users. |
What Keycloak and Nextcloud SSO work costs and requires
What drives the effort of a Keycloak and Nextcloud SSO integration?
The main drivers are the number of groups and claim rules you map, whether an existing LDAP or Active Directory directory must be matched through soft provisioning, how the reverse proxy and TLS are set up on both sides, how many Nextcloud apps interact with login, and the upgrade path you plan to follow.
- Group and claim rules: each group that controls quota, sharing or admin rights adds mapping, and each rule needs test cases.
- Existing directory: matching LDAP users to OIDC identities needs an extract to compare and a decision on which identifier wins.
- Network and TLS: both Keycloak and Nextcloud must reach each other over HTTPS with consistent hostnames and redirect URIs.
- Apps and upgrades: third-party apps must be checked for login behavior, and Nextcloud majors must be applied one at a time, so the plan should cover future upgrades as well as the first sign-in.
Can our own team set up Keycloak and Nextcloud SSO without a partner?
Yes, if your team already administers both Keycloak and Nextcloud and has time to build a test environment and test each login path. The work is mostly configuration: a Keycloak client, claim mappers and group rules, then the user_oidc app configured in Nextcloud. The parts that usually need extra care are soft provisioning for existing LDAP users, bearer token validation for API clients, and backchannel logout, because mistakes there can lock users out or leave sessions open. Confirm that you can run a full test cycle, including a rollback, before you cut over production users.
What does the client need to provide for this integration?
Plan to name a Keycloak owner and a Nextcloud owner who can make changes and sign off on them. Also prepare a test group set that covers each role and quota level, a directory extract if LDAP or Active Directory users must match existing accounts, and access to your change control process with agreed maintenance windows. Access to the Keycloak realm and Nextcloud admin account in a non-production environment is needed for testing. Ask your partner or internal team to list these inputs in the written scope so that testing and cutover dates depend on them being ready.
Does Nextcloud Enterprise have to be licensed for Keycloak login?
Confirm this before you commit, using the Nextcloud documentation and the user_oidc app listing for your target version, because the answer depends on the app and release you deploy. Nextcloud Enterprise is sold in Standard, Premium and Ultimate tiers with a 100-user minimum, according to the Nextcloud pricing page, and the tiers differ in maintenance length, support hours and response times. Those differences affect how long you can stay on a release and who you call when login fails, so include them in your decision even if the login method itself is available in the community edition.
How do supported Nextcloud and Keycloak versions affect the plan?
Version support sets the window in which you can test and run the integration. Nextcloud publishes a new major version every four months and supports each for one year, and Nextcloud does not allow skipping major releases during upgrades. Keycloak ships four minor releases a year, and its 26.8 upgrade notes change behavior such as enforced SMTP StartTLS and mandatory signature validation of backchannel logout tokens from external providers. Check the current support dates for both products, choose a pair that will still be supported through your planned operating period, and test backchannel logout after every Keycloak upgrade.
Does DeployOpen give a price or timeline for this integration?
DeployOpen does not publish a price list. Most engagements are fixed-scope, so the quote follows from a written scope that lists the groups and claim rules, the directory situation, the apps in use, the environments to build and the testing and handover you need. Agreeing that scope in writing before work starts is what sets the cost and the schedule. Ongoing support, upgrades and continuous testing are available as retainers, so ask for those to be quoted separately from the initial build.
What should we verify before a production cutover?
Verify each login path with test accounts: browser sign-in for new users, existing LDAP users matched by soft provisioning, group-based quota and admin rights, bearer token access for clients that use it, and backchannel logout that ends the Nextcloud session when the user signs out in Keycloak. Confirm that TLS is enforced end to end and that the Keycloak admin console is not exposed on the public hostname, as Keycloak's production guidance recommends. Keep a documented local admin path in Nextcloud and a rollback plan for the configuration before cutover.
How DeployOpen scopes and delivers Keycloak and Nextcloud SSO
DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, so the Keycloak and Nextcloud SSO integration runs in your cloud accounts, data centers or air-gapped network. The work is agreed as a fixed-scope engagement with written deliverables before any configuration begins.
How we scope
- Confirm which Keycloak realm, Nextcloud instance and user sources (Keycloak users, LDAP or Active Directory) the written scope covers.
- Record the claims, groups and roles that must drive Nextcloud group membership and admin rights, and who approves that mapping.
- Agree in writing whether soft provisioning for existing LDAP users, bearer token validation and backchannel logout are in scope, with deliverables and timelines.
How we build
- Configure the Keycloak client, scopes and mappers, then install and configure the user_oidc app in a staging Nextcloud before production.
- Test first sign-in, provisioning from token claims, group mapping, token validation and logout across the browser, desktop and mobile sync clients.
- Verify that the Nextcloud upgrade path, backups and third-party app compatibility are handled before the SSO change goes live.
How we hand over
- Deliver configuration documentation covering Keycloak client settings, claim mappings, Nextcloud user_oidc settings and the rollback path.
- Provide a test record showing each scoped login, provisioning and logout case and its result, so your security team can review it.
- Walk your administrators through daily tasks such as adding groups, rotating the client secret and handling a locked-out user.
How we support
- Ongoing support, Keycloak and Nextcloud upgrades and continuous testing are available as a retainer, scoped separately from the build.
- Plan each Keycloak and Nextcloud upgrade against the SSO configuration, so claim names and client settings are retested after every change.
- Ask any implementation partner to confirm how they handle Nextcloud major version upgrades, since each one must be applied in sequence.

