When a custom Keycloak authenticator is the right answer
A custom authenticator is the right answer when a security or product team needs a sign-in step that stock Keycloak does not provide, such as a risk score check before a password is accepted, a fraud signal from a third-party service, or a call to an external identity verification API. Before writing any code, confirm that the need cannot be met by configuring a built-in authenticator, an existing conditional flow, or a supported OTP, WebAuthn or recovery-code step. Keycloak's Authentication SPI is the extension point for the cases that remain. It sits between configuration and a fork: you ship a provider JAR that Keycloak loads, so the server code stays upstream.
The work has four parts that this page follows: building the authenticator and its factory classes, presenting any form the user must complete, placing the step in an authentication flow, and testing both the happy path and the failure paths. Each part carries its own risk. The step runs on every login it is attached to, so latency, timeouts and error handling against the external service affect every user. Fail-open or fail-closed behavior is a policy decision that security and product owners should make in writing before the build starts.
This is a server-side Java extension that runs in your own infrastructure, so your team owns its code, its dependencies and its failure modes. Ask who will maintain it after launch, which Keycloak versions it must support, and how it will be packaged and deployed to each environment. The Keycloak server administration guide documents the built-in authentication options you should compare against first. Plan for upgrade exposure from the start, because SPI interfaces can change between releases and the custom code must be retested on every upgrade.
What the Authentication SPI lets you add to a sign-in flow
A custom authenticator is one execution inside a browser authentication flow. It runs alongside built-in steps such as passwords, OTP and WebAuthn, and its position in the flow decides what it can see and block. The cards below cover the parts you will build and the points to confirm against your Keycloak version before writing code.
The authenticator class
The authenticator class holds the logic that runs at its step in the flow. It decides whether to let the user continue, show a challenge, or stop sign-in with an error. For a risk check, this is where you read request context and decide. Confirm the authenticate and action method signatures in the Authentication SPI of your Keycloak version, since these are the calls your code depends on.
Keycloak docsThe authenticator factory
The factory registers the authenticator with Keycloak and tells the admin console how to present it. It supplies the provider ID that flows reference, the display name, the requirements it supports, and any configuration properties administrators can set on the execution. Keep the provider ID stable, because flows and configuration refer to it and renaming it breaks existing flows.
The form or challenge
When the step needs input, the authenticator renders a page through a FreeMarker template in a theme. A verification code prompt or a message asking the user to wait would both appear here. Decide whether the page belongs in your theme or in a separate theme, since that choice affects how much work a theme upgrade will cost. Confirm the form-rendering methods available in your version.
Placement inside the browser flow
A flow is an ordered list of executions, and each execution has a requirement such as Required, Alternative, Conditional or Disabled. Your authenticator sits in that list next to built-in steps like password, OTP and WebAuthn. Its position decides whether a user reaches it before or after the password check, and whether a failure stops sign-in. Test each requirement setting, because a wrong one either bypasses the check or locks users out.
Server admin guideProvider registration in the server
Keycloak finds custom providers through the service loader files packaged in your JAR, and the JAR is deployed into the server's providers directory. Registration errors often show up only at startup or in the admin console when the authenticator fails to appear. Check the build and deployment steps for your distribution, including whether the Quarkus-based server needs a rebuild after a new provider is added.
External calls and failure handling
A verification service or risk engine adds a network dependency to every sign-in that reaches your step. Decide what happens on timeout, on an error response and on an unknown result, and whether the flow fails closed or open. Keep credentials for that service out of the realm configuration in plain text, and test the failure paths as carefully as the success path.
Upgrade exposure of custom SPI code
Custom authenticators depend on SPI interfaces that Keycloak may change between releases. The project says breaking changes in a minor release are opt-in, but your code still needs to compile and behave against each new version you adopt. Before an upgrade, rebuild the JAR, rerun your flow tests in a staging realm and read the upgrade notes for any SPI changes that affect your code.
Release updates postWhich extension approach fits the sign-in step
This table compares four ways to add a step to Keycloak sign-in: configuring a built-in authenticator, writing a custom authenticator through the Authentication SPI, using a required action or form action for a narrower job, and handing the step to an external identity provider or gateway. Read each row for when the option fits, what it means for upgrades and who keeps it working. For most new checks, the custom authenticator is the right tool only after the built-in options have been ruled out.
| Approach | When it fits | Upgrade exposure | Who maintains it |
|---|---|---|---|
| Configure a built-in authenticator | The step is OTP, WebAuthn, passkeys, recovery codes, conditional OTP or a condition the shipped flow can express | Low: the step is maintained by the Keycloak project and changes arrive with release notes | Your identity team, through realm configuration and flow settings |
| Custom authenticator (Authentication SPI) | A check Keycloak does not ship, such as a risk score, device signal or call to an external verification service, that must run inside the browser login flow | High: the code depends on internal SPI interfaces and flow APIs that can change between minor and major releases, so each upgrade needs a rebuild and test | Your engineering team or a partner, for the life of the provider |
| Required action or custom form action | A narrower job after credentials are checked, such as forcing acceptance of updated terms or validating a field on a registration form | Medium: narrower SPI surface, but still compiled against Keycloak and tied to theme templates that need review | Your identity team with engineering support for the provider code |
| External step through an identity provider or gateway | The check belongs to another system, such as a corporate IdP enforcing its own MFA, or a gateway policy that runs before traffic reaches Keycloak | Low for Keycloak itself, but the external component has its own upgrade cycle and failure modes | The team that owns the external IdP or gateway, plus your identity team for the brokering configuration |
| Built-in flow with a custom step held outside Keycloak | The external service only needs to be called as a yes or no decision, and the result can be passed back as a signed token or claim | Medium: depends on the token contract and claim mapping, which need testing after each upgrade | Shared between the service owner and your identity team |
| Upgrade test effort | Every custom provider needs to be rebuilt, deployed to a test realm and exercised against the flows used in production after each Keycloak upgrade | Scales with the number of providers and flows that depend on them | Whoever owns the provider code, with the identity team signing off the test result |
| Ownership after go-live | Someone must track Keycloak release notes, own the provider source and keep the external dependency reachable | Undefined ownership is the most common cause of a stalled upgrade, so confirm the owner in writing before build starts | Confirm the named owner and backup owner in your own environment |
How the authenticator is built, placed and released
This sequence turns a sign-in decision into an authenticator that is designed, tested across realms and clients, deployed to the Keycloak server and released with a way back. Each step ends with an artifact a reviewer can check before the next step starts.
Define the sign-in decision and its inputs
Write down the decision the authenticator makes, such as allowing, denying or challenging a sign-in, and list every input it needs: user attributes, client identifiers, IP or device signals, and the response from any external verification service. Name the owner of each input and the data protection terms for sending user data to an outside service. The step is done when a reviewer has signed off a one-page design that states the outcomes for success, failure and an unavailable external service, and the fallback behavior for each.
Write the authenticator and factory classes
Implement the Authenticator interface for the runtime logic and the AuthenticatorFactory for the configuration properties, display name and requirement choices that appear in the admin console. Register the factory through the standard service loader file so the server discovers it at startup. Keep the logic free of hard-coded hostnames and secrets, reading them from the configuration the factory defines. The step produces compiling source and unit tests for the decision logic, with the external call wrapped so tests can run without the live service.
Build the form or challenge templates
If the step shows a page to the user, create FreeMarker templates in a theme that extends the base login theme, and keep the changes limited to the new template so later Keycloak upgrades touch as little as possible. Map each form action to a clear error message and add translation keys for every visible string. The step is done when the template renders in the browser for each outcome, including the error state, and a reviewer has checked the page against the design.
Add the execution to a copy of the browser flow
Duplicate the built-in browser flow in a test realm, then add the new execution at the point in the flow where the decision belongs, and set its requirement (required, conditional or alternative) to match the design. Configure the factory settings in the flow. Do not edit the built-in flow in place, because the copy is what you will later bind to clients or to the realm. The output is an exported flow definition that a reviewer can compare with the design and that can be reproduced by a deployment script.
Test across realms and clients
Run the flow for each realm, client and user group that will use it, including users who already have credentials, users who are required to reset them, and clients that use a different browser flow or a direct grant. Test the failure path where the external service is slow, returns an error or is unreachable, and confirm the behavior matches the fallback in the design. Record results in a test matrix. The step is done when every row in the matrix passes or has a documented exception approved by the owner of the sign-in policy.
Package and deploy to the server
Build the provider as a JAR with the factory registration and any theme files included, then deploy it to a non-production Keycloak with the same version and build options as production. Check the server log for the provider loading without warnings and confirm the flow export imports cleanly. Keep the JAR, the exported flow and the template files in version control together, tagged with the Keycloak version they were tested against. The output is a repeatable artifact and a deployment record.
Release with a rollback path
Promote the tested artifacts to production during an agreed change window, binding the flow to the target clients only after the new execution is confirmed in place. Keep the previous flow binding and the previous JAR available so the flow can be rebound and the provider removed without a rebuild. Confirm that sign-in succeeds for a test account and that login failure events and metrics show the expected pattern. Before each Keycloak upgrade, rerun the test matrix against the new version, because provider interfaces can change between releases.
How the authenticator class, factory and flow fit together
A custom authenticator is two cooperating classes. The factory is the piece Keycloak discovers: it is registered as a provider through the Authentication SPI service registration, which tells the server the step exists and gives it an identifier that administrators select when they add the step to an authentication flow. The authenticator is the per-execution object the factory creates, and it is where the step's logic lives. Keep that split in mind when you design: anything that is configuration (the URL of an external verification service, a risk threshold, whether the step is required or optional) belongs in the factory's configuration properties, while anything that varies per login (the user, the client, the request) must be read at execution time from the authentication flow context. Confirm the exact provider interfaces and registration file for your target Keycloak version against the server developer documentation, since the SPI surface is where upgrade exposure begins.
When the flow reaches your step, the authenticator reads the state Keycloak has built so far from the authentication session: the user already identified by earlier steps, the client that started the login, the selected realm, and any notes passed between executions. It then makes one of three decisions. It can continue, letting the flow proceed without user interaction, when the check passes or the step does not apply. It can fail the flow, which ends the login with an error the user sees or that is logged, when the check is definitively negative. Or it can challenge, rendering a form or redirect so the user supplies something and the flow resumes at the action endpoint. Design the branches before writing code: for each external outcome, decide which of the three applies, and decide what happens when the answer is ambiguous.
Two design rules matter more than the mechanics. First, a step should not silently change user state. If the authenticator sets an attribute, adds a required action, locks an account or revokes a session, record that change in the server's event log or your own audit trail with the user, client, time and reason, and confirm that your audit requirements are met before the step goes live. Second, every external call needs a timeout that is shorter than the user's patience and a defined behavior when the service is down: fail closed for high-risk clients, fall back to a stronger challenge, or continue with logging for low-risk ones. Write that policy down with the security owner, because an undefined outage behavior becomes either a lockout or a bypass. Test both paths explicitly in staging before production rollout.
Testing the authenticator before users see it
Unit tests cover the decision logic inside the authenticator, separated from Keycloak's runtime. Keep the code that decides whether a user passes, fails or gets challenged in plain functions or classes that take inputs such as user attributes, risk scores and client identifiers, so each branch can be exercised without starting a server. The external service call should sit behind an interface so tests can substitute a stub that returns approvals, denials, malformed responses and errors.
- Decision branches: Test every outcome the flow can produce, including the path where the step is skipped for a given client or user group.
- Failure inputs: Feed in missing attributes, null responses and unexpected status codes, and confirm the code fails closed where the policy requires it.
- Timeout handling: Simulate a slow verification service and confirm the authenticator returns a defined result within the configured limit.
- Logging: Check that events record the outcome without writing secrets, tokens or full personal data to logs.
Before moving on, confirm that the unit suite runs in continuous integration on every change to the authenticator or its factory.
Integration tests run the authenticator inside a real Keycloak instance in a development realm, so the flow, the form and the provider wiring are exercised together. Create a dedicated realm, register the factory, add the step to a copy of the browser flow and point a test client at it. Use a stub or sandbox version of the external service so the tests remain repeatable.
- Flow placement: Confirm the step runs where intended in the browser flow and that conditional sub-flows behave as designed.
- Form rendering: Walk each form the step presents, with the expected fields, errors and messages.
- Token outcome: Verify that a successful run leads to the expected tokens and that a failed run does not issue them.
- Upgrade rehearsal: Run the suite against the next Keycloak release in a separate environment before any production upgrade.
Keep the realm configuration exported as code so the test environment can be rebuilt from the same definition each time.
Staging should resemble production in the parts that change behavior: the same database engine and version, the same reverse proxy and TLS path, the same realm and client configuration, and realistic identity providers or test accounts. Run real browsers and the actual applications, not only API calls, because flow and redirect problems often appear only there. Then roll out to production in a canary, limiting the new step to one client or one realm while the others keep the existing flow.
- Production-like clients: Test with the same redirect URIs, client types and token lifetimes that production applications use.
- Browser matrix: Check the forms in the browsers and devices your users rely on, including password manager autofill and keyboard-only navigation.
- Canary scope: Choose a low-risk client or realm first and define in advance what result would stop the rollout.
- Monitoring during canary: Watch failed logins, authenticator events and external service latency through your metrics and logs.
- Rollback: Confirm that the flow binding can be reverted quickly without deleting the authenticator.
Ask the team who owns the external service to confirm its test environment and its production limits before the canary begins.
Failure paths matter most for a custom step, because the default behavior of an external check is often unclear until it fails. Decide, for each failure, whether the user is denied, offered a fallback such as another factor, or allowed through, and test that decision directly. A verification service that times out is the most common case, and the test should show the user a clear message and leave no half-finished session state.
- Timeouts: Inject delays longer than the configured limit and confirm the result matches the written policy.
- Service errors: Return server errors, rate-limit responses and dropped connections and check the logs and user messages for each.
- Retries: Confirm retries do not duplicate verification requests or send a user through the same check repeatedly.
- Form resubmission: Test back-button and refresh behavior on the form, since repeated submissions can produce duplicate events or errors.
- Browser behavior: Check each form the step presents in each target browser, including error states, focus handling and accessibility labels.
Record the expected result for every failure case in the test plan, and confirm with the security owner that fail-open and fail-closed choices are approved.
The test plan should be written and agreed before the build is accepted, not after the code is finished. It lists each test level, each decision branch and failure path, the environments used, the browsers and clients covered, and the criteria for moving to the next stage. Writing it first also clarifies what the authenticator must do, which often exposes gaps in the requirements such as who may skip the step and what happens when the external service is unavailable.
- Acceptance criteria: Write each expected outcome as a pass or fail statement that a reviewer can check.
- Ownership: Name who runs each stage, who approves the canary and who can trigger rollback.
- Evidence: Decide which test results, logs and screenshots will be kept for security review or audit.
- Retest triggers: List the events that require a rerun, such as a Keycloak upgrade, a change to the external service or a new client.
- Scope of cost: Ask any partner to price the test plan and test execution as separate line items in the written scope.
Before accepting the build, confirm that every item in the plan has a recorded result.
Where upgrades expose a custom authenticator
A custom authenticator depends on several parts of Keycloak that change between releases: the Java interfaces it implements, the theme templates its form renders, the flows it sits in, and the security behavior around sign-in. The cards below cover each area, and they share one conclusion: every upgrade needs a sign-in test pass against the release notes for the version you are moving to.
SPI interface changes
Your authenticator and factory classes compile against Keycloak's Authentication SPI interfaces and the server classes they call. Method signatures, default methods and helper classes can change between releases, which can break the build or fail at startup. Keep the provider in its own module, pin the Keycloak version it compiles against, and treat a successful build on the new version as the first check, not the last. Ask whether your implementation uses any internal server class, since those carry the least compatibility promise.
Compatibility policyMinor release opt-in changes
Keycloak states that breaking changes in a minor release will be opt-in. That policy lowers the risk of an accidental break, but it does not remove the need to read each release's changes. Confirm which behavior switches are enabled in your configuration and which are defaults in the version you are moving to. An authenticator that relies on a behavior that was once optional can change silently when a default moves.
- Minor release breaking changes
- Opt-in
Theme template and message changes
A form-based authenticator renders FreeMarker templates and message bundle keys from the theme in use. When a release renames a template, changes its variables or alters a message key, your form can show a blank field, a raw key or a broken layout. Compare your template overrides with the base templates in the new version, and check every custom message key on each locale your realm serves. Keep overrides small so the diff to review stays short.
Default flow and execution changes
Your authenticator sits in a flow that was built on a particular set of default executions and requirement levels. A release can add an execution to the browser flow, change a default requirement or reorder steps, which can move your check before or after a step it depends on. Export the flow before and after each upgrade, compare the two, and confirm that your execution still runs at the intended point for each client and login path.
Security behavior changes
Security defaults move with releases, and they can affect sign-in even when your code is unchanged. The 26.8 upgrade notes, for example, enforce SMTP StartTLS without plaintext fallback, require signature validation of backchannel logout tokens from external providers, and persist login failures to the database by default. If your authenticator calls an external verification service, check how the new defaults affect that call, its failure paths and any data it writes. Read the security section of each release note first.
Upgrading guideRe-test every upgrade
Treat each upgrade as a change to the sign-in path. Run a test plan that covers the successful path, each failure path, the external service being down, each locale and each client that uses the flow, and record the results. Repeat the full pass against the release notes for your target version, not only the one you read last time. Ask your team or partner to own this checklist as part of the upgrade plan, so the authenticator is never skipped.
What drives the cost of a custom authenticator
What is the main cost driver when building a custom Keycloak authenticator?
The biggest driver is how much the authenticator has to integrate with, not the Java code itself. Each external verification service adds an API contract, credentials, error handling, timeout behavior and a test double to build against. A risk check that calls one scoring service is a bounded piece of work. The same check that calls several services, each with different failure modes, multiplies the design and test effort. Ask the partner to list every external dependency in the written scope before agreeing a price.
How many flows and clients does an authenticator change affect?
Effort rises with the number of authentication flows and clients that depend on the new step. An authenticator added to one browser flow for one client is a contained change. Adding it to browser, direct grant and step-up flows across several realms means more configuration, more test paths and more regression checks each time the flow changes. Ask for the list of flows, realms and clients in scope, and whether the step is required, conditional or optional in each one.
Does compliance evidence add to the cost of a custom authenticator?
Yes, when your auditors need records of how the step was designed, tested and changed. Evidence work includes documenting the decision logic, retaining test results, recording configuration exports and linking changes to approvals. This effort is separate from writing the code. Ask whether the quote includes evidence packages and in what format, and confirm with your assessor which artifacts they expect before work starts.
How much does localizing the authenticator's forms add?
Localization adds effort in proportion to the number of languages and the number of custom pages. Each form needs message bundle keys, translated text, and layout checks for longer strings and right-to-left languages. Keycloak's internationalization model is documented in the server administration guide, so confirm the locales your users need before the design is frozen. Adding a language after launch usually costs more than including it at the start.
How many Keycloak versions must the authenticator support?
Plan for the versions you run in production and the one you intend to upgrade to next. Keycloak ships four minor releases a year, and the project states that breaking changes in a minor release are opt-in. Each SPI you depend on is a point of upgrade exposure, so an authenticator that uses internal APIs needs more retesting at every upgrade than one that sticks to documented interfaces. Ask the partner to name the Keycloak versions covered by the quote and how upgrade retesting is priced.
Can our own team build and run a custom authenticator?
Often yes, if your team has Java experience, has operated Keycloak before and can staff ongoing ownership. Build work requires familiarity with the Authentication SPI, FreeMarker forms and a container-based test setup. Running the step also needs a named owner for upgrades, service credentials and incident response. A partner can cover the initial build and knowledge transfer while your team takes over, and the written scope should state which parts transfer and when.
What does the work need from our staff?
Your staff must provide decisions and access, which often take longer than the code. Expect to supply the business rule behind the step, the external service accounts and sandbox credentials, a test environment that mirrors production Keycloak, and reviewers for security and compliance sign-off. Name these contacts before the engagement starts. Delays in any of these inputs move the schedule, whatever the build effort.
What should we request in a written quote for an authenticator?
Ask for a fixed scope that lists each external service, flow, realm, client, language and Keycloak version covered. The quote should separate one-time build and test work from recurring upgrade retesting and support. Request the acceptance criteria, the test types included, the evidence package, handover tasks and the exclusions. Confirm the timeline is tied to named client inputs, since DeployOpen agrees timelines in writing for each fixed-scope engagement.
How a custom step runs inside a Keycloak login
The login starts in the browser, where Keycloak runs its built-in executions of the browser flow in order. When execution reaches the custom authenticator, Keycloak calls the external verification service or evaluates the risk rule inside its own server, so that call crosses the trust boundary. The authenticator then either shows its form and continues the flow, or fails the login. Check that a failed step stops the flow before any token is issued, and that the external call has a timeout and a defined behavior when the service is unavailable.
A custom authenticator runs inside the browser flow and calls out only at the marked boundary.
How a custom authenticator connects to the rest of the platform
An authenticator does not work alone. It sits inside a browser flow, renders through a theme, reads and writes user data, leaves a trail in events and logs, and may call an outside service with its own credentials. Each connection below is a place where a working prototype can fail in production, so confirm each one in your environment before the build starts.
Realm and browser flow
Your authenticator only runs when it is placed in a browser flow that the realm uses for sign-in. Decide whether the step is added to the existing browser flow, copied into a new flow, or bound to specific clients, because each choice changes which users meet it. Confirm the execution requirement (required, conditional or alternative) and the position relative to password and MFA steps. Test the flow with a user who has no second factor, since that path is where risk checks most often break sign-in.
Keycloak docsTheme that renders the form
The form your authenticator returns is drawn by the login theme, so its template name, message keys and field names must match what the active theme provides. Confirm which login theme each realm and client uses, including any per-client overrides. A template change made for branding can silently remove the fields your step expects. Keep the form minimal and check it in every theme that serves the flow, including the localized versions of the pages.
User attributes and user profile
Many checks read or write user data, such as a verified phone number, a device flag or a risk score. Confirm which attributes exist in the declarative user profile, who can view and edit each one, and whether unmanaged attributes are enabled in your realm. An attribute your code writes but the profile does not define may be dropped or hidden from administrators. Agree the attribute names with the team that owns the user profile before the step depends on them.
Event logging and audit trail
Authentication decisions made by your step should appear in the same audit trail as built-in sign-in events, so security teams can reconstruct why a user was challenged or blocked. Decide which events your code emits, how failures are recorded, and where the records go. Confirm that login failure persistence in the database matches your retention policy, since that setting is on by default in Keycloak 26.8. Do not log raw risk-service payloads or personal data that the audit policy does not allow.
External service and its credentials
A verification or risk service adds a network dependency to every sign-in that reaches your step. Confirm the service's availability target, its timeout behavior and whether your step fails open or closed when it cannot answer. Store its API key or client secret in a secrets store that the Keycloak runtime can read, not in the theme or the realm export. Confirm who owns rotation, and whether the service's own terms allow the user data you send.
Monitoring through the metrics endpoint
Keycloak exposes Prometheus-format metrics at /metrics on its management interface when started with --metrics-enabled=true. Your step should be visible there, or in its own logs, so that a slow or failing external call shows up before users report it. Confirm that the management interface is reachable only from your monitoring network, and set alerts on error rates and latency for the outside call. Optional HTTP and cache histograms are available if you need deeper timing data.
Questions teams ask before writing a custom authenticator
Can an existing Keycloak authenticator or required action do the job first?
Often yes, and checking this first is the cheapest decision in the project. Keycloak ships authenticators for OTP, WebAuthn, passkeys, recovery codes, conditional logic and several others, and the server administration guide documents how to combine them in a browser flow. Before writing code, map the check you need against the built-in steps, then against the required action SPI if the requirement is a step after login such as accepting updated terms. Only build a custom authenticator when no combination of shipped steps produces the behavior you need, such as a call to your own risk engine or an external verification service. Confirm the exact list of steps in the Keycloak version you run, because the set changes between releases.
What does the work need from our developers and security team?
The build needs a Java developer who can write against the Keycloak Authentication SPI, plus someone who owns the flow design and the external service contract. Developers write the authenticator and factory classes, the form template if the step asks the user for input, and tests. Your security team should define what the step must decide, how a failed or timed-out check is handled (fail closed or fail open), what data leaves Keycloak, and how the service credentials are stored. Your operations team needs to know how the provider JAR is built, deployed and rolled back. Ask any partner to show who signs off on the security decisions, since the code is the easy part of the work.
How do Keycloak upgrades change the effort of a custom authenticator?
Every custom authenticator is code that depends on Keycloak internals, so each minor or major upgrade can require a rebuild, a code change or a retest. The upgrading guide and the backwards compatibility notes describe what changes between releases, and the project says breaking changes in a minor release are opt-in. Recurring cost comes from keeping the provider compiled against the version you run, rerunning the flow tests and checking the admin console screens that display your step. Keep the authenticator small, avoid depending on undocumented internal classes, and keep the external call behind a separate client class so an upgrade touches less code. Ask for the upgrade effort to be stated per release line in the quote.
How should we test what happens when the external service fails?
Test the failure paths as deliberately as the success path. Cover timeouts, connection refusals, HTTP errors, malformed responses, and a service that answers slowly, and confirm the flow outcome for each one matches the decision your security team made. Run these tests against a stub or a local simulator of the service so results do not depend on the vendor's uptime. Also test that users see a clear message, that no sensitive detail leaks into the page, and that the event is written to the login event log so operators can see it. Include a test where the flow is run with the step in its required and conditional settings, because the outcome differs. Ask for the test cases and their results as part of the delivery.
What documentation will an auditor expect for a custom authenticator?
An auditor will usually want to see the authentication requirement the step satisfies, the flow configuration that enforces it, and evidence that the flow works and is controlled. Prepare a design record that states the purpose of the step, the decision logic, the failure handling and the data sent to the external service. Keep the source code under version control with review records, the build artifact identifier for each deployed version, and the test results for each release. Export the realm configuration that contains the flow, and keep change records for who altered it and when. Confirm with your auditor which framework controls apply, because the mapping depends on the framework and on your environment. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors issue the opinion.
What drives the cost of a custom authenticator project?
The main drivers are how many decisions the step needs, how complex the external service contract is, and how many flows and clients use the step. A single check that calls one well-documented HTTP API is a small build. Costs rise with multiple external services, custom user interface forms, per-client logic, and detailed failure handling that must be tested. Recurring cost comes from upgrades, service changes and audit evidence. Ask for a quote that separates design, build, test, deployment, documentation and a post-release upgrade allowance, and state which external services and test environments are assumed. DeployOpen does not publish a price list, and a quote follows from the written scope.
Should we build this ourselves or hire a partner?
Build it in-house if you already maintain Java services, have engineers who have worked with Keycloak internals, and can own the upgrade work for years. Consider a partner when the team has not written a Keycloak provider before, when the external service contract is still changing, or when the deadline for an audit or rollout is fixed. Whichever path you choose, agree the scope in writing before work starts, decide who owns the upgrade responsibility, and confirm that the design record and tests will be handed over. Keep in mind that the person who wrote the authenticator is often the one who must debug it at two in the morning, so plan for that handover.
What to hand over and keep after the build
The handover should leave the client able to build, deploy, test and change the authenticator without the people who wrote it. The core package is the authenticator and factory source code in the client's own repository, a build and packaging guide that produces the provider JAR, and the flow definition exported as configuration so the flow can be recreated in a new realm or environment. Include the test suite with recorded results for each Keycloak version tested, and confirm that the exported flow lists the execution order, the requirement settings and the provider IDs exactly as they run in production. Ask for the external service's contract, sandbox credentials handling and the failure behavior the code implements.
Runbooks matter as much as code. The runbook for external service failure should state what users see when the verification service times out or returns an error, whether the flow fails closed or falls back, who can switch the execution to disabled or alternative, and how to confirm recovery. Add an upgrade checklist with one section per Keycloak release the client runs, covering SPI interface changes, the form template changes, and a retest of the flow in a staging realm before the production upgrade. Check each item against the upgrade notes for that release, which is where interface changes are recorded.
Settle ownership before go-live, not after the first incident. Decide who owns the repository, who approves changes to the flow in production, and who is on call when the external service fails at the sign-in step. The handover is incomplete until the client's engineers have made one build and one deploy themselves and rolled back a change in a test environment. Put the owner, the on-call path and the upgrade calendar in writing, so the authenticator does not become an unmaintained component that blocks the next Keycloak upgrade.

