Keycloak for NIS2 multi-factor authentication and access control: what it covers
An essential or important entity under NIS2 must be able to show that users authenticate with multiple factors or continuous authentication where appropriate, and that access to its systems is controlled. Those duties sit in Article 21(2)(j) and Article 21(2)(i) of Directive (EU) 2022/2555, and the detail is set in Commission Implementing Regulation (EU) 2024/2690 for the entities it covers. Keycloak can supply much of the configuration and the records behind these duties: MFA policies tied to user groups and applications, OTP and WebAuthn or passkey options, admin account controls, and login and admin events. It does not decide what your entity must protect or how strong each authentication must be. That judgment belongs to your risk assessment and to the classification of each asset.
Keycloak helps most directly with the technical authentication and access requirements. These include requiring separate credentials for privileged accounts, applying MFA to administrative access, blocking users after repeated failed log-ins, ending inactive sessions, and enforcing credential changes on a set schedule or after suspected compromise. Keycloak also supports the identity life cycle when user data is sourced from an HR system or directory through user federation, although the joiner, mover and leaver process itself is run by your HR and IT teams. Human resources screening, background verification, disciplinary processes, physical access control under point 13.3, and asset management are outside what Keycloak provides. Confirm with your own assessor how each of these will be evidenced elsewhere.
NIS2 creates no certificate of compliance. National competent authorities oversee compliance through inspections, security audits, scans, information requests and fines, and they judge whether your evidence fits your own documented policies. Before you configure anything, confirm your national transposition law, your entity classification as essential or important, and which asset classes Keycloak will front. Then write down which applications rely on it, which groups and roles grant access, and which records you will retain. The section that follows turns those decisions into settings.
Mapping NIS2 MFA and access control requirements to Keycloak settings
This table pairs each NIS2 implementing requirement in scope for MFA and access control with the Keycloak capability that addresses it and the configuration an assessor will expect to see. Read each row as a starting point: the capability is what Keycloak documents, while the configuration column lists what your realm, clients and processes must still set and prove. Anything marked as a confirmation item depends on your own environment, your asset classification and your HR and ticketing processes.
| Requirement | Keycloak capability | Configuration needed |
|---|---|---|
| Article 21(2)(j): multi-factor or continuous authentication where appropriate | OTP policies, W3C WebAuthn, passkeys with conditional and modal UI, recovery codes | Enable MFA as a required action or conditional step for each client that the entity classifies as sensitive; document which clients are exempt and why |
| Article 21(2)(i): access control policies and asset management | Realms, clients, groups, realm and client roles, admin console | Maintain a written access control policy that maps each client and role to an asset classification and owner |
| Point 11.7.1 and 11.7.2: authentication strength matched to asset classification | Authentication flows with conditional steps by group, client or role; per-client flow bindings | Assign a stronger flow (for example, WebAuthn or passkeys) to clients for high-classification assets; confirm the mapping against your own asset register |
| Point 11.6.2: credential change at intervals, on compromise, lockout after failures, session end | Required actions for password update, brute force detection, session idle and max lifespan settings | Set realm session timeouts and brute force protection values to your policy; confirm the interval and thresholds with your security owner |
| Point 11.6.2: separate credentials for privileged or administrative accounts | Separate admin users in the master realm or a dedicated admin realm, realm-level roles | Create named admin accounts distinct from daily user accounts; avoid reusing a standard identity for administration |
| Point 11.3.2(a): strong authentication for privileged and system administration accounts | OTP, WebAuthn or passkeys enforced on the admin console and admin-role holders via conditional flows | Require MFA for every account holding admin roles; confirm the admin console and Administration REST API are restricted to a separate hostname or path |
| Points 11.2.2 and 11.2.3: need-to-know, least privilege, separation of duties | Groups, client roles, composite roles, fine-grained authorization services | Grant access through groups tied to job functions; keep administrative and approval roles in separate groups |
| Points 11.2.2 and 11.2.3: access rights recorded in a register and reviewed | Group and role membership data, admin events and user event logging | Export group and role membership on a schedule as the register; record who approved each change and when the review took place |
| Points 11.5.2 to 11.5.4: one person per identity, shared identities only with approval | Unique user accounts, user attributes, required actions for identity verification | Disable generic shared accounts or record each approval outside Keycloak; confirm no account is linked to more than one person |
| Points 11.5.2 to 11.5.4: deactivate unneeded identities without delay | User enable or disable state, user federation sync, admin API for deactivation | Connect deactivation to your HR or directory source so a leaver is disabled in Keycloak on the same day; confirm the timing your procedure sets |
| Section 10: termination procedures and role change | Federation with LDAP or Active Directory, identity brokering, group membership changes | Define the joiner, mover and leaver steps and test them; keep evidence of each disablement and removal of group memberships |
How to set MFA policies by user group and application
Start by deciding, for each application and user group, which authentication strength the asset requires, because Implementing Regulation 2024/2690 asks for multi-factor or continuous authentication where appropriate and matches the strength to the classification of the asset accessed (points 11.7.1 and 11.7.2). Build a short matrix with three inputs: the asset classification from your own inventory, the user groups that reach it (staff, contractors, administrators, service accounts reviewed separately), and whether access comes from outside the network. Each row becomes one Keycloak authentication flow or conditional rule. Keycloak lets you attach MFA to a flow, so the matrix should name the flow, the required factor and the clients it covers before anyone edits the realm. Confirm with your own risk owners which classifications require a phishing-resistant factor.
In Keycloak, OTP policies define the algorithm, digit count and period for time-based one-time passwords. WebAuthn policies govern security keys and platform authenticators, and the passkey options in the server administration guide cover conditional and modal sign-in. Recovery codes give users a documented fallback when they lose a device, and they are a control in their own right: decide who may regenerate them, how they are issued and whether a help desk reset requires identity proof. Treat recovery as part of the MFA design, not an afterthought, because a weak fallback can bypass the factor the matrix requires. Check each option against the Keycloak version you run, since flow names, required-action behavior and policy fields have changed between releases.
Before you rely on this design in an assessment, export the realm configuration and test each group and application combination with a real account, recording the factors prompted and the events written to the log. Confirm that privileged administrator accounts use separate credentials with MFA, as point 11.3.2(a) and 11.6.2 require. Verify the exact authentication flow setup against the Keycloak release you deploy, using the Keycloak server administration guide, because the documented steps and defaults are version specific. Keep the matrix, the test results and the flow export together as the evidence an essential or important entity would show.
Admin access and leaver handling in Keycloak
Administrators of Keycloak can change authentication rules, read user data and issue tokens for any application in a realm, so the implementing regulation expects their accounts to carry separate credentials and strong authentication, such as multi-factor authentication. In practice this means administrative users should not be the same accounts used for day-to-day work, and the Keycloak admin console and Administration REST API should sit on a hostname or context path that is different from public frontend URLs, as the production guide recommends. Restricting network reach to that hostname is part of the same control.
- Separate admin identities: Create dedicated administrator accounts in the master realm or a管理 realm, with no application roles attached.
- MFA for admin accounts: Require OTP, WebAuthn or passkeys in the browser flow used for administrative logins.
- Split admin hostname: Expose the admin console and Administration REST API on a separate hostname or path, with network restrictions at the reverse proxy.
- Admin event logging: Enable admin events so that role, client and authentication policy changes are recorded with the acting user.
- Break-glass process: Document who holds emergency admin credentials, where they are stored and how their use is reviewed.
Confirm the exact reverse proxy path rules and the admin event retention in your own environment before you describe them as evidence.
When people join a team or change roles, their access should follow the role they now hold, not the access they accumulated before. Keycloak can model this with groups and realm or client roles, so that group membership drives application access and a move between groups removes the old entitlements. The regulation asks that access rights follow need-to-know and least privilege, and that changes are recorded in a register, so the design should make each grant traceable to a group or role.
- Group-based grants: Assign application roles to groups rather than to individual users, so one change updates every affected account.
- Remove on role change: Build the mover step so that the old group is removed in the same operation as the new one is added.
- Shared identity approval: Shared or service-style accounts should exist only after explicit approval, with an owner recorded on the account.
- Single person per identity: Link each user record to one person and avoid reusing usernames for different people.
- Periodic reviews: Export group and role membership on a planned schedule and have application owners confirm it.
Confirm which of these steps your HR or identity governance system performs and which steps Keycloak performs, since the record of each step depends on that split.
Leaver handling is where access most often outlasts a person's employment. The regulation expects identities that are no longer needed to be deactivated without delay, and it expects access to change when someone leaves. In Keycloak, the practical control is to disable the user account, which blocks new logins and token refresh, and to end active sessions so that existing access stops. Deletion is a separate decision that affects audit trails and should follow the retention rules your organization has set.
- Disable before delete: Set the user to disabled so sign-in stops immediately, then keep the record for the agreed retention period.
- End sessions: Revoke active user sessions as part of the leaver step, so access does not persist until token expiry.
- Remove federated links: Check brokered and federated identities, since a disabled Keycloak user may still be reachable through another path if the upstream account is active.
- Credential removal: Remove or reset passwords, OTP devices and passkeys registered to the account.
- Timed trigger: Decide whether the trigger is an HR event, a ticket or a scheduled sweep for dormant accounts, and record which one applies.
HR-driven lifecycle automation usually sits outside Keycloak, in an HR system, a provisioning tool or an identity governance platform. Confirm with your HR and IT teams who triggers the disable step and how long that takes in practice.
Evidence an essential or important entity can show from Keycloak
NIS2 does not issue a certificate, so an entity shows compliance through records that its own team and national authorities can inspect. The cards below cover the Keycloak records that carry MFA and access control claims, who should keep each one, and who should review it before an inspection or security audit.
Admin and login event records
Keycloak's admin events and user login events show who signed in, from where, with which method, and which administrative changes were made. Keep them in a central log store outside the Keycloak host, with retention set by your own policy and national rules. Check that failed login and admin events are captured, since they support the account lockout and privileged access claims. The security operations team should review them on a set schedule, and the compliance lead should sample them for auditors.
Keycloak docsMFA enrollment and policy exports
Export the realm configuration that defines OTP, WebAuthn and passkey policies, required actions and the authentication flows that apply MFA by group or application. Store each export in version control so changes between exports are visible. Confirm that privileged and administrative accounts are covered by a stronger flow than general users. The identity team should own the exports, and the security lead should review them against the authentication strength the entity set for each asset class.
Role and group membership registers
Keep a register of realm roles, client roles and group memberships, with the approver and date for each grant. The register shows that access follows need-to-know, least privilege and separation of duties, and it is the baseline for detecting role changes. Compare it against the HR joiner, mover and leaver records to find accounts that outlived their role. The application owner should approve grants, and the identity administrator should maintain the register.
Access review records
Record each periodic review of who holds access to each application, including the reviewer, the date, the decision on every account and the removals made. Use the user and role data from Keycloak as the input, and keep the exported list that the reviewer signed off. Reviews that show no changes need the same evidence as reviews that removed access. The business owner of each application should perform the review, and internal audit or the compliance lead should test a sample.
Metrics at /metrics
When started with metrics enabled, Keycloak exposes Prometheus-format metrics at /metrics on its management interface. Login and failure rates from these metrics can show unusual authentication activity and support the monitoring part of the entity's incident detection. Keep the management interface off public routes, and confirm the scrape job and retention in your monitoring stack. The operations team should own the dashboards and alert rules, and the security team should review the alerts.
Metrics guideChange records for upgrades and configuration
Keep change tickets for each Keycloak upgrade, each realm or client change, and each Operator update approved in manual mode. Store the Keycloak configuration as code in a Git repository so every change has an author, a reviewer and a commit history. Record the release tested before production, including the database migration output. The platform owner should approve changes, and a second engineer should review them before they reach production.
Upgrading guideConfiguration sequence for NIS2 access control
This sequence turns the access register and authentication requirements into a Keycloak configuration that an essential or important entity can explain and evidence. Each step builds on the one before it, so the records produced at each stage can be reviewed by the compliance team. The order is a starting point, and the exact sequence depends on your environment, identity sources and applications.
Deploy Keycloak behind TLS and a reverse proxy
The platform team deploys Keycloak in infrastructure you control, with TLS on all communication and a reverse proxy that restricts paths. Keycloak's production guidance calls for this baseline before any authentication policy is set. Done means that every login, token and admin request reaches Keycloak only over encrypted connections, and the team can show the proxy configuration and certificate chain to a reviewer. Confirm the database and high availability design against the current Keycloak documentation before going live.
Separate the admin console hostname
The platform team exposes the admin console and Administration REST API on a hostname or context path that differs from public frontend URLs. This limits which networks can reach administrative functions and gives the auditor a clear boundary to test. Done means that an admin login attempt from an unapproved network path fails, and the reverse proxy rules are stored in version control with the change record that approved them.
Model groups and roles from the access register
The identity team translates the access register into realms, groups and roles, following need-to-know, least privilege and separation of duties. Each role is tied to a documented business function, and no role grants rights that the register does not list. Done means that every group has a named owner, a written purpose and a list of applications it can reach, and the team can trace any assigned role back to a register entry.
Set MFA policies per application and user group
The identity team configures authentication flows and conditional OTP or WebAuthn requirements for each client, scoped by group and by the classification of the asset accessed. Stronger factors apply to applications that hold sensitive data or administrative functions. Done means that a test account from each group reaches each application only after the required factors, and the test results are saved with the flow configuration.
Enforce separate credentials for administrative accounts
The security team creates dedicated administrative accounts that are separate from day-to-day user accounts, requires MFA for each of them, and limits realm and master realm administration to named individuals. Shared administrative identities are only allowed with explicit approval. Done means that each admin account maps to one person, carries MFA, and appears in a reviewed list of privileged holders.
Configure lockout, password and session timeouts
The security team sets brute-force detection to block users after a predefined number of failed log-ins, sets password change and reset rules, and configures session idle and maximum lifetimes so inactive sessions end. The values should come from your documented policy, not from defaults alone. Done means that a controlled test of repeated failures locks the account as designed, and an idle session expires at the configured limit.
Enable event logging and metrics
The operations team enables login and admin event storage, forwards events to your log platform, and turns on Prometheus metrics at the management interface. Logs must show failed log-ins, MFA events and administrative changes with timestamps and user identifiers. Done means that a test failed login, an MFA enrollment and an admin change each appear in the central log store and in the metrics endpoint, and the team has confirmed retention with the log owner.
Document joiner and leaver procedures
The HR and identity teams write the procedures that create, change and disable identities, linking each account to a single person and linking each change to an approved request. Procedures should state who removes access on termination or role change and how quickly. Done means that a written joiner, mover and leaver procedure exists, the Keycloak steps are mapped to it, and a sample leaver can be traced from HR notice to disabled account.
Schedule and record access reviews
The compliance team sets a recurring review of group memberships, role assignments and privileged accounts, using exports from Keycloak and the register as inputs. Each review records who approved what, what was removed and why. Done means that the first review is completed and signed, the findings are closed in the register, and the review interval is stated in the policy that the access register cites.
How an MFA-protected login and admin access fit together
The flow starts with a user signing in to an application, which redirects to Keycloak on the public hostname. Keycloak runs the authentication flow, prompts for a second factor for the user group and application involved, and issues tokens back to the application. Administrators take a separate path through an admin hostname that the reverse proxy restricts, and where their accounts require a second factor. Each login and admin action writes to the event log, and metrics go to Prometheus. Check that the admin path is not reachable from the public hostname and that both event and metrics outputs reach the evidence store.
Login, admin access and the event and metrics outputs that feed evidence.
Questions entities ask before getting help with Keycloak and NIS2
Does installing Keycloak make my organization NIS2 compliant?
No. Keycloak is an open source identity and access management server, and it supports controls that NIS2 Article 21(2)(i) and 21(2)(j) ask for, such as MFA policies, role and group design and session handling. NIS2 creates no certificate of compliance. National competent authorities oversee compliance through inspections, security audits, information requests and administrative fines. Compliance depends on how your entity configures Keycloak, which applications sit behind it, how joiner and leaver processes run and whether you can show evidence of each control working.
What does a Keycloak NIS2 access control project cost, and what drives it?
DeployOpen does not publish a price list. A quote follows from a written scope, and most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. The main drivers are the number of applications and clients to configure, how many user groups need different MFA rules, whether Keycloak must federate with Active Directory, LDAP or an upstream identity provider, how many admin roles need separate credentials, and how much evidence your assessors will expect. Ask for a quote that lists each application, each federation source, the MFA policy per group, the joiner and leaver workflow, the evidence pack and whether a retest or ongoing support is included. Your own internal costs, such as staff time for policy decisions and application owner reviews, are separate from any partner fee.
How long does a Keycloak MFA and access control implementation take?
No fixed duration applies to every entity, so the answer depends on scope. The effort grows with the number of applications and protocols (OpenID Connect, OAuth 2.0 and SAML 2.0 each need client configuration), the number of user populations, existing directory integration, the number of privileged roles and how much change control your organization requires before production cutover. Ask any partner for a timeline tied to a written scope with named milestones, and confirm which dependencies sit with your team, such as application owners who must test sign-in and identity administrators who must approve policy.
What does my team need to provide before a Keycloak project starts?
The work moves faster when your team prepares a few inputs before kickoff. Typical items include a list of applications that need sign-in through Keycloak with their protocol and owner, your asset classification so MFA strength can match the sensitivity of each system, your current user directories and their authoritative source for joiners and leavers, the groups and roles that represent your access model, the hosting target and network constraints, and the names of people who approve privileged access. You should also name who will sign off on the policy decisions, since NIS2 expects access rights to follow need-to-know, least privilege and separation of duties.
Can our own team implement NIS2 access controls on Keycloak without a partner?
Yes, an experienced identity or platform team can build this internally, and Keycloak's documentation covers realm, client, authentication flow and admin configuration. The question is capacity and evidence. Your team needs time to map each Article 21 requirement to a setting, test MFA behavior for each group, document the joiner, mover and leaver process, secure admin access, and keep records that an inspector can sample. Confirm internally whether you have people who can own the configuration after go-live, because Keycloak releases regularly and upgrades need planning. A partner is most useful when the scope is wide, the deadline is fixed or the evidence pack is unfamiliar to your team.
Does Implementing Regulation 2024/2690 apply to my organization?
It applies to the categories it names. Commission Implementing Regulation (EU) 2024/2690 sets the technical and methodological requirements of the Article 21(2) measures for DNS, TLD, cloud, data center, CDN, managed and managed security service providers, online platforms and trust service providers. If your organization is an essential or important entity in another sector, NIS2 still applies through your national transposition law, but the detailed Implementing Regulation text may not be the direct benchmark. Its sections 10, 11 and 12 are still useful as a reference for human resources security, access control and asset management. Confirm your sector, classification and national rules with your national competent authority or legal counsel before you choose a control baseline.
What evidence will an NIS2 supervisor expect for MFA and access control?
Supervisors look for proof that controls operate, not only that settings exist. Useful evidence includes a register of access rights linked to roles and groups, MFA policy exports by user group and application, records of admin accounts with separate credentials, joiner, mover and leaver tickets matched to identity events, periodic access review results and authentication event logs. Keycloak's metrics and event data can support some of this, but you should confirm which events your deployment records and how long they are retained. ENISA's June 2025 technical guidance gives non-binding examples of evidence, and it is a good reference for deciding what to collect.
How DeployOpen scopes and delivers NIS2 identity configuration and evidence
DeployOpen plans, implements, hardens and documents self-hosted Keycloak inside your own infrastructure, so the MFA policies, admin access and joiner and leaver handling behind NIS2 Article 21(2)(i) and (j) can be reviewed by your team. Engagements are fixed-scope, with the written scope fixing what evidence the work produces.
How we scope
- We agree in writing which user groups, applications and admin roles fall under the MFA and access control design.
- We map each NIS2 requirement in scope to the Keycloak settings, realms and clients that will show it.
- We confirm with you which asset classifications set the authentication strength each application needs.
How we build
- We configure conditional MFA by user group and application, with separate credentials for administrative accounts.
- We set up joiner, mover and leaver workflows linked to your HR or directory source, with one identity per person.
- We test login, step-up, session timeout and failed-login lockout behavior before any production cutover.
How we hand over
- You receive configuration documentation, a register of group and role assignments, and the event logging setup.
- You receive a test record showing which MFA and access control checks were run, with results and fixes.
- You receive a runbook for periodic access reviews and for removing identities on termination or role change.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- We can retest MFA and access control settings after Keycloak upgrades or changes to group and role design.
- We help you prepare evidence for assessments, though national authorities and auditors make the final judgment.
Sources and further reading
- NIS2 Article 21 Cybersecurity risk-management measures, EUR-Lex ↗
- Commission Implementing Regulation (EU) 2024/2690, EUR-Lex ↗
- NIS2 Technical Implementation Guidance (June 2025), ENISA ↗
- Keycloak server administration guide ↗
- Keycloak: Configuring for production ↗
- Keycloak: Gaining insights with metrics ↗

