n8n OIDC SSO with Keycloak

Connect self-hosted n8n to a Keycloak realm over OpenID Connect, with a confidential client, a discovery endpoint, the PKCE and state settings n8n can meet today, and role provisioning from Keycloak groups.

On this page

Why teams run n8n SSO through Keycloak and what that setup requires

A self-hosted n8n instance that staff sign in to with separate local passwords creates a second account store to manage, and every leaver has to be removed twice. Teams in this position usually want n8n to trust the identity provider they already run, and Keycloak is a common choice for that role. It is an open source identity and access management server licensed under Apache 2.0, and keycloak.org describes it as a Cloud Native Computing Foundation incubating project. It supports the OpenID Connect, OAuth 2.0 and SAML 2.0 protocols and provides single sign-on, identity brokering, user federation, an admin console and fine-grained authorization services. That breadth matters if the same realm will also serve other internal applications.

OIDC SSO delegates the password check to the identity provider. A user chooses the SSO login, authenticates at Keycloak, and n8n accepts the identity that comes back. n8n still keeps its own user record, so the instance decides what each person can see and change. Per n8n's pricing page, SSO and LDAP are included only in the Business and Enterprise plans. Confirm in writing with n8n which plan covers OIDC in the version you will run, before the design depends on it, because the plan decision affects the budget and the upgrade path.

The Keycloak side of the setup is a confidential client for n8n, with the exact redirect URL registered and the realm's discovery endpoint supplied to n8n so it can read the provider's metadata. Turning off PKCE and state requirements that n8n cannot yet meet is a security trade-off, so record the decision, restrict the client's redirect URLs and review the setting when n8n adds support. Role provisioning is the other decision: choose whether Keycloak groups or claims will set n8n roles, and who approves changes to them. Keep a local owner account for recovery, and test the full sign-in path in a non-production realm first.

Which Keycloak and n8n deployment shapes fit this setup

A single n8n main instance runs triggers, webhooks, the editor and executions in one process group, with one database and one encryption key. This is the simplest shape to configure for OIDC because the redirect URL points at one public address and there is no key to distribute. It suits smaller teams, pilots and internal automations where a short interruption during a restart is acceptable. The trade-off is that execution load and sign-in traffic share the same resources, and the instance has no second main node to take over if it fails.

  • One callback target: the redirect URL in Keycloak points at the single public hostname of the main instance.
  • One encryption key: the key lives only on the main instance, so rotating or restoring it involves one host.
  • Shared load: heavy executions can slow the editor and login flow during peaks.
  • No built-in failover: high availability for n8n multi-main is restricted to Enterprise self-hosted deployments, so this shape has no second main to fail over to.
  • Simple upgrades: one instance to stop, back up and upgrade.

Before you go live, confirm the public URL, the proxy headers and the database backups for this single instance.

Configuration options for the n8n OIDC client in Keycloak

This table pairs each Keycloak client setting with the n8n OIDC field it must match and shows what fails when the two disagree. Work through it in order during setup, because the redirect URI, discovery URL and client secret must match exactly. Confirm current n8n field labels and variable names in the n8n documentation before you configure, since they can change between versions.

SettingKeycloak clientn8n OIDC settingWhat breaks if wrong
Client authenticationOn, so the client is confidential and holds a secretClient secret from the Keycloak Credentials tabToken requests fail with an unauthorized client error at callback
Standard flowEnabled for the browser sign-in redirectConfirm the flow n8n expects in its current OIDC docsUsers reach Keycloak but return to n8n without a usable login result
Valid redirect URIExact callback URL for the n8n host, including scheme and pathMust match the public n8n URL configured for the instanceKeycloak rejects the login with an invalid redirect error
Web originsThe n8n origin only, not a broad wildcardNo direct field; the origin must match the n8n public URLBrowser CORS errors block token or user info calls from the editor
Discovery URLRealm well-known OpenID configuration endpointDiscovery URL field in the n8n SSO settingsWrong realm or hostname stops n8n from loading endpoints during setup
Client ID and secretClient ID in the client settings; secret in the Credentials tabClient ID and secret fields; rotate both togetherA mismatched or stale secret causes sign-in to fail for every user
Scopes and email claimopenid, profile and email scopes assigned to the clientConfirm the scope setting and attribute mapping in current docsMissing email claim means users cannot be matched or created
Groups or roles claim and PKCEMapper adds groups or roles to the token; PKCE not required on this clientRole provisioning mode; no PKCE toggle assumed, so confirm before setupClaim missing leaves users with no role; PKCE enforced blocks sign-in

How to configure Keycloak and n8n for OIDC sign-in

This sequence connects n8n to a dedicated Keycloak realm over OpenID Connect and turns on enforcement only after a non-owner sign-in has been tested. Each step ends with a check, and a local owner account stays usable throughout so an identity provider outage cannot lock out every administrator.

  1. Create a dedicated Keycloak realm

    A Keycloak administrator creates a realm used only for n8n sign-in, separate from the master realm that administers Keycloak itself. Keep the realm name short and stable, because it appears in the issuer URL that n8n stores. Create the realm in the admin console and confirm it is enabled. Check: the new realm appears in the realm selector, and you can create a test user inside it. Keycloak's server administration guide covers realm settings in detail.

  2. Create a confidential OIDC client for n8n

    In the n8n realm, create an OpenID Connect client with client authentication turned on, which makes it a confidential client. Add the exact redirect URL shown on n8n's OIDC settings page as the valid redirect URI, with no wildcards, and match the host and protocol that users will type into their browser. Set the PKCE and state options to the values n8n's current documentation specifies, because n8n cannot yet meet every Keycloak default. Store the client secret in your password manager. Check: the client shows client authentication as on, and the secret is visible on the Credentials tab.

  3. Confirm the discovery endpoint responds

    Request the OpenID configuration document for the realm, found at the realm's .well-known/openid-configuration path, from the host where n8n runs, not only from your browser. This confirms that n8n can reach Keycloak over the network path it will use. Check: the response is valid JSON, the issuer value matches the realm URL exactly, including scheme, host and path, and the authorization, token and userinfo endpoints are present. A mismatch between the issuer and the address n8n uses is a common cause of failed sign-ins, so resolve it before continuing.

  4. Enter issuer and client credentials in n8n

    Sign in to n8n as the local owner account and open the SSO settings. Select OIDC, then enter the issuer URL from the discovery document, the client ID and the client secret, and save. Leave enforcement off at this point. Confirm your plan includes SSO and LDAP, since n8n lists these as part of its Business and Enterprise plans, and check the current plan details on n8n's pricing page. Check: the settings save without a validation error, and your owner session remains active in the same browser.

  5. Test sign-in with a non-owner account

    Create a test user in the Keycloak realm with an email address that matches the n8n account you plan to test, and set a password. Open a private browser window, choose the SSO sign-in option on the n8n login page and complete the Keycloak login. Check: the user reaches n8n, the account is created or linked as expected, and it receives the role you intended. Then try a wrong password and confirm that n8n refuses access. Keep the owner session open in the original window so you can compare behavior and fix problems without losing administrative access.

  6. Confirm the owner account works without the IdP

    Before enabling enforcement, sign in to n8n with the local owner account using email and password, in a separate browser session, and confirm the login succeeds without Keycloak. Record where the owner credentials and any recovery codes are stored, and who can reach them during an outage. Check: the owner logs in with Keycloak stopped or unreachable, which you can test in a non-production copy of the instance if you cannot stop production. If this fails, do not continue to enforcement.

  7. Enable SSO enforcement with a break-glass account

    Only after the non-owner test and the owner fallback test both pass, turn on enforcement in n8n's SSO settings so ordinary users must sign in through Keycloak. Confirm in n8n's current documentation how enforcement treats local accounts, and whether a manual-login exemption is needed for the owner. Check: a non-owner user is sent through Keycloak, a password login by a regular user is blocked, and the local owner can still sign in from a separate session. Document this procedure so the break-glass path is known before an incident.

Turning off PKCE and state requirements that n8n cannot yet meet

PKCE and the state parameter are both defenses against attacks on the OpenID Connect authorization code flow. The state parameter is a random value that n8n sends with the login request and checks when Keycloak redirects the browser back, which blocks cross-site request forgery and login injection, where an attacker tricks a user's browser into completing a login the attacker started. PKCE (Proof Key for Code Exchange) binds the authorization code to the client that requested it, using a code verifier that only the client holds, so an intercepted code cannot be exchanged for tokens by someone else. Keycloak can require both for a client. This page recommends a confidential client, meaning n8n authenticates to Keycloak with a client secret at the token endpoint, which already protects the code exchange, so the decision is about what n8n can actually send.

Turning these requirements off is a compatibility decision, not a hardening step. If Keycloak enforces PKCE or state for the n8n client and n8n does not send them, the login fails at the callback. Whether a given n8n release supports PKCE or state in its OIDC flow is a fact to confirm against the exact version you run, using the n8n documentation for that release and a test login. Do not assume a later version has changed the behavior. In the Keycloak admin console, the settings to review are on the client's advanced tab (PKCE code challenge method) and the client's capability settings. Disable only what the test requires, and leave the client confidential and the redirect URI restricted to your n8n callback address.

After any change to these settings, test the full flow: a new user login, an existing user login, a failed login with a wrong password, a session timeout and a logout. Check the Keycloak event log and the n8n logs for warnings at each step. Then write the decision down in your security review record: the n8n version tested, the Keycloak release (the current release is 26.8.1 per Keycloak's site, but confirm your own), each setting changed and why, the compensating controls such as the confidential client secret, a tight redirect URI and TLS on every hop, and the date you will recheck. Revisit the decision on every n8n and Keycloak upgrade, because a release that adds PKCE or state support lets you turn the exception back on.

How an n8n OIDC login flows through Keycloak

The login starts in the user's browser, which goes to n8n and then to Keycloak's authorization endpoint with the client ID and redirect URL. After the user signs in, Keycloak returns an authorization code through the browser to n8n's callback. n8n then calls Keycloak's token endpoint directly from the server, using the confidential client secret. This server-to-server exchange is the step that crosses the trust boundary. The returned ID token and userinfo claims are then mapped to an n8n role. Check that the redirect URL matches exactly and that the role or group claim arrives as expected.

Browser redirects carry the login, while the token exchange runs server to server.

How Keycloak groups and roles map to n8n access

Once sign-in works, the next question is who gets which access. Keycloak groups, the claims that carry them, and the role rules in n8n decide whether a new hire, a team lead or a leaver ends up with the right permissions. Each card below is a decision or check to settle before users arrive.

Put group membership in the token

n8n can only map groups it receives. Add a group membership mapper to the n8n client in Keycloak so the ID token or userinfo response carries the user's groups under a claim name you choose. Decide whether to send full group paths or short names, because that choice changes every mapping rule that follows. Confirm the claim name and format n8n expects in your version before you write any rules. Then sign in as a test user and inspect the returned claims.

Keycloak docs

Map a small group to instance admin

Instance-level roles control settings, user management and other server-wide actions, so they deserve the smallest group in the design. Create one Keycloak group for instance administrators, keep its membership short, and require approval to add anyone to it. Map ordinary staff to member-level access only. Record who owns the group in Keycloak, because a broad admin group is the most common way SSO setups grant more access than intended.

Assign project roles per team

Project roles decide who can edit workflows and use credentials inside a team's space. Create one Keycloak group per team that needs a project, and map each group to the matching project role. Decide before rollout whether projects are created by hand or follow group membership, since that decides who maintains the mapping. Keep the group naming convention documented so a new team does not reuse an existing group by accident.

Set the default for users without a group

A user who signs in through Keycloak but belongs to no mapped group still needs a role, or none. Decide what that default should be and confirm how your n8n version assigns it on first login. Test a user with no groups to see what they can open, and make sure no shared or legacy group gives them more than the design intends. This default is the first thing a reviewer will ask about during an access review.

Plan for users who leave a group

Removing someone from a Keycloak group does not automatically remove the access they already have in n8n. Confirm when role changes take effect, whether at the next sign-in or on a sync, and whether existing sessions end at the same time. Until you have confirmed this, treat removal from Keycloak as only part of offboarding. Pair the role plan with the steps for deleting users and rotating the credentials they could reach.

Test every mapping before rollout

Build a test realm or a set of test users, one for each group and each role outcome you designed. Sign in as each one and check the instance role, project memberships and what the interface lets them change. Include a user in two groups and a user in none, since conflicting or missing mappings cause most surprises. Keep the results with the change record, and retest after any Keycloak or n8n upgrade.

Questions teams ask before setting up n8n with Keycloak

Can our own team set up n8n with Keycloak without outside help?

Yes, if your team already administers both Keycloak and n8n and has time to test. The work is a sequence of configuration steps: a confidential client in Keycloak, a redirect URL in n8n, the discovery endpoint, role provisioning and testing with non-admin accounts. Teams most often underestimate testing and rollback, because a wrong redirect or claim mapping can lock out administrators. Outside help is useful when Keycloak runs in high availability, when several n8n instances share one realm, or when compliance evidence must be ready by a fixed date. DeployOpen works to a fixed scope agreed in writing before work starts, so you can compare the quote with the hours your own team would spend.

What drives the effort of an n8n and Keycloak SSO setup?

The main drivers are the number of identity groups that map to n8n roles, whether n8n runs in queue mode, whether Keycloak runs in high availability, and how much compliance evidence you need. Each group mapping adds rules to design, test and review, and each role case adds test accounts. Queue mode adds a separate change: the main instance's encryption key must be shared with every worker and webhook processor node so they can read stored credentials, so plan that alongside the login work. A highly available Keycloak needs a synchronously replicated database and a deployment method such as the Keycloak Operator, which adds infrastructure work. Ask any provider to break the quote down by these items.

What must we provide before an SSO setup starts?

Before work starts, your team should provide:

  • Keycloak administrator access to the target realm, with rights to create clients and roles
  • n8n administrator access on each instance that will use SSO
  • Test accounts in Keycloak for each role you plan to map, including one that should be denied access
  • DNS records and TLS certificates for the n8n hostname, since the redirect URL must match it exactly

Also name the people who approve changes to the identity configuration and who will test sign-in after each change. Missing any of these items usually delays testing more than the configuration itself.

Do we have to disable PKCE and state for n8n?

Current n8n OIDC support cannot meet the PKCE and state requirements, so you will likely need to turn both off in the Keycloak client. Confirm this against the n8n version you run before you change anything. PKCE protects the authorization code exchange against interception, and state protects the login callback against forged requests. Turning them off widens the attack surface, so compensate for it: keep a confidential client with a strong secret, register exact redirect URIs with no wildcards, serve everything over TLS, limit who can administer the client, and review sign-in events regularly. Recheck this setting on every n8n upgrade, because support may change.

How long does an n8n Keycloak SSO setup take?

No reliable typical duration is available for this setup, so ask for a fixed-scope estimate rather than a generic timeline. The schedule depends on how many groups and roles you map, whether Keycloak and n8n already run in production or are still being built, how many environments you test in, how quickly your identity team can review changes, and whether compliance evidence is part of the work. A written scope should list each stage, the dependencies on your teams, and the review and test windows. If a provider gives a duration before asking about these inputs, treat it as an assumption to challenge.

Does n8n SSO with Keycloak need a paid license?

It may, so confirm the plan before design starts. n8n's pricing page lists SSO and LDAP among features included only in the Business and Enterprise plans, and the SAML guides cover those plans, so ask n8n in writing whether OIDC is covered by the plan you buy. n8n is licensed under the Sustainable Use License, which allows self-hosted use for your own internal business purposes or for non-commercial use. Files with .ee in their name require a valid n8n Enterprise License. Keycloak is licensed under Apache 2.0, so its license adds no fee. Have procurement confirm the n8n terms before the build.

Will compliance reviewers need evidence from the SSO setup?

Often yes. Reviewers usually ask for proof that access is controlled, that changes are recorded and that access ends when people leave. An SSO setup can supply part of that evidence, including the client configuration, role mappings, sign-in records and test results. DeployOpen prepares systems, controls and evidence for compliance assessments, while independent auditors and certification bodies issue audit reports, attestations and certifications. Ask early which frameworks apply, which controls your auditor will test and who owns each evidence item. Also confirm how removing a user in Keycloak affects existing n8n sessions, since identity provider removal does not always end them.

What a fixed-scope Keycloak SSO engagement covers

A fixed-scope Keycloak SSO engagement for n8n starts with a written scope that names every deliverable before work begins. In practice that means a Keycloak realm and client design (the realm that holds n8n's users, the confidential OpenID Connect client that n8n will use, its redirect URL, and the discovery endpoint n8n reads its settings from), an n8n OIDC configuration applied to the instance, a role mapping rule set that translates Keycloak groups or roles into n8n instance and project roles, and a documented break-glass procedure for a local owner account. The written scope should also state which n8n edition is in use, because OIDC login depends on the plan and licensing terms, and it should list which PKCE and state settings are relaxed and why. Confirm the edition and license position with your team before the scope is signed.

Testing with pilot users is a separate deliverable and should be written as one. The pilot should cover a user from each planned role, a user who should be refused, a user whose group membership changes during the test, and a sign-in attempt with the local owner account. The handover package should include the realm and client configuration exported in a reviewable form, the role mapping rules with their owners, the break-glass steps with the named people allowed to use them, and the Keycloak upgrade and database responsibilities that stay with your team after go-live. Quotes follow from the written scope, so ask each provider to itemize these deliverables, the environments they will touch, and what your own staff must provide, such as Keycloak administrator access, a test realm and pilot user lists. Engagement duration and cost should be confirmed against that written scope, not estimated from this page.

How DeployOpen delivers n8n SSO with Keycloak

DeployOpen plans, configures and documents the Keycloak client, redirect URL, discovery endpoint and role provisioning for your n8n instance, inside infrastructure you control. Each step is scoped in writing, tested before enforcement and handed over with the settings and evidence your security team needs to review.

How we scope

  • Confirm your n8n edition and whether OIDC is available on the plan you run before work starts
  • Agree which Keycloak realm, n8n URL and environments are in the written scope
  • Define how IdP groups map to n8n roles, and which break-glass local accounts stay

How we build

  • Configure the confidential client, redirect URL and discovery endpoint in a non-production realm first
  • Set the PKCE and state settings n8n cannot yet meet, and document each deviation with its reason
  • Test sign-in, role provisioning and user deprovisioning before enforcing SSO for all users

How we hand over

  • Deliver the configuration record, client settings, environment variable list and test results
  • Document the owner account procedure, recovery steps and known limits of the OIDC integration
  • Walk your platform and security teams through the setup so they can review and operate it

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts
  • Ongoing support, Keycloak and n8n upgrade planning and retesting are available as a retainer
  • Upgrade reviews re-check the OIDC client settings and role mappings after each platform change

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.