Nextcloud Keycloak Integration

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a nextcloud keycloak integration by linking both apps with OpenID Connect or SAML. This link lets your central identity provider check user logins and pass group roles to your file server. Most teams build this setup to stop managing separate passwords in two places. Yet broad group mapping often gives users too much access across shared folders and backing databases. How a nextcloud keycloak integration works The workflow starts when a user opens the file app in a browser. Instead

Keycloak: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up a nextcloud keycloak integration by linking both apps with OpenID Connect or SAML. This link lets your central identity provider check user logins and pass group roles to your file server. Most teams build this setup to stop managing separate passwords in two places. Yet broad group mapping often gives users too much access across shared folders and backing databases.

How a nextcloud keycloak integration works

The workflow starts when a user opens the file app in a browser. Instead of asking for a local password, the file server sends the browser to your identity server. The identity server checks the user password and any second factor token. Once that check passes, the identity server builds a signed token or assertion. This token holds the user ID, email, and group list.

The browser carries this signed token back to the file server. An installed single sign-on plugin reads the token and checks the digital signature. If the signature matches the trusted key, the file server logs the user in. When a new user logs in for the first time, the app can create a fresh profile on the fly. On later logins, the app updates the user profile and group roles from the token.

Mapping groups and managing user roles

Role mapping is the core part of linking your identity provider to your file storage. Your identity team creates roles or groups inside the central directory. They then set up a mapper that puts those group names into the login token. When the file app reads the token, it matches those group names to local storage groups. You can even map a specific central role to the local admin group.

Teams must plan how to handle older local accounts before turning this on. If a user already has an account, you must link it by matching the username or email. Otherwise, the system might create a second, blank account for the same person. You should also decide if local login keeps the session active for break-glass admin recovery. Turning off local login forces every user through your central security rules.

Keycloak: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where single sign-on stops and runtime risk begins

Linking your file app to an identity server solves the front-door login problem. When someone leaves the team, you disable one profile and block web logins right away. You also gain one place to enforce strong passwords and hardware keys. For normal web users sharing documents, this flow works well.

Still, single sign-on only checks who logs into the web app at the start. It does not control what engineers or scripts do inside the backing database or host server. Admins still need direct shell or database sessions to run updates, fix bugs, and check storage tables. Those backend sessions often bypass the web login screen and use shared static keys. A single sign-on link cannot inspect live database queries or redact sensitive fields like emails, phone numbers, or card numbers in query results.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should I use OpenID Connect or SAML for this setup?

Both standards work well for linking your identity server and your file app. OpenID Connect is lighter and uses modern JSON tokens, so most teams pick it first. SAML is older and uses XML, which fits teams with legacy enterprise rules.

What happens to existing users when I turn on single sign-on?

Existing users can keep their old files if you match their unique ID or email address. If the attributes in the login token do not match, the app creates a new empty account. Always test attribute mapping with one test user before moving your whole team.

Does single sign-on protect the database behind the file server?

No, single sign-on only guards the web login flow for the file app itself. Engineers who maintain the underlying database or host OS still log in through separate backend channels. You need database and command controls to audit queries and mask sensitive fields like national IDs.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.