Keycloak vs Auth0 for B2B SaaS Cost, Operations and Architecture

Authentication & Security

Compare Keycloak vs Auth0 for B2B SaaS. Model identity costs, test enterprise SSO, assess recovery, and decide what your team should host or delegate.

TL;DR

  • Choose between Keycloak and Auth0 by pricing the same identity outcomes. Include enterprise connections, account recovery, multi-factor authentication, tenant onboarding, environments, audit export, recovery and support. Compare a current vendor quote with the costs of operating a supported Keycloak stack.
  • Self-hosting puts upgrades, database recovery, proxy configuration, signing-key rotation and incident response on your team. An established platform team and a credible reason to control hosting can justify that ownership. A managed provider can remove much of the identity infrastructure work while leaving tenant configuration, integration and customer support with you.
  • Keep your SaaS account IDs independent of the identity provider. Link a verified issuer and subject to your application’s user record, and verify organisation membership in the application. Benchmark both providers with the same onboarding and outage scenarios before agreeing to a cutover.

Frame the choice around the identity work your team already owns

A B2B SaaS company has local login and two prospective enterprise customers. One requires SAML single sign-on with its company directory. The other uses OpenID Connect (OIDC) and expects accounts to lose access quickly when employees leave. Both want to invite new users into the right organisation and the product team must support people who belong to more than one account. The engineering team is comparing a managed Auth0 deployment with Keycloak running in its Kubernetes environment.

The first estimates tend to compare a licensing quote against a pod and database bill. Neither number answers who owns the connection to the customer’s identity provider, who diagnoses an account lockout or who confirms that recovery reached the promised point after a database failure. An existing Kubernetes platform can reduce the marginal compute cost but does not guarantee that identity operations are already staffed.

Write down the events that determine the comparison. Include a new enterprise customer, a user logging in to two organisations, a disabled account with a still-valid session, an emergency signing-key rotation and a region outage. Agree which failures must be detected, who can respond and which dependencies need their own service targets. Separate identities created from active users and distinguish interactive login from machine-to-machine access. Ask a managed provider how its contract counts relevant usage instead of assuming a universal definition. Auth0 pricing and plan capabilities

Do the same for environments. A realistic screening plan may include production, a staging integration environment and a place where a customer’s IT team can validate changes. Some contracts or provider limits vary by environment. Integration estimates should include the business’s own ticket, runbook and audit process, even if the identity endpoints themselves are hosted.

Where the two architectures put responsibility

Customer directory or social identity provider
  → identity broker (Keycloak deployment or Auth0 tenant)
  → verified issuer and subject
  → application user and organisation membership
  → application permissions and business data

Keycloak can act as an identity broker and retain local users. You choose the supported version, deployment environment, database and network layout. For high availability, place replicas and supporting systems according to the chosen topology. Review the relational database and cache behaviour alongside service replicas. Database failover, storage durability and the ability of all nodes to reach the same dependencies affect the result directly. The upstream guide documents multiple architectures with different fault and recovery assumptions. Keycloak’s high-availability architectures

Auth0 hosts the core identity service and offers Universal Login and enterprise connections. Your team manages the application integration, customer connection details, redirect URLs, claim mappings, factors and any login extensibility you use. Availability of Auth0 Organizations depends on your implementation and plan or agreement. The organisation handling your SaaS workspace can still be a distinct application record even when it is mapped to an identity organisation. Ask how the service supports mixed membership and user deprovisioning for your specific connection types. Auth0 Organizations and plan dependencies · Auth0 enterprise identity providers

Identity broker and tenant layout are separate decisions. In Keycloak, decide which boundaries need their own realm and which can share a realm with separate organisation and application records. A realm-per-customer design can simplify some isolation decisions while multiplying issuer metadata, configuration, key rotation and test coverage. A shared realm simplifies deployment operations and moves more responsibility onto organisation mapping and explicit membership checks. Evaluate both patterns against your customer onboarding and identity lifecycle. Keycloak Server Administration Guide

CapabilityKeycloak deploymentAuth0 deployment
Enterprise SSOConfigure identity brokers and your own admin process.Configure supported enterprise connections and verify limits in the agreement.
Login and factor policyOwn authentication flows, recovery and factor configuration.Verify Universal Login and factor support, including enrolment and recovery for the contracted configuration.
Service operationsOwn runtime, database, networking, upgrades and recovery.Own application monitoring, service integration and escalation to the provider.
Evidence and exitPlan audit exports, database restores and configuration rollback.Verify audit streaming, retention, export and transition rights for your agreement.

Run an identical SSO proof on both sides. For SAML, test your customer’s signing certificate rotation, identifier mapping and a recovery path. For OIDC, confirm the issuer, redirect paths and claims in an actual browser flow. For social login, make sure a corporate address does not accidentally link a user to an enterprise identity without a verified linking process. Test each required MFA enrolment and recovery flow. A checklist marked “supported” does not expose a login screen that blocks the customer’s required journey. Auth0 Universal Login documentation

Build a comparable cost and architecture experiment

Put support, availability and growth into one cost model

For a managed quote, capture counted usage, enterprise connections, tenant features, audit log export, SLA, support coverage, transaction limits and contract tiers. Ask whether staging and regional hosting change the price, and what happens if your active-user or SSO counts exceed the estimate. Estimate the engineering time for integration changes, SSO troubleshooting, customer onboarding, and provider incident coordination.

For self-hosting, include compute and memory, managed PostgreSQL or self-managed database operations, backups, cross-zone traffic, ingress, security monitoring and support. Time-box patch validation, integration testing, rotation and restore drills. Spread one-time migration cost over an explicit planning horizon or list it as a separate line item. Model uncertainty with low, typical and high demand for identity operations. Use expected hours for hands-on work and separately record the availability burden of holding an on-call rotation.

def annual_operating_cost(
    annual_service_fees: float,
    annual_iac_and_infrastructure: float,
    monthly_run_hours: float,
    annual_fixed_hours: float,
    loaded_hourly_cost: float,
) -> float:
    yearly_hours = 12 * monthly_run_hours + annual_fixed_hours
    return annual_service_fees + annual_iac_and_infrastructure + (
        yearly_hours * loaded_hourly_cost
    )

# Hypothetical engineer-hour estimates; use your invoice and staffing inputs.
def extra_self_hosted_hours() -> int:
    self_hosted = 12 * 10 + 40
    managed = 12 * 3 + 16
    return self_hosted - managed

assert extra_self_hosted_hours() == 108

The assumptions above imply 108 additional engineer-hours per year for the self-hosted example before accounting for infrastructure and vendor fees. This is a fabricated scenario for comparing arithmetic, with no quoted prices or savings. Replace the hour estimates with incidents, upkeep and onboarding observations from a pilot. Multiply by your own loaded rate per hour, and compare the result against the same outcomes on a current managed quote. Separate reliability and workload risk from hard spending.

Run a production-shaped Keycloak pilot

Start from a pinned, supported release and image digest. Verify your specific release’s CLI and database support. This example separates upstream HTTP proxy options from build-time settings that need to be included in an optimized image. It assumes HTTPS at an edge proxy, a private route to Keycloak, and a database with a trusted certificate whose hostname matches the JDBC target. Make the trust chain available to the JVM. Restrict management endpoints and ports so that health and metrics are monitored internally. Keycloak production configuration · Supported databases and connection settings

# Built into the approved image with kc.sh build before start --optimized:
KC_DB=postgres
KC_HEALTH_ENABLED=true
KC_METRICS_ENABLED=true

# Runtime configuration for edge TLS termination on a private network:
KC_HOSTNAME=https://identity.example.com
KC_HTTP_ENABLED=true
KC_PROXY_HEADERS=xforwarded
KC_PROXY_TRUSTED_ADDRESSES=10.42.10.0/24
KC_DB_URL=jdbc:postgresql://id-db.internal:5432/keycloak?sslmode=verify-full
KC_DB_USERNAME=keycloak
# Inject KC_DB_PASSWORD separately through the deployment secret store.

Use this as a configuration fragment. Set the trusted proxy addresses to your real ingress and configure the proxy to overwrite forwarded headers. Limit backend access at the network layer. If traffic between proxy and application requires encryption, use a supported HTTPS design and adapt the HTTP configuration accordingly. Review the installation against the proxy guide, especially hostname, path and admin routing assumptions. Keycloak guidance for reverse proxies

Exercise gradual rollout on a supported upgrade path and a test copy of configuration and database data. Record whether your deployment and version allow a rolling upgrade, and what to do if schema changes have already occurred. Test a database switchover and restoration into a new environment with valid secrets. Realm import and export can support reproducible configuration, but do not capture everything needed to restore a production system such as persisted sessions and some event history. Keycloak realm import and export limitations

Keep issuer validation independent of provider preference

During the pilot, give each provider a reviewed issuer setting. The smoke test below retrieves OpenID Provider metadata for a trusted issuer and checks that the expected endpoints exist. Run it against each environment. It is only a deployment check. Keep application token validation in an established OIDC client or verification library configured for the expected issuer, audience and allowed algorithms. Test discovery and login separately. OpenID Connect Discovery specification

import json
from urllib.request import urlopen

def verify_discovery(issuer: str) -> dict:
    # Pass only an issuer controlled by your reviewed deployment configuration.
    url = issuer.rstrip("/") + "/.well-known/openid-configuration"
    with urlopen(url, timeout=5) as response:
        metadata = json.load(response)

    if metadata["issuer"] != issuer:
        raise ValueError("Unexpected issuer in discovery document")
    for key in ("authorization_endpoint", "token_endpoint", "jwks_uri"):
        if not metadata[key].startswith("https://"):
            raise ValueError(f"{key} must be reachable over HTTPS")
    if "code" not in metadata.get("response_types_supported", []):
        raise ValueError("Authorization code response is missing")
    return metadata

Use the verified issuer and subject together for the stable identity mapping. A subject value alone can collide across providers. Avoid relying on email as a stable identifier or a sole criterion for automatically linking accounts. Test the account recovery and migration path, including what users must re-enrol and whether the product will accept sessions from the original provider during transition. A separate mapping table and a clear linking flow reduce the chance of punishing a legitimate user as a duplicate account.

Failure modes that look like a provider comparison failure

Issuer metadata advertises an incorrect origin

The application’s expected issuer differs from what the browser or callback sees through the proxy. Login may fail during discovery, code exchange or token validation. Confirm the advertised issuer, paths and TLS from outside the cluster. Use a known public hostname and keep the application’s issuer configuration precise. Test fresh authentication and callbacks after each ingress change.

Tenant membership arrives from the wrong place

A person authenticates correctly but the application attaches them to a workspace based only on an email domain or connection name. Membership needs its own trustworthy mapping. Test multiple memberships, revocation, invitation acceptance and machine users. Establish a process to override a mistaken mapping with an accountable review.

Recovery restores configuration but loses user state

A dry run can recreate a realm while leaving its underlying production records, event history or sessions behind. Drill a complete restore using the database and required service configuration. Compare the resulting recovery time and point with your customer commitments. For a managed deployment, ask what restores are in scope and rehearse application recovery even when provider data is out of your hands.

Cost assumptions ignore the next enterprise connection

Usage stays flat while operation costs grow because each organisation needs its own directory attributes, certificate work or access reviews. Track enterprise onboarding time and support cases independently of active-user counts. Keep commercial and engineering sizing in one versioned worksheet and revise it after real integration work.

Make the hosting decision with observed evidence

  • Choose a managed provider if a verified plan meets identity and residency requirements and the team needs predictable support without staffing the infrastructure directly.
  • Choose self-hosted Keycloak if your team can demonstrate restore, patching, rollout and incident response, and hosting control or customisation delivers concrete value.
  • Consider supported Keycloak hosting when the Keycloak model fits but database or runtime operation needs an owner outside your team. Check responsibilities and exit terms with the same diligence you apply to Auth0.

Track median and tail latency for the login flow separately from customer identity-provider response times. Observe new organisation onboarding, certificate changes and the support time spent on recovery in both pilots. A shorter initial setup does not guarantee cheaper long-term operations. An exit rehearsal is as valuable as a signup demo because it validates your ability to move if constraints change.

Frequently asked questions

Is self-hosted Keycloak cheaper than managed Auth0?

It depends on the identity features, service targets and operations your team needs. Compare a current Auth0 quote with Keycloak infrastructure, staffing, support, recovery and upgrade work. Also estimate the customer onboarding and support your team owns under either design. Use a low and high workload scenario to expose assumptions.

Can both Keycloak and Auth0 support enterprise SSO?

Both platforms support applicable enterprise identity integrations, including SAML or OpenID Connect through supported providers or broker configurations. Verify your exact provider, sign-in flows, claimed identifiers, deprovisioning expectations and contract limits. Exercise certificate rotation and account recovery during the trial, including the flows customers actually use.

Does every Keycloak customer need a separate realm?

A separate realm can be useful when the customer needs a distinct identity configuration or issuer. It increases configuration, monitoring, key management and rollout work. A shared realm with explicit organisation mapping may better fit a SaaS product with users who work in multiple accounts. Choose based on the required boundary and operational design.

Can I move accounts from Auth0 to Keycloak without disruption?

Some account data and identity relationships can be migrated, but password, factor enrolment and session portability depend on your configuration and access to data. Plan for reset or re-enrolment where necessary. Keep application IDs stable, use an approved linking process and test recovery and rollback with a limited user cohort.

Further reading

Comparing Keycloak and Auth0 for enterprise single sign-on? Talk to Dumb Potato about an architecture review or a trial that measures the same identity flows and cost drivers.

Dumb Potato Editorial

Putting this into practice?

Share the problem you’re solving and the tradeoffs you’re weighing with our engineering team.

See how we help with application security

Discuss your project