How Keycloak login for Strapi end users works
If your team already runs Keycloak, the goal for end users is one identity system behind both your Strapi-backed front end and your other applications. End-user login in Strapi is handled by the Users & Permissions plugin, which is separate from admin panel SSO. Admin SSO only governs editors signing in to the admin panel, so configuring it does nothing for customers or members of your site. The supported approach for this topic is OpenID Connect through the plugin's provider settings, with Keycloak as the identity provider and a confidential client that holds a client secret on the server side. Confirm the current provider field names, the callback path and any required scopes in the Strapi documentation for the exact version you run, because these details have changed across Strapi releases. Do not adopt a third-party connector unless the Strapi documentation or your own tested configuration confirms it works with your version.
The flow has three parts that your team must plan together. First, Keycloak needs a realm and a confidential client whose valid redirect URIs match the callback URL that Strapi exposes for the provider, and whose web origins match your front end. Second, Strapi needs the issuer, client ID and client secret in its provider configuration, and the secret belongs in environment variables or a secrets manager, not in version-controlled files. Third, after a successful sign-in Strapi issues its own JWT to your front end, which then calls the Strapi API with that token. The token Strapi returns is not the Keycloak token, so your front end and any service that verifies requests must be designed around Strapi's JWT, its lifetime and its signing secret. Ask your Strapi developer to document which claims and user fields reach Strapi and how new Keycloak users are created as Strapi users.
Before go-live, run a test sign-in against a staging realm with a user who is disabled, a user who has not verified their email and a user who signs in for the first time. Check that Keycloak sessions end when expected, that a changed Keycloak password or disabled account is reflected in Strapi access, and that the Strapi public and authenticated roles grant only what each audience needs. Plan an additional review of Keycloak itself, since the sign-in path depends on its realm settings, token lifetimes and TLS configuration. Keycloak's current release is 26.8.1, and its project plans frequent minor releases, so schedule upgrades and test the sign-in flow after each one. Also confirm your Keycloak database and high availability design against the Keycloak high availability overview before end users depend on it.
What you need before configuring Keycloak login for Strapi
Keycloak login for Strapi Users & Permissions depends on four components that must be in place before any provider setting is entered. Each one has its own version or configuration rule, and a gap in one usually shows up later as a failed redirect or token error. Check them in the order listed so the Keycloak client and Strapi provider settings can be tested end to end.
Strapi 5 on a supported Node.js line
Run Strapi 5 on an Active or Maintenance LTS Node.js version, since Strapi 5 supports only those release lines. Strapi 4 reached end of life on April 30, 2026, so a v4 project should be upgraded before adding the Keycloak provider. Confirm the exact Node.js version against the installation requirements for the Strapi release you deploy, and record it with your build image so a later runtime change does not break the login flow.
- Apr 30, 2026
- v4 EOL
PostgreSQL 14 or later for Strapi
Strapi 5 supports PostgreSQL 14 or later, along with MySQL 8.0 or later, MariaDB 10.3 or later and SQLite 3. It does not support MongoDB or other NoSQL databases. The Users & Permissions tables store the end-user accounts that the Keycloak login creates or links, so this database needs a tested backup before the provider is enabled. Confirm the database version and backup method with your DBA.
- PostgreSQL minimum
- 14+
Keycloak release and realm
Plan around a current Keycloak release, which is 26.8.1 as of October 13, 2026. Create a dedicated realm for the front-end users rather than reusing the master realm used for administration. Decide now which realm name, issuer URL and user population the Strapi provider will trust, because the issuer appears in the OpenID Connect discovery settings and changing it later means reconfiguring Strapi.
Keycloak admin guideSupported production database for Keycloak
Keycloak's production databases include PostgreSQL 14 to 18, MariaDB, MySQL, Microsoft SQL Server, Oracle Database, EnterpriseDB Advanced, Amazon Aurora PostgreSQL and Azure SQL. The default dev-file database is for development only and must not hold login data for a live Strapi site. Confirm that the chosen database and version appear on Keycloak's list, and plan its backups alongside the Strapi database.
Keycloak database guideProduction hostname and TLS for both services
Serve Strapi and Keycloak over HTTPS with valid certificates and stable public hostnames. Keycloak's production configuration expects a hostname and TLS settings to be in place first, and the redirect URI registered in the Keycloak client must match the Strapi callback exactly, including scheme and host. Check certificate chains from the machines that will call the token endpoint, not only from a browser.
Keycloak production configurationFront-end origin for post-login redirects
Name the exact front-end origin that receives users after sign-in, including scheme, host and port. Strapi redirects users back to this origin after the provider authenticates them, and the origin must also be allowed by the Strapi CORS settings. Keep the list of origins short and confirm it with the front-end team, since a missing or extra origin is a common cause of rejected or looping logins.
How the login request moves between browser, front end, Strapi and Keycloak
The flow starts when the browser asks the front end to sign in, and the front end sends the user to Strapi's provider route. Strapi redirects the browser to Keycloak's authorization endpoint, and Keycloak returns an authorization code to the Strapi callback. The key hand-off is the server-side exchange: Strapi trades the code for tokens using the client secret, which never reaches the browser, then creates or links the Strapi user and returns a JWT to the front end. Check that the code exchange happens only on the server side.
Authorization code flow for Strapi end-user login through Keycloak.
Configuring the Keycloak client, Strapi provider and test login
This sequence turns a Keycloak realm into a trusted sign-in source for Strapi's Users & Permissions plugin, with each step closed by a check that proves the client, redirect rules and token behave as intended before front-end users arrive.
Create or choose the Keycloak realm
Decide which realm will hold the front-end users, separate from any realm used for staff or administrators, so that end-user accounts and their settings stay apart from workforce identity. The platform or identity team creates the realm in the Keycloak admin console or selects an existing one, then confirms the OpenID Connect discovery document loads from the realm's well-known endpoint. Done means the discovery URL opens in a browser and lists the issuer value you will later copy into Strapi.
Create a confidential OpenID Connect client
In the realm, create an OpenID Connect client for Strapi and turn on client authentication so Keycloak issues a client secret. Keep the standard authorization code flow enabled and disable flows the Strapi provider does not use, such as direct access grants, unless your front end needs them. The identity team owns this step and should record the client's settings in the change ticket. Done means the client shows client authentication as on and a secret exists in the credentials tab.
Set exact redirect URIs and web origins
Register the exact Strapi callback URL for the Users & Permissions Keycloak provider as a valid redirect URI, using the full scheme, host and path from your environment, with no wildcards. Add only the front-end origins that call Strapi as allowed web origins. Confirm the callback path against the Strapi version you run, since the path is set by the provider configuration. Done means a test authorization request with an unlisted redirect URI is rejected by Keycloak with an invalid redirect error, which proves the allow list is working.
Store the client ID and secret in secret storage
Copy the client ID and client secret into your organization's secret store or the deployment's secret mechanism, not into source control, shared documents or the Strapi admin settings in plain text. Inject them into the Strapi environment at runtime so the value can rotate without a code change. The person who deploys Strapi should confirm that the secret is absent from the repository and container images. Done means a search of the repository and built image finds no secret value, and the running process reads it from its environment.
Enable the Keycloak provider in Users & Permissions
In the Strapi admin panel, open the Users & Permissions plugin settings and enable the Keycloak provider. Enter the client ID and secret from the secret store, and set the issuer or discovery values from the realm's well-known configuration so Strapi validates tokens against the correct realm. Check that the provider's redirect value in Strapi matches the URI registered in Keycloak character for character. Done means the provider saves without error and the Strapi admin shows the provider as enabled.
Set the default role for new end users
Choose the Users & Permissions role that new Keycloak users receive when they first sign in, and keep it at the least-privileged authenticated role that gives them only the content and actions they need. Review the public role and the authenticated role together, because a permissive public role can expose content regardless of the provider. Ask the editorial or product owner to confirm which collections are readable by this role. Done means a newly created Keycloak test user is assigned the chosen role in Strapi and cannot read collections outside it.
Run a test login and decode the token
Sign in as a test user from the front end through the Strapi provider URL and complete the Keycloak login. Strapi returns a JWT to the front end, which should be decoded to check the issuer, audience or client claim, the subject identifier and the expiry time. Then confirm the matching user record exists in the Strapi content manager under Users, with the expected provider and role. Done means the decoded token shows the Keycloak issuer for your realm and the user record appears in Strapi.
Confirm rejected logins and failure paths
Repeat the sign-in with a redirect URI not on the allow list and with a user disabled in Keycloak, and confirm that neither produces a Strapi session or user record. Check that an expired or tampered token fails when used against a protected Strapi endpoint. Record the results with the test date and the Keycloak and Strapi versions in your deployment log so later upgrades can be re-tested. Done means each negative case fails as expected and the results are filed with the configuration baseline.
Mapping Keycloak users and claims to Strapi users
This table compares each Keycloak identity field with the Strapi Users & Permissions field or role it feeds and what happens when the value is missing. Read it before you configure protocol mappers, and confirm in your Strapi version which claims the provider reads from the token response. The main takeaway is that the email and verified flag decide whether an existing Strapi account is linked or refused.
| Keycloak source | Strapi field or role | If missing or empty |
|---|---|---|
| Subject (sub claim) | Stable provider identifier stored against the user account | Login should fail; confirm how your Strapi version handles a missing sub |
| Username (preferred_username) | Username field, used as a display and lookup value | Strapi may generate a username; decide whether that is acceptable for editors and support |
| Email (email claim) | Email field, the usual key for linking to an existing account | Refuse login or require a manual match; do not create accounts without an email |
| Email verified flag (email_verified) | Gate for account linking and creation, if your provider logic checks it | Treat as unverified and refuse linking to an existing account with the same email |
| Enabled state (user status in Keycloak) | Blocked or inactive Strapi user, enforced by Keycloak before tokens are issued | Disabled Keycloak users receive no token, so Strapi never sees them; confirm sessions already issued stay valid until expiry |
| Client roles or groups from protocol mappers | Strapi default role or custom mapping in your provider override, since the Users & Permissions default role is not set per claim by default | Assign the default authenticated role and log the user for review; never grant elevated roles on missing claims |
Security settings to review before end users sign in
Keycloak and Strapi share trust decisions at every hop: which client can request tokens, where the browser may return, how long a session lasts and which routes accept the JWT. The cards below cover the settings to review before end users sign in, and they are most effective when checked together rather than one at a time. Confirm each value against your own environment before go-live.
Keep the client secret server-side
The confidential client's secret lets Strapi prove its identity to Keycloak during the token exchange, so it belongs in Strapi's environment configuration, not in front-end bundles, browser storage or version control. Check that the front end never receives the secret, that the repository excludes environment files, and that the secret is rotated through your secrets manager. Treat any secret that appeared in a public build or commit as compromised and replace it in Keycloak.
Keycloak production guideUse exact redirect URIs only
Keycloak sends the authorization code to a redirect URI that must match a registered value. Register each callback URL exactly, including scheme, host, port and path, and avoid wildcards such as a trailing asterisk on the path or host, because a broad pattern lets an attacker supply a URL that receives codes. Review the list for leftover development entries, such as localhost addresses, before production.
Restrict web origins
Web origins tell Keycloak which browser origins may call its token endpoints from JavaScript, which controls cross-origin access for the front end. Set only the front-end origins that legitimately sign users in, and do not use a permissive wildcard. Confirm that the list matches the Strapi and front-end domains you actually operate.
Require HTTPS on every hop
Authorization codes, tokens and session cookies pass between the browser, the front end, Strapi and Keycloak. Serve each of these over HTTPS, set Keycloak's hostname and proxy settings so issued URLs use HTTPS, and confirm Strapi trusts the forwarded protocol from your reverse proxy. A single plain HTTP hop can expose tokens that the rest of the design protects.
Align token and session lifetimes
Strapi's Users & Permissions JWT has its own expiry, and Keycloak's access and SSO session lifetimes decide how long a user can stay signed in before the provider asks again. Set Keycloak's values so the session does not outlive what your front end accepts, and document how a user who signs out in Keycloak loses access in Strapi. Confirm the chosen JWT lifetime with your security team before launch.
Make the JWT the only route to protected content
Public permissions in Strapi should expose only content that is meant for anonymous visitors. Review the public role for each content type, custom route and upload, because a permissive public role lets requests succeed without a token and makes the JWT check decorative. Test protected endpoints with no token, an expired token and a token for a different user.
Separate admin access paths
Keep Keycloak administrators on a separate identity path from users who sign in to the Strapi admin panel, and avoid reusing the same realm roles for both. Confirm that the Strapi admin login path, which uses SSO separately, cannot grant Keycloak administration rights. Limit who can change clients, redirect URIs and secrets.
Enable and test audit logging
Enable Keycloak event logging for logins, failures, token and client changes, and configure metrics for monitoring sign-in behavior. Send the events to a store your security team reviews and run a test sign-in, a failed attempt and a client change to confirm each one appears. Logs that have never been tested are not evidence that the controls work.
Keycloak metrics docsWhat the JWT your app receives contains and how to use it
The token your front end receives after a Keycloak login is a Strapi token, not the Keycloak access token. Strapi's Users & Permissions plugin exchanges the Keycloak authorization result for its own JWT, and that JWT is what the front end sends to Strapi's content API. Keycloak's access token and ID token should stay between the Keycloak redirect flow and your back end, and the front end should not forward them to Strapi. Before you document any front-end code, confirm the token format, the fields it carries and the default lifetime in the Strapi version you are deploying, because the exact payload and the provider callback behavior are the details most likely to differ between releases. Check them against the Strapi Users & Permissions documentation and a test login on your own instance, not against this page.
Store the Strapi JWT where page scripts cannot read it. A token kept in browser local storage can be read by any injected script, so a single cross-site scripting flaw would expose every active session. The safer pattern is a back-end route handler that completes the OAuth callback, keeps the Strapi JWT in a server-side session, and attaches it to outgoing content API requests as an Authorization header with the Bearer scheme. If your front end must call Strapi directly from the browser, plan an HTTP-only cookie set by your own domain, and confirm that your reverse proxy and CORS settings support that flow. Decide this before build, because moving a token from local storage to a cookie later changes the login code, the logout code and the test plan.
Choosing how to run Keycloak for the login integration
A single Keycloak server suits a pilot, a proof of concept or a non-production environment where the team needs to confirm the client setup, redirect URLs and Users & Permissions provider behavior before committing to production infrastructure. It is the fastest way to validate the flow end to end, but it has no redundancy, so an outage stops every sign-in to Strapi. Keycloak's development database option is for development only, so the pilot should still use a supported database if it will later be promoted.
- Database choice: Plan for a supported production database from the start, even in the pilot, so the schema and backups carry over.
- Realm and client setup: Create the confidential client and redirect URLs as they will be used in production, with the same hostnames pattern.
- Test users and roles: Use realistic test accounts to confirm the claims that Strapi receives in the JWT.
- Promotion path: Decide whether the pilot configuration will be exported and reapplied or rebuilt by hand.
- Exit criteria: Define what must work before the pilot is promoted, such as token issuance, logout and account lockout.
Before leaving the pilot, confirm with your security team which environment-specific values, such as client secrets, must be stored outside the realm configuration.
A production deployment usually runs Keycloak as a cluster so that sign-in survives a node failure. Keycloak documents three high availability architectures: a single cluster optionally spread across availability zones, multi-cluster deployments (v2) without external Infinispan, and the deprecated multi-cluster v1 that used a separate Infinispan cluster per site. Both supported designs require a synchronously replicated database, which is the component most likely to determine recovery behavior and cost.
- Architecture selection: Choose the single-cluster or multi-cluster v2 design based on how many sites you run and your tolerance for site loss. Avoid v1 for new builds because it is deprecated.
- Database replication: Confirm that the chosen database, such as PostgreSQL 14 to 18, is configured for synchronous replication across the failure domains you plan to use.
- Load balancer and TLS: Place the cluster behind a load balancer with the hostname that appears in the Strapi provider settings and redirect URLs.
- Schema migration: Keycloak migrates its schema at startup by default. For large deployments, the upgrading guide suggests applying SQL manually.
- Metrics and health: Enable metrics so that token failures and login errors are visible to operations staff.
Before you commit to an architecture, ask your infrastructure team to document the replication guarantees and the failover runbook, since these define your sign-in availability.
On Kubernetes, the Keycloak Operator manages the Keycloak server and its configuration through custom resources. The operator is installed through Operator Lifecycle Manager, which is the recommended method, though kubectl and an experimental Helm chart are also available. The operator manages Keycloak, KeycloakRealmImport, KeycloakOIDCClient and KeycloakSAMLClient resources, so the Strapi client can be declared as code next to the cluster.
- Install method: Use OLM as the recommended install path and record the operator version you deploy.
- Update approval: Set manual approval mode for operator updates. The operator documentation strongly recommends it to avoid unintended automatic upgrades.
- Client as code: Define the Strapi client with KeycloakOIDCClient so that the redirect URLs and client settings are reviewed in version control.
- Realm import: Use KeycloakRealmImport for the initial realm, then manage later changes through reviewed manifests.
- Secrets handling: Keep the client secret in a Kubernetes secret or external secret store, not in the manifest itself.
Before you choose this option, confirm that your cluster team can run the operator lifecycle, including the manual approval step for each upgrade.
Common Keycloak and Strapi login failures and their fixes
This table pairs each common failure in Keycloak-backed end-user login with its likely cause and the fix to check first. Read it when a login, token or user record misbehaves after setup, and work through the cause column before changing settings. The main takeaway is that most failures trace to a mismatch between the Keycloak client settings, the Strapi provider settings and the hostname the browser actually uses.
| Symptom | Likely cause | Fix |
|---|---|---|
| Invalid redirect URI error at Keycloak | The callback URL in the Keycloak client does not exactly match the URL Strapi sends, including scheme, host, port and path | Copy the callback URL from the Strapi provider configuration into the client's valid redirect URIs, and remove wildcards you do not need |
| Invalid client secret after rotation | The client secret was regenerated in Keycloak but the Strapi provider still holds the old value | Update the secret in the Strapi environment, restart the process, and confirm no older deployment still reads the previous value |
| Login fails with issuer mismatch or discovery errors | Strapi reads the discovery URL from one hostname while Keycloak issues tokens with another, often behind a reverse proxy or without the proxy headers Keycloak expects | Set the Keycloak hostname and proxy settings so the issuer matches the discovery URL Strapi uses, and verify the well-known configuration endpoint from the Strapi host |
| Front end blocked by CORS or origin rejection | The front-end origin is missing from Strapi's allowed origins or from the Keycloak client's web origins | Add the exact front-end origin to both places and avoid trailing slashes or mismatched ports |
| Users sign in but have no permissions | The new end-user is created under Users & Permissions without the default authenticated role, or the role assignment does not apply to this provider | Set the default role for new users in the Users & Permissions settings and test with a fresh account to confirm the role is attached |
| Duplicate accounts for one person | A Keycloak login with the same email as an existing Strapi user creates a second record, or links unexpectedly, depending on how the provider handles existing accounts | Decide the account-linking rule before go-live, check for existing users with matching emails, and test with a pre-existing account |
| Tokens rejected as not yet valid or expired | Clock skew between the Keycloak server, the Strapi host and the client machine shifts the issued-at or expiry times | Synchronize time on all hosts with NTP and confirm the token lifetime settings match what the front end expects |
| Login breaks after a Keycloak upgrade | The automatic schema migration at startup failed or did not complete, or the new release changed behavior the integration relied on | Back up the database first, review the upgrading guide for the target release, and plan manual schema migration for large deployments; the Keycloak Operator should use manual approval mode for updates |
Questions buyers ask before outsourcing Keycloak login for Strapi
Can an internal team set up Keycloak login for Strapi without a partner?
Yes, a team that already runs Keycloak and has someone who knows Strapi's Users & Permissions plugin can usually do it in house. The work is a confidential client, redirect URLs, provider settings and claim handling, which are configuration tasks rather than new software. The harder part is testing the login flow end to end across each front end and environment, and documenting the result so the next person can maintain it. If your team lacks either Keycloak or Strapi depth, a fixed-scope engagement with written deliverables can cover the gap. Confirm your Keycloak and Strapi skills before deciding.
What drives the cost of Keycloak login for Strapi up?
Cost follows the scope you agree in writing. The main drivers are:
- How mature your existing Keycloak setup is, including realms, client conventions and whether it is already in production.
- The number of front ends and environments that need their own clients and redirect URLs.
- How complex the claim mapping is, for example mapping Keycloak roles or groups to Strapi user fields.
- Whether high availability is required for the identity layer, which adds design and testing work.
- The testing scope, from a single login path to every provider, logout and token expiry case.
Ask any quote to list these items separately so you can see which ones move the price.
How long does a Keycloak login integration for Strapi take?
The duration depends on the same factors as cost: Keycloak maturity, the number of front ends, claim mapping and testing scope. No duration is stated here because none has been supplied for this topic. A reliable estimate needs your environment details and a written scope. Ask for a timeline with milestones for the Keycloak client setup, the Strapi provider configuration, the front-end login flow and the test pass, and ask which of those depend on your team's availability.
What is one-time work and what recurs after go-live?
The initial build is one-time: creating the confidential client, configuring the Users & Permissions provider, wiring redirect URLs and testing. Recurring work follows the platforms. Keycloak publishes four minor releases a year and plans breaking changes in minor releases to be opt-in, so you should plan regular review of upgrade notes. Strapi 5 also ships minor releases roughly weekly, so the provider settings and front-end code need checks after upgrades. Client secret rotation and changes to redirect URLs or front-end domains also recur. Ask any partner whether these are included in a retainer or billed separately.
What must our team provide before the work starts?
The partner needs access and context to work safely. Typically this means:
- Keycloak admin access, or an admin who can create a client and test users in a dedicated realm.
- A test realm that mirrors production settings, separate from live users.
- Contacts for each front end, including the people who own its login pages and redirect handling.
- Environment URLs for development, staging and production, including the Strapi and front-end addresses.
- Your decision on which claims or roles must reach Strapi and how they map to users.
Agree on how secrets are shared and stored before any credentials change hands.
Does the Strapi SSO feature replace this end-user login?
No. Strapi SSO applies to administrator login to the admin panel through an identity provider. End-user authentication for your front end is handled separately by the Users and Permissions plugin, which is the path this page covers. Keep the two decisions apart in your scope so admin access and public user access are reviewed on their own terms. Check the Strapi self-hosted plan terms for SSO if you also want admin sign-in, since SSO is an add-on for the Growth plan and included in Enterprise.
When should we ask for a quote, and what should the scope include?
Ask for a quote once the scope is written and agreed. A written scope should name the Keycloak realm and client, the Strapi version and hosting, each front end, the claim mapping rules, the environments, the test cases, the deliverables and the handover documentation. It should also say who owns Keycloak changes after go-live. Without these points, any quote is a guess. DeployOpen works on fixed-scope engagements with scope, deliverables and timelines agreed in writing before work starts, and does not publish a price list.
How DeployOpen scopes and delivers Keycloak login for Strapi
DeployOpen plans, builds, tests and hands over end-user login from Strapi's Users & Permissions plugin to a Keycloak realm you run in your own infrastructure. Each engagement starts with a written scope that fixes the realm, client, redirect URLs and handover materials before any configuration begins.
How we scope
- Written scope covers the Keycloak realm, confidential client, redirect URLs and the Users & Permissions provider settings in Strapi.
- We confirm which Keycloak version, database and hosting model your team runs, since these shape the setup and the upgrade path.
- Scope lists the front-end applications, token handling and test accounts that must work before go-live.
How we build
- We configure the confidential client, valid redirect URIs and client secret storage, then connect the provider in Strapi's Users & Permissions settings.
- We verify the JWT that Strapi issues to your front end, including its claims, expiry and how user records map to Strapi accounts.
- We test sign-in, sign-out, failed login and permission checks against your staging Strapi and Keycloak instances.
How we hand over
- You receive a written runbook covering realm settings, client configuration, redirect URLs and where each secret is stored.
- Handover includes a test plan with the cases we ran and the results, so your team can repeat them after changes.
- We walk your engineers through the front-end token flow and the steps to rotate the client secret.
How we support
- Fixed-scope engagements end at a written handover, and any further change is scoped and quoted separately.
- Ongoing support, Keycloak and Strapi upgrades and continuous testing are available as a retainer.
- Before a Keycloak minor release reaches production, we can retest the login flow in staging against your written scope.

