How to secure an Express app with Keycloak
This page covers two patterns for a Node.js service that must work with a Keycloak realm: server-rendered sign-in with sessions, and bearer-only APIs that accept access tokens. Both patterns use OpenID Connect against the same realm, so the client registrations, role model and token claims you design once will serve both. The page names the middleware you will see in older guides, keycloak-connect, and explains how to decide whether to use it. Keycloak's own documentation directs teams toward standard OpenID Connect clients rather than framework-specific adapters, so confirm the current maintenance status of keycloak-connect in its repository and in the Keycloak docs before you commit to it. A standard OIDC library with a well-understood session layer is often the safer default for a new service.
Two decisions shape everything that follows. The first is whether the browser ever holds tokens: a confidential Express client keeps tokens in server-side session storage and gives the browser only a session cookie, while a bearer-only API expects a token on each request and never runs a login flow. The second is how the service will reach Keycloak, which determines where the issuer URL, client secret and redirect URIs live and how they differ between development, staging and production. Pick these before writing any route, because changing them later means reregistering clients and reissuing sessions.
The page then covers the prerequisites, the configuration order, claim mapping, security settings, testing and the failure points that most often break Express integrations. Those failure points include redirect URI mismatches behind a reverse proxy, session stores that do not survive restarts or scale-out, role claims that sit in a different place in the token than the code expects, and tokens accepted without an audience check. Confirm your Keycloak version and your Node.js and library versions against the supported matrices before you start, because the client settings and token contents you rely on are defined by the Keycloak release you run.
What the team needs before configuring Keycloak for Express
Most delays in a Keycloak and Express integration come from decisions made late: which Keycloak release and realm to target, whether the Node.js server can hold a secret, and whether both hostnames run over HTTPS. Confirm these items first, because the client settings, redirect URIs and middleware configuration all depend on them.
Keycloak version and target realm
Confirm which Keycloak release your environment runs. The current release is 26.8.1, according to keycloak.org, but many teams run an older supported line and should check the upgrade notes before assuming behavior. Decide whether the application gets its own realm or shares one with other applications, since the issuer URL, client IDs and role names all include the realm name and are hard to move later.
Keycloak docsNode.js and Express versions
Confirm the Node.js runtime and Express major version against your organization's support policy before choosing a library. Check the same for the middleware or OpenID Connect library you plan to use, because older keycloak-connect releases are tied to the deprecated Keycloak adapter. Record the chosen versions in your change request so the upgrade path is visible to the security team.
Confidential or public client
Decide whether the Express server can keep a client secret safely. A server-rendered app that runs the login flow on the server usually uses a confidential client with a secret or signed client authentication, stored in a secret manager. A browser-only or mobile client cannot hold a secret and needs a public client with PKCE. Make this decision before creating the client, because switching later changes how tokens are issued and stored.
HTTPS on both hostnames
Plan TLS for the Express application hostname and the Keycloak hostname. Keycloak's production guidance calls for TLS on all communication, and OpenID Connect redirect URIs and cookies depend on consistent scheme and host values. Confirm that certificates are issued by a trust chain your Node.js runtime accepts, including any internal certificate authority, so that discovery and token calls do not fail on certificate validation.
Network path to the issuer URL
Confirm that the Node.js server can reach the Keycloak issuer URL over the network, not only the public frontend. The server fetches the discovery document and keys from the issuer and calls the token endpoint directly. Keycloak's production guide recommends separating the admin console and Administration REST API from public frontend URLs, so check which hostname the application must use for backchannel calls.
Admin account for client setup
Identify who will create the realm, client, redirect URIs, roles and any client scopes in Keycloak. This can be a platform administrator or a delegated administrator with rights limited to one realm. Ask the Keycloak owner to confirm the process for changing client settings, since redirect URI and role changes affect every environment and should be reviewed before go-live.
How a sign-in and an API call flow between Express, the browser and Keycloak
The browser flow starts when a user requests a protected Express route with no session. The app redirects the browser to the Keycloak authorization endpoint, and Keycloak returns an authorization code to the app's callback URL. The Express server exchanges that code for tokens over a back channel, then stores them in a server-side session. The API flow is separate: a client sends a Bearer access token, and the route checks the token signature against the realm keys at the issuer URL and then checks roles before responding. Check that the redirect URI and issuer match the Keycloak client settings exactly.
Browser sign-in uses a code and a session, while API calls send bearer tokens.
Choosing keycloak-connect or a standard OpenID Connect library
The keycloak-connect package is Keycloak's Node.js middleware for Express. It registers the login redirect and callback routes, keeps the authenticated user in the server-side session, and provides helpers for protecting routes by role. Its main value is that the login flow is already assembled, so the team writes less of the plumbing.
- Login and callback: The middleware starts the authorization redirect and handles the return path, storing the result in the Express session.
- Role checks: Route guards let you require realm or client roles, but your team still decides which role grants which endpoint.
- Bearer-only APIs: A client can be configured for bearer-only protection, which validates tokens in the Authorization header instead of starting a browser login. Confirm the exact client settings for your Keycloak version.
- What your team writes: Session secret management, logout routes, error pages, redirect URI allowlists and any custom claim checks.
- Maintenance: Confirm the package's support status with its maintainers and the Keycloak version it is tested against before you adopt it.
Check the Keycloak server administration guide and the Node.js guidance it points to for whether this package is still the recommended path.
A general OpenID Connect client library reads the realm's discovery document, then leaves routing, sessions and authorization logic to your application. Libraries such as openid-client, or a Passport strategy built on OpenID Connect, fit teams that want the protocol handled by a standards-focused library and the rest written in their own code. The trade-off is more code to review and maintain.
- Discovery and flows: Point the library at the realm's OpenID configuration and use the authorization code flow with PKCE for browser sign-in.
- What your team writes: Login and callback routes, session creation, token refresh logic and logout handling.
- Bearer tokens: Middleware verifies access tokens against the realm signing keys and checks issuer, audience and expiry. This suits APIs that return JSON and never render pages.
- Role checks: Read roles from the token claims and write the authorization helpers yourself. Confirm where Keycloak places realm and client roles in your token mapper configuration.
- Maintenance: Track the library's release history and confirm which Keycloak versions its test suite or documentation covers.
Confirm the library's Keycloak test coverage, and check whether the Keycloak documentation references it, before you commit to it.
A reverse proxy or authentication gateway can handle login before requests reach Express. The proxy manages redirects, callbacks and session cookies, then passes identity to the application in headers or forwarded tokens. OAuth2 Proxy with its Keycloak OIDC provider is a common example. The Express code then needs less login logic, but it depends on the proxy being the only path to the app.
- Login outside Express: Redirects, callbacks and cookies sit at the proxy, so the Express app carries little or no login code.
- Identity passed upstream: Headers or tokens carry user data to the app. Restrict network access so only the proxy can reach Express, or the headers can be forged.
- Bearer-only APIs: Proxies usually suit browser pages. API clients that send bearer tokens may need separate routes or paths, so confirm how token validation applies to API traffic.
- Role checks: The proxy can enforce coarse group or role restrictions, but fine-grained permissions in Express still need application code.
- Logout and sessions: Confirm how logout reaches the proxy session and how long proxy sessions last compared with Keycloak sessions.
Confirm the proxy's Keycloak provider support status and the Keycloak version it is tested against before you rely on it for production access.
Configuration sequence for an Express app on Keycloak
This sequence takes an Express application from an empty Keycloak realm to a working login, session handling and role-checked routes, with a separate path for APIs. Each step closes with a check so the team knows the previous step held before moving on.
Create or select the realm
Choose the Keycloak realm that will hold the application's users, roles and clients, or create a new one for it. Keep realm settings such as password policy, MFA and token lifespans under the team that owns the identity service so that application teams do not change them per app. Confirm the realm is reachable at its issuer URL over TLS, because the Express middleware will read the discovery document from that address. Done when the realm's OpenID configuration document loads in a browser from the same host name your Express app will use.
Create the client with redirect URIs for the callback path
Create an OpenID Connect client for the Express app and choose the client type based on how the app runs. A server-rendered Express app that keeps its own client secret is usually a confidential client using the authorization code flow, so enable standard flow and keep it disabled for implicit flow. Register the exact callback URL your middleware will use, such as the path your library's callback route serves, and avoid wildcards that match unrelated paths. Done when a test authorization request from the realm's account or admin tooling reaches the login page without a redirect URI error.
Set web origins and post-logout redirect URIs
Set the web origins for the client to the scheme, host and port of the Express app, so that browser-based cross-origin requests from that app are allowed. Add the post-logout redirect URI if the app will send users back to a page after sign-out. Keep the list short and exact, and do not use a catch-all origin. Confirm with the team that owns the reverse proxy that the public host name matches what Keycloak expects. Done when a browser request from the app origin to the token endpoint returns a response that does not show a CORS block in the developer tools.
Set the client secret or confirm public client settings
For a confidential client, generate the client secret in Keycloak and store it in your secrets manager or environment configuration, never in source control. Confirm the client authentication setting matches the choice above. If you use a public client with PKCE instead, which suits apps that cannot keep a secret, enable PKCE in the client settings and keep the Express app's token handling on the server. Ask your security team whether client secret rotation and storage meet your policy, because rotation will require a coordinated restart. Done when the app can exchange a test authorization code for tokens using the configured credentials.
Define roles the routes will check
Decide which realm or client roles each route needs, such as an administrator role for an admin page or a reporting role for a report endpoint. Create these roles in Keycloak, assign them to test users and groups, and decide whether they appear as realm roles or client roles in the token. Configure a mapper so the roles appear in the claim your Express code will read, and document the claim path, since the default location differs between realm and client roles. Done when a decoded access token for a test user shows the expected role entries in the claim path you documented.
Configure the Express session store and cookie settings
For a server-rendered app, the session holds the login state after the callback, so choose a session store that suits your deployment, such as a shared store for multiple Express instances, and do not rely on the in-memory default in production. Set the session cookie to secure, HTTP-only and an explicit same-site policy, and make sure the app trusts the reverse proxy headers so secure cookies work behind TLS termination. Keep the session secret in your secrets manager. Done when a login sets a secure session cookie in the browser, and a second request to a protected page is served without a new redirect to Keycloak.
Wire the OIDC middleware and protect routes
Install a standard OpenID Connect library or the keycloak-connect middleware and configure it with the issuer URL, client ID, client secret and callback path that match the client you created. Mount the middleware before your routes, then protect pages with a login requirement and add role checks on routes that need them, returning 403 when the user is signed in but lacks the role. Test the full round trip: visit a protected route, sign in at Keycloak, return to the app and load the page. Then sign in as a user without the role and confirm the restricted route returns 403. Done when both checks behave as expected.
Protect APIs with a bearer-only client or audience check
For JSON APIs that clients call with bearer tokens, validate the token on the API side instead of starting a browser login. Create a separate client or audience mapper for the API so tokens issued to the front-end or server client carry the API audience, then check the issuer, audience, signature and expiry in your Express middleware. Decide whether the API will verify tokens locally against the realm keys or call token introspection, and confirm the choice with your security team. Done when a request with a valid token for the API succeeds, and a token issued for a different audience or missing the required role is rejected with 401 or 403.
How Keycloak token claims map to Express user objects and role checks
This table lists the Keycloak token claims an Express team typically reads, the job each one does in the app, and what goes wrong when the wrong claim is read. Use it as a checklist when you write the user mapping and authorization middleware. The exact claim set depends on the client scopes and protocol mappers configured in your realm, so confirm each claim in a test token before you rely on it.
| Claim | Express use | Risk if read wrong |
|---|---|---|
| sub | Stable user key for the session user object, database foreign keys and audit records | Using email or username as the key breaks accounts when those values change, and a reused name can map to the wrong user |
| preferred_username | Display name and login label in views and logs, not an access key | Usernames can be changed by administrators, so authorization built on this value can silently shift |
| Contact address and notification target; check email_verified before trusting it | Unverified or changed addresses used for account linking can allow account takeover | |
| realm_access.roles | Realm role checks in middleware, such as requiring a role for an admin route | Roles from other clients or default roles mistaken for application roles can grant unintended access |
| resource_access.<client>.roles | Client role checks scoped to this Express API's client ID | Reading the wrong client key or a shared role name can grant access meant for another application |
| aud | Confirms the token was issued for this API before any role check runs | Skipping the audience check lets a token issued for another client be accepted by this API |
| azp | Identifies the client that requested the token, useful for logging and for rejecting unexpected callers | Treating azp as the audience confuses the two checks and can leave the API open to tokens meant for other services |
| iss | Verifies the token came from your Keycloak realm URL before signature and claim checks are trusted | A missing or loose issuer check can accept tokens from a different realm or a look-alike server |
| Logging key (sub plus iss) | Pair subject and issuer in audit logs so identities from several realms or brokers stay distinct | Logging only preferred_username makes it hard to trace actions across realms or after a rename |
Why server-rendered apps and bearer-only APIs need different settings
A server-rendered Express app keeps tokens on the server, stores them in a session, and sends the browser only a session cookie. That makes the session store, cookie flags and logout path the settings that matter most. The session store must hold tokens and session state outside the Node.js process if you run more than one instance, the cookie should be marked HttpOnly and Secure, and the app must end both its local session and the Keycloak session when a user signs out. Logout is where server-rendered apps most often go wrong, so confirm with your own test plan how logout behaves before you write the routes that depend on it.
A bearer-only API does something different. It never starts a login. Clients send an access token with each request, and the API must validate that token on every call. The checks that matter most are the issuer, audience and role checks: the token must come from the expected realm, it must name this API as an intended audience, and the roles or client roles the route relies on must be present. Confirm with your team which token claims carry roles in your realm configuration, because the mapper that places them is set in Keycloak, not in Express. The method of validation (local signature checks or introspection) is covered in its own section, so this page only needs the policy the API enforces.
Many applications are mixed: they render pages on the server and also expose JSON endpoints that a browser script or mobile client calls. Decide where tokens live before you write any route. If the browser holds the session and the API is called with the same cookie, the API is part of the server-rendered app. If other clients call the API directly with bearer tokens, treat those endpoints as a separate API with its own audience and checks. Writing routes first and deciding token placement later usually leads to two authentication paths that disagree about who the user is, so agree the split with the security team and document it in the design.
Security settings to review for an Express app behind Keycloak
An Express app and its Keycloak realm share a set of settings that decide whether a sign-in flow stays safe after launch. The cards below cover the client, the session, the tokens, the routes and the Keycloak server in front of them. Confirm each setting against the Keycloak production guide before go-live, because defaults and hardening steps can change between Keycloak releases.
Exact redirect URIs and web origins
Set the client's valid redirect URIs to the exact callback URLs your Express app uses, including scheme, host, port and path. Avoid wildcards and root-level redirects, since a loose pattern lets an attacker send an authorization code to a URL they control. Set web origins only to the origins that call Keycloak from a browser, and leave them empty for a backend-only client. Review both lists whenever a hostname or environment changes.
Keycloak production guideTLS on the app and every Keycloak endpoint
Terminate TLS for the Express app and for every Keycloak endpoint the app calls, including the issuer, token, userinfo and JWKS URLs. Keycloak's production guide calls for TLS on all communication, so do not allow the app to fetch discovery documents or keys over plain HTTP. Confirm that the session cookie is marked Secure once the app is served over HTTPS, and that the Express app trusts the proxy's forwarded headers only when a proxy is actually in front of it.
Session cookie settings and session store
Set the session cookie to HttpOnly, Secure and an explicit SameSite value, and give it an expiry that matches your session policy. The default in-memory store in express-session does not survive restarts and does not work across several Node processes, so choose a production-grade store that your team can back up and monitor. Confirm the session secret comes from your secret manager and rotate it through a planned process.
Client secret storage outside source control
Keep the confidential client secret in an environment variable or secret manager that the deployment platform injects at runtime. Never commit it to a repository, a sample .env file or a container image layer. Limit who can read the secret in Keycloak's admin console, and plan a rotation procedure that updates the Express app and Keycloak in the same change window. Check build logs and error handlers so the secret is never printed.
Issuer and audience checks on API tokens
When the Express API accepts bearer tokens, verify the issuer against the exact realm URL and check that the audience claim includes this API. Also verify the signature against the realm keys and the expiry, and reject tokens with unexpected algorithms. A token issued to another client in the same realm is otherwise valid and can reach your routes. Test with a token from a different client to confirm the API rejects it.
Least-privilege roles on each route
Map each Express route to the smallest set of realm or client roles it needs, and deny by default on any route without an explicit check. Keep admin roles out of the default composite roles for end users, and review client scope mappers so tokens carry only the roles the API reads. Write one test per protected route that confirms a user without the role receives a 403 response.
Admin console on a separate hostname
Keycloak's production guidance is to expose the admin console and the Administration REST API on a different hostname or context path from public frontend URLs. Your Express app and users should never need the admin hostname to sign in. Confirm that the admin path is reachable only from your administrator network and that your reverse proxy does not forward it to the public site.
Reverse proxy with path restrictions
Run Keycloak behind a reverse proxy that forwards only the paths your sign-in flow needs, such as the realm endpoints, and blocks the admin paths and any management interface from the public internet. Set the proxy's forwarded-header configuration so Keycloak builds correct issuer and callback URLs. Ask your team to test every blocked path from outside your network after each proxy change.
Common Express and Keycloak failures and how to fix them
This table lists the failures teams most often hit when wiring Express routes and APIs to a Keycloak realm, with the likely cause, how to confirm it and the fix for each. Read it from the symptom backward: find the error you see, check the confirmation step, then apply the change in Keycloak client settings or the Express configuration. Most of these come down to a mismatch between what Keycloak issued and what the app expects.
| Failure | Likely cause | How to confirm | Fix |
|---|---|---|---|
| Redirect URI mismatch | The app moved to a new path, port or hostname, or the redirect URI in the Keycloak client does not match the callback route exactly | Keycloak shows an 'Invalid parameter: redirect_uri' error on the login screen; compare the redirect_uri in the browser URL with the client's valid redirect URIs | Register the exact callback URL, including scheme, host, port and path, in the client settings and remove stale entries |
| Issuer mismatch behind a proxy | Keycloak sees a different hostname or scheme than the browser, so the iss claim differs from the issuer the Express app expects | Decode an access token and compare its iss claim with the issuer URL in the app configuration; check the Keycloak frontend URL and proxy headers | Set the Keycloak hostname and proxy settings so frontend URLs match the public address, then align the app's issuer or discovery URL with that value |
| Missing or wrong client secret | The confidential client secret was rotated, copied with whitespace, or the app reads an environment variable that is not set | Token exchange returns 401 invalid_client; log the presence and length of the secret at startup, never its value | Copy the current secret from the client's credentials tab, store it in your secret manager, and confirm the variable reaches the Express process |
| Sessions lost between instances | The express-session store is the default in-memory store, so each process holds its own sessions and users are logged out on other nodes | Users are sent back to login after a request hits a different instance; the session ID cookie is present but the session is missing | Use a shared session store that all instances can reach, and keep the same cookie settings on every node |
| Roles missing from tokens | No client role or realm role mapper includes roles in the access token or ID token, or the app reads a claim path that does not exist | Decode the access token and look for the roles claim; check the client scopes and mapper configuration in the Keycloak admin console | Add or correct the role mapper so the claim your middleware reads is present, then sign out and sign in to get a new token |
| Audience rejected for API calls | The access token's aud claim does not include the API's client ID or audience value, so the resource server refuses it | The API returns 401 with an audience validation error; compare the aud claim in the token with the audience the API validates | Add an audience mapper to the client that calls the API, or change the API's expected audience to the value the token carries |
| Clock skew between servers | The Keycloak host, the Express host and the caller disagree on time, so tokens look expired or not yet valid | Errors mention exp or nbf or iat in the future or past; compare system time on each host with a time synchronization check | Synchronize all hosts with NTP or your platform time service, and allow only a small, documented leeway in the token validation library |
| Logout ends the Express session only | The app clears its local session but never redirects to Keycloak's end-session endpoint, so the Keycloak session stays active | After logout, visiting a protected page in the same browser redirects back in without a password prompt; check whether the logout route calls the end-session URL | Redirect to the realm's logout endpoint with the id_token_hint and a registered post-logout redirect URI, and review the logout pattern in the single logout guidance |
| Admin or helper endpoints served from the public hostname | Health or admin routes share the public frontend host, which exposes paths that should stay private | Request the path from outside your network and confirm whether it responds; review the reverse proxy path rules | Restrict the path at the proxy and keep administrative and management traffic on a separate hostname or context path |
Questions teams ask before securing an Express app with Keycloak
What drives the cost of securing an Express app with Keycloak?
The main drivers are the number of routes and roles, whether the app is server-rendered or an API, how many realms and clients Keycloak needs, how much existing login code must be replaced, and how much test coverage already exists. A single Express app with a short list of roles is a small change. An app with many routes that check roles in different places, custom session code, and several realms for different customer groups adds design and test work at each step. Costs fall into one-time work (design, build, testing and cutover) and recurring work (Keycloak upgrades, client secret rotation and role changes as the product grows). When you ask for a quote, request the list of routes and roles, the session approach, the realm and client layout, and the test plan so that quotes compare against the same scope.
How long does an Express and Keycloak integration take?
No duration figure is supplied for this topic, so this page does not give one. Timelines depend on scope: the number of routes and roles, whether a Keycloak realm and clients already exist, how much legacy login code is removed, and how many environments need testing. DeployOpen sets timelines in the written scope agreed before work starts, after reviewing your app and Keycloak configuration. Ask any provider for a timeline tied to named milestones, such as a working test realm, protected routes verified against your role model, session and logout behavior tested, and a production cutover plan. A timeline without those milestones is hard to check. Also ask what could change the estimate, such as waiting on Keycloak access or on decisions about role design.
What must our team provide before securing an Express app with Keycloak?
The team needs four things before work starts:
- Access to a Keycloak instance, or an agreed plan to provide one, with admin rights for a test realm
- A test realm and the hostnames for development, staging and production, so redirect URIs can be set correctly
- A written role design that lists each role, what it allows, and which routes require it
- A named owner who makes decisions on roles, sessions and logout within an agreed time
Delays in role design are a common cause of rework, so the owner should be available during the design phase. Your team should also confirm who manages Keycloak changes after go-live, because client and role updates recur. The Keycloak server administration guide describes the client and role settings the team will need to review.
Can an internal team secure an Express app with Keycloak on its own?
Yes, for a single app with a clear role model and an engineer who knows Express and OpenID Connect. The core work is contained: configure a client, add middleware or an OIDC library, map roles to routes, and write tests. Outside help usually adds value in three places. The first is reviewing the role model before code is written, since role mistakes are expensive to undo later. The second is testing session handling and logout across browsers. The third is checking token validation for APIs. Outside help also becomes more useful when several apps share one realm, because client and role decisions then affect other teams. Whether to pay for help depends on how many of these areas your team has handled before. Either way, plan for ongoing Keycloak upgrades and client changes after go-live.
Does the Keycloak adapter status change the plan for Express?
Yes, it changes which library you choose and how much code your team writes, so confirm it first. The keycloak-connect package is the Keycloak-specific middleware for Node.js. Before you select it, check its current status against the Keycloak documentation and the package registry, and confirm that it supports the Keycloak version you run. If the adapter is deprecated or lacks support for your version, a standard OpenID Connect library for Express is the safer plan. That choice affects scope: with a standard library, your team handles callback routes, token storage, discovery settings and logout behavior directly. Ask the provider which option they recommend for your Keycloak version and how they will test upgrades.
Should Express APIs validate Keycloak tokens locally or through introspection?
Local signature validation is the usual default for Express APIs, and introspection is the choice when immediate revocation matters more than load on Keycloak. Local checks verify the token signature against the realm keys, the issuer, the audience and the expiry, so the API does not call Keycloak on every request. Introspection asks Keycloak whether a token is still active, which helps when a revoked session must stop access at once, but it adds traffic to Keycloak. For server-rendered apps, the server-side session and its cookie matter more than bearer tokens. Your team should decide which pattern each route group uses, document the decision, and test expired, wrong-audience and revoked tokens. Keycloak's guidance on token validation is the next step before you commit.
What usually breaks when Express meets Keycloak?
Most failures come from configuration mismatches between the app and Keycloak. Check these first:
- Redirect URIs and post-logout redirect URIs that differ from the client settings, including trailing slashes and protocol
- TLS and proxy settings, so the app builds correct callback URLs behind a reverse proxy
- In-memory session stores in production, which lose sessions on restart and fail across multiple Node.js processes
- Role claims read from the wrong place in the token, or roles missing because client scopes or mappers were not configured
Test each of these in a test realm before production. Keycloak's production guide also expects TLS on all communication, so confirm that the app and the proxy use HTTPS end to end.
How should we test role checks before go-live?
Test each protected route with users who hold each role, users who hold none, and tokens that are expired, unsigned or issued for another audience. Automated tests should call the routes directly and assert the status codes, which catches a missing middleware call on a new route. Include tests for session expiry, logout from the app and logout from Keycloak, since those are the points where sessions drift apart. Ask for the test scope in writing, including which routes are covered and where tests run. Some should run against a live Keycloak test realm in addition to mocks. Where your process allows, keep the test realm's users and roles in version control so that role changes go through the same review as code.
How DeployOpen scopes and delivers a Keycloak integration for Express
DeployOpen plans, builds, hardens and documents Keycloak integrations for Express applications inside the infrastructure you control. Each engagement starts with a written scope that names the routes, APIs, roles and session model to be protected, so your team knows exactly what gets built and handed over.
How we scope
- We inventory which Express routes are browser pages, which are bearer-only APIs and which call other services
- We map each protected route to the Keycloak realm, client type and role checks it needs
- We agree in writing which session storage, logout behavior and environments are in scope before work starts
How we build
- We configure the Keycloak realm, clients, redirect URIs and roles for your Express apps in your environment
- We wire keycloak-connect or a standard OpenID Connect library into Express middleware, with role checks on protected routes
- We test sign-in, token expiry, refresh, role denial and logout paths against your Keycloak deployment
How we hand over
- We deliver the configuration, middleware code and environment settings with a written record of each client and role decision
- We document how to rotate client secrets, update redirect URIs and add a new protected route
- We walk your engineers through the test cases so they can rerun them after changes
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing are available as a retainer
- Retainer scope, including Keycloak version upgrades and library updates, is confirmed in the written agreement

