What does auth TCO actually include for Keycloak and Auth0?

Comparing a Keycloak license (free) with an Auth0 subscription (not free) tells you almost nothing. Total cost of ownership (TCO) counts everything you pay to keep login working, secure, and audited over several years: money, engineering hours, and the risk you absorb. That is the only basis on which build and buy can be compared fairly.

With Auth0, the cost is mostly the vendor bill. It depends on monthly active users (MAUs), the plan tier, the number of enterprise connections such as SAML or OIDC federation for B2B customers, and features that only higher tiers include, often MFA options, advanced attack protection, and longer log retention. Published list prices are a starting point. Contracts at scale are usually negotiated, so get a real quote for your projected MAUs and connection count before you model anything.

With Keycloak, the bill is spread across your own budget: compute, a highly available database, engineering time for upgrades and configuration, on-call coverage, and security and compliance work such as patching, pen-test scope, and audit evidence.

Some costs exist either way. Wiring authorization into your applications, mapping roles and claims, and handling token validation correctly cost the same whichever option you choose. Leave them out of both columns, or put them in both.

Cost category Keycloak (self-hosted) Auth0 (managed)
License/subscription None MAU- and tier-based, negotiated
Infrastructure and database You pay and operate Included
Upgrades and patching Your engineers Vendor
On-call for login outages Your rotation Vendor SLA, plus your escalation path
Enterprise SSO connections Configuration effort Often priced per connection or tier
Advanced security features Build, configure, or integrate Gated to higher tiers
Compliance evidence You produce it Partly vendor-provided
App-side authorization Shared Shared

Why do teams use Keycloak or Auth0 instead of writing their own login?

Both are identity providers (IdPs). They exist so that your applications don't have to store passwords, implement MFA, handle account recovery, or speak SAML to every enterprise customer's directory. Teams adopt one for a few concrete reasons:

  • Standard protocols. Both implement OpenID Connect (OIDC), OAuth 2.0 and SAML 2.0. Your applications integrate once against a standard and get login, token issuance and federation without custom crypto or session code.
  • Single sign-on across applications. One identity and one session serve every product you run, instead of a separate user table per service.
  • Federation. Both can broker logins from social providers and from corporate identity systems over SAML or OIDC. Keycloak can also federate users from LDAP or Active Directory.
  • Security features in one place. Password policies, MFA, brute-force protection and session revocation live in the IdP, not scattered across codebases.
  • Audit surface. Login events, admin changes and token issuance are recorded in one system, which is what auditors ask about.

The choice between them is not about these capabilities, which overlap heavily. It is about who operates the system and how you pay for it. That is why the rest of this article is a cost model rather than a feature comparison.

How do Keycloak and Auth0 work?

From an application's point of view, both work the same way. The application redirects the user to the IdP's authorization endpoint. The IdP authenticates the user with a password, MFA, a social login or an upstream enterprise IdP. It then redirects back with an authorization code, which the application exchanges for an ID token and an access token. The application validates those tokens with the IdP's public signing keys, published as a JWKS document. APIs validate access tokens the same way, without calling the IdP on every request.

The differences are in where that IdP runs and how you configure it:

  • Keycloak is an open-source Java server that you deploy and operate. Configuration is organised into realms, which are isolated tenants holding users, clients (the applications allowed to request tokens), roles, identity provider links and authentication flows. You can extend it with SPIs, for example custom authenticators, user storage providers or password hash providers. It needs a relational database and, for more than one node, a distributed cache. The next section covers that setup.
  • Auth0 is a hosted service. You get a tenant and configure applications, connections (database, social and enterprise sources of users) and the hosted login page through a dashboard or the Management API. Custom logic runs in Auth0's extensibility features, such as Actions, at defined points in the login flow. The vendor runs the infrastructure, upgrades and availability.

Because the protocol surface is the same, an application written against standard OIDC can switch between them by changing configuration. The migration section shows how.

Who should use this TCO model?

This model is for the people who have to sign off on the decision and then live with it:

  • Engineering leads and CTOs choosing an IdP for a new product or consolidating several login systems into one.
  • Platform and SRE teams asked whether they can take on a self-hosted, tier-zero identity service, and what it would cost them in on-call and upgrade work.
  • B2B SaaS teams whose enterprise customers demand per-customer SAML or OIDC federation, which is where managed pricing tends to step up.
  • Teams approaching an Auth0 renewal or a tier change, who need to know whether moving to Keycloak would actually be cheaper once engineering time is counted.
  • Teams already running Keycloak who want to check whether the engineering time it consumes is still justified.

If you have a handful of users and no enterprise SSO requirements, the managed free or entry tiers usually make the analysis unnecessary. The model matters once MAUs, enterprise connections or compliance scope start to grow.

How does a highly available Keycloak deployment work, and what does it cost to run?

A production Keycloak cluster has three moving parts, and each one can take down login for every product you run.

            clients / apps
                  |
          [ load balancer ]
           /      |      \
   [ KC node ] [ KC node ] [ KC node ]
        \    distributed cache    /
         \   (sessions, tokens)  /
          \         |           /
        [ relational DB: primary + replica ]
  • Stateless-looking nodes behind a load balancer. Keycloak nodes sit behind a load balancer and serve the login and token endpoints.
  • A shared relational database. The database holds realms, clients and users. It needs automated failover, backups and tested restores.
  • A distributed cache. The cache replicates sessions and login state between nodes. If it is misconfigured, users are silently logged out during node restarts or rolling upgrades.

An outage in any of these breaks more than one feature. Every user of every application stops being able to sign in or refresh tokens. Identity therefore needs a higher availability target than most internal services, along with redundancy across zones and an on-call rotation.

The configuration example below shows the settings your team owns: the database connection, the public hostname, proxy headers and the cache stack. Exact option names have changed across Keycloak versions, so check the documentation for your release.

Illustrative estimate (assumed numbers, not a benchmark):

Monthly cost = (nodes × node cost) + DB cost + LB cost + (engineer FTE fraction × loaded salary ÷ 12)

Assumed inputs: 3 nodes × $150, a $400 HA database, a $50 load balancer and 0.5 FTE × $180,000.

  • Infrastructure: (3 × $150) + $400 + $50 = $900 per month
  • People: 0.5 × $180,000 ÷ 12 = $7,500 per month
  • Total: about $8,400 per month

Under these assumptions, compute is roughly a tenth of the total, and engineering time is the main cost.

services:
  keycloak:
    # Pin an exact tag and upgrade on purpose, with a rolling-upgrade plan.
    image: quay.io/keycloak/keycloak:${KEYCLOAK_VERSION}
    command: start
    environment:
      # Shared relational DB. Point this at the HA endpoint, not a single host.
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://db-primary.internal.example:5432/keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: ${KC_DB_PASSWORD}   # inject from a secret store

      # Public URL that goes into tokens and redirects. Every node must use the same value.
      KC_HOSTNAME:

      # TLS ends at the load balancer. Trust its forwarded headers.
      KC_PROXY_HEADERS: xforwarded
      KC_HTTP_ENABLED: "true"

      # Distributed cache, so sessions survive node restarts.
      # jdbc-ping discovers peers through the DB on recent releases.
      # Older releases use stacks such as tcp, udp or kubernetes.
      KC_CACHE: ispn
      KC_CACHE_STACK: jdbc-ping

      # Endpoints for LB health checks and monitoring.
      KC_HEALTH_ENABLED: "true"
      KC_METRICS_ENABLED: "true"
    ports:
      - "8080:8080"   # traffic from the load balancer only
      - "7800:7800"   # JGroups cluster traffic between nodes; keep it private

A Docker Compose definition for one Keycloak cluster node that shows the settings your team must own and keep consistent on every node: the database connection, public hostname, proxy headers, cache stack and health endpoints.

What are the real people costs of self-hosting Keycloak?

That engineering share breaks down into a few distinct kinds of work.

Initial build. Someone has to design the realm structure, configure clients and their redirect URIs and scopes, theme the login pages to match your product, federate external identity providers such as corporate SAML or social login, and migrate existing users. Password hashes are often the hardest part of a migration. If your current hashes use an algorithm Keycloak doesn't support natively, you need a custom provider or a forced reset.

Ongoing operations. This includes major-version upgrades, monitoring token endpoints and database health, tested backups, and incident response. The hidden costs sit inside the upgrades:

  • CVE response. When a security advisory lands, your patching speed depends on your team, not a vendor's.
  • Breaking customizations. Custom themes and SPIs (Service Provider Interfaces, Keycloak's extension points) that rely on internal APIs can break between releases. Each extension adds regression testing to every upgrade.
  • Schema migrations. Upgrades can change the database schema. On large user tables, you need to rehearse these migrations and plan for downtime.
  • Load tuning. Under traffic spikes, token issuance and session storage need tuning.

Staffing floor. Auth is a tier-zero dependency, so at least two people need to understand it. If only one does, every vacation and every resignation becomes an outage risk.

Neglect. A well-built deployment that nobody upgrades keeps working while it accumulates unpatched vulnerabilities. When you finally upgrade, you face a multi-version jump with stacked schema and API changes.

Compliance. For SOC 2 or HIPAA, your Keycloak infrastructure, access controls, and change processes all fall inside your audit scope.

How do you calculate the Keycloak vs Auth0 break-even point?

Every number below is an assumption chosen for illustration. None of it is a measured result or a real price quote. Replace each input with your own vendor quote, cloud bill, and salary data.

Inputs (all assumed)

  • MAU: 200,000
  • Auth0 effective price: $0.05 per MAU per month. This is a placeholder blended rate, not published pricing.
  • Keycloak infrastructure: $1,500/month for a 3-node cluster plus managed Postgres, backups, and load balancer.
  • Loaded engineer cost: $200,000/year
  • Engineering time on Keycloak: 0.4 FTE (baseline)

The formula

Annual Keycloak cost = infra_monthly × 12 + FTE × loaded_salary. Annual Auth0 cost = MAU × price_per_MAU × 12.

Setting the two equal gives the break-even MAU. In a spreadsheet, that is =(B2*12 + B3*B4) / (B5*12), where B2 is monthly infra, B3 is FTE, B4 is salary, and B5 is the per-MAU price.

At baseline, Keycloak costs $98,000/year and Auth0 costs $120,000/year. The break-even point is about 163,000 MAU.

Sensitivity on FTE

The FTE input is the least certain one. Teams usually size it for steady-state operation. They often leave out upgrade projects, incident response, and compliance work.

Scenario FTE Keycloak annual Break-even MAU Cheaper at 200k MAU
Optimistic 0.2 $58,000 ~97,000 Keycloak
Baseline 0.4 $98,000 ~163,000 Keycloak
Pessimistic 0.75 $168,000 280,000 Auth0

Illustrative estimate.

Infrastructure barely affects the result. The FTE figure decides it. If you can't defend your FTE number with real on-call and upgrade history, use the pessimistic row.

MAU = 200_000
PRICE_PER_MAU = 0.05      # assumed blended $/MAU/month, not published pricing
INFRA_MONTHLY = 1_500     # assumed: 3 nodes + managed Postgres, backups, LB
LOADED_SALARY = 200_000   # assumed loaded cost per engineer per year

SCENARIOS = {"optimistic": 0.2, "baseline": 0.4, "pessimistic": 0.75}


def keycloak_annual(fte):
    # Fixed cost: infra plus engineering time. Mostly independent of MAU.
    return INFRA_MONTHLY * 12 + fte * LOADED_SALARY


def auth0_annual(mau):
    # Variable cost: grows linearly with MAU under this simplified model.
    return mau * PRICE_PER_MAU * 12


def break_even_mau(fte):
    # Solve keycloak_annual(fte) == auth0_annual(mau) for mau.
    return keycloak_annual(fte) / (PRICE_PER_MAU * 12)


print(f"Auth0 at {MAU:,} MAU: ${auth0_annual(MAU):,.0f}/yr")
print(f"{'scenario':<12} {'FTE':>5} {'Keycloak/yr':>12} {'break-even':>11}  cheaper")
for name, fte in SCENARIOS.items():
    kc = keycloak_annual(fte)
    cheaper = "Keycloak" if kc < auth0_annual(MAU) else "Auth0"
    print(f"{name:<12} {fte:>5} {kc:>12,.0f} {break_even_mau(fte):>11,.0f}  {cheaper}")

A small Python script that computes the Keycloak vs Auth0 break-even MAU and reruns it across optimistic, baseline, and pessimistic FTE assumptions; all inputs are illustrative placeholders to replace with your own figures.

Which cost drivers scale nonlinearly, and what are Auth0's hidden costs?

A per-MAU line in a spreadsheet assumes cost grows smoothly with users. Several drivers grow in steps or curves instead, and they land on different sides of the build-vs-buy ledger.

Driver Mainly raises Why it is nonlinear
Per-customer SAML/OIDC enterprise connections (B2B SaaS) Auth0 bill Connections are capped or priced per plan, so one new enterprise customer can force a tier change.
Machine-to-machine token volume Auth0 bill M2M tokens are metered separately from user logins. Services that don't cache tokens multiply the count.
Multi-region availability Keycloak effort Cross-region cache replication, database failover and failover testing become your design and on-call problem.
Compliance audits Keycloak effort You must evidence patching, access control and logging for an IdP you operate.

Auth0's hidden costs

  • Tier jumps. A single requirement can force an upgrade, and the higher plan is often priced across your whole user base. Common triggers are custom domains, enterprise SSO, longer log retention and extensibility features.
  • Rate limits. The Management and Authentication APIs throttle requests. Bulk imports, directory sync jobs and login spikes can return 429s. You then need batching and backoff, or a higher plan.
  • Roadmap and renewal risk. You get little say in feature deprecations or price changes at renewal, and you have less leverage once integrations are deep.

What the spreadsheet undercounts

Auth0 absorbs IdP upgrades, CVE patching and availability on-call. A salary line rarely captures the unplanned week when a critical Keycloak advisory lands mid-sprint. Vendor attestations, such as SOC 2 reports, can also replace evidence you would otherwise produce yourself. Confirm the current scope of those reports with the vendor before relying on them in an audit.

How do you migrate between Auth0 and Keycloak without lock-in?

Migration cost is mostly set by three things you can't move cleanly: password hashes, user identifiers, and live sessions.

Password hashes. Auth0 does not expose hashes through its Management API. Bulk hash export goes through a support request, so you can't schedule it on your own timeline. Keycloak can import hashes only for algorithms it supports, and some formats require a custom password hash provider. If a bulk transfer is impractical, use lazy migration instead. Both platforms can verify a user's password against the old system at first login and store it locally: Auth0 through custom database connections, Keycloak through its User Storage SPI. The trade-off is that you run both systems until the long tail of inactive users either logs in or is retired.

User IDs. The sub claim changes when the issuer changes. If your database uses sub as the primary key, every foreign key breaks during cutover. Store your own internal user ID and map it to an (issuer, sub) pair. A migration then only adds a new mapping row instead of rewriting tables.

Sessions and refresh tokens. Tokens are signed by the old issuer's keys, so they won't validate against the new one. Plan for a forced re-login and tell users ahead of time. Shorter refresh token lifetimes in the weeks before cutover reduce the number of stale tokens still in use.

To keep exit cost low, write clients against standard OIDC. Configure only the issuer URL, discover endpoints and keys from /.well-known/openid-configuration, and read standard claims such as sub, email, and email_verified. Avoid Auth0 Actions-injected claims and vendor SDK helpers in core paths. Under those rules, the same client configuration works against either IdP.

Given this, starting with Auth0 and planning an exit is a sound strategy, as long as you design for the exit from the first day.

import os
from flask import Flask, url_for, session
from authlib.integrations.flask_client import OAuth

app = Flask(__name__)
app.secret_key = os.environ["FLASK_SECRET_KEY"]

ISSUER = os.environ["OIDC_ISSUER"]

oauth = OAuth(app)
oauth.register(
    name="idp",
    client_id=os.environ["OIDC_CLIENT_ID"],
    client_secret=os.environ["OIDC_CLIENT_SECRET"],
    server_metadata_url=ISSUER.rstrip("/") + "/.well-known/openid-configuration",
    client_kwargs={"scope": "openid email profile"},  # standard scopes only
)

@app.route("/login")
def login():
    return oauth.idp.authorize_redirect(url_for("callback", _external=True))

@app.route("/callback")
def callback():
    token = oauth.idp.authorize_access_token()  # validates the ID token against discovered JWKS
    claims = token["userinfo"]
    # Key users by (iss, sub), never by sub alone: sub changes when the issuer changes.
    user_id = lookup_or_create_user(
        issuer=claims["iss"],
        subject=claims["sub"],
        email=claims.get("email") if claims.get("email_verified") else None,
    )
    session["user_id"] = user_id  # internal ID, stable across IdP migrations
    return "ok"

def lookup_or_create_user(issuer, subject, email):
    # Placeholder: SELECT user_id FROM identities WHERE issuer=%s AND subject=%s;
    # on a miss, link to an existing user by verified email or create one, then insert a mapping row.
    raise NotImplementedError

A Flask client built on Authlib that configures only the issuer, discovers endpoints and keys, reads only standard claims, and maps each (iss, sub) pair to an internal user ID, so the same code runs against Auth0 or Keycloak.

How can the right choice save engineering time?

Either option saves time compared with building authentication yourself. The real question is where each one saves time and where it costs time.

Compared with writing your own auth. Both IdPs remove work that is easy to get wrong and expensive to audit: password hashing and storage, MFA enrolment, account recovery, session management, token signing and key rotation, and SAML integration with customer directories. Application teams integrate against OIDC once and reuse that integration in every service.

Where Auth0 saves time. The vendor handles upgrades, CVE patching, scaling and availability on-call. Those are the line items that dominate the Keycloak column in the model above. For a team without spare operations capacity, this is the most direct saving.

Where Keycloak saves time. Deep customization can be faster when you own the server. Custom authentication flows, unusual claims, or per-tenant realms can be built as SPIs or configuration, without working around plan limits or API rate limits. Bulk imports and directory syncs aren't throttled by a vendor quota, so you can skip batching-and-backoff code you would otherwise need.

Where both save time through design choices. The provider-agnostic client pattern in the migration section saves a rewrite later. If clients use only standard OIDC discovery and claims, and users are keyed by (issuer, sub), a future IdP change is a configuration change and a data migration, not an application rewrite across every service.

Where the model itself saves time. The sensitivity table shows that the FTE input decides the outcome. That tells you where to spend analysis effort: pull your actual upgrade, incident and audit hours instead of debating infrastructure prices that barely move the result.

Illustrative estimate (assumed inputs, not a measurement): at the baseline assumption of 0.4 FTE and an assumed 2,080 working hours per year, self-hosted Keycloak consumes about 0.4 × 2,080 ≈ 830 engineering hours per year. If buying instead frees most of those hours, the question becomes whether the Auth0 bill costs less than what those hours would otherwise produce on your product. Replace both assumed figures with your own data.

When should you build with Keycloak, buy Auth0, or consider alternatives?

Four questions settle most build-vs-buy decisions:

  • Do we already run stateful, highly available services well? If your team operates clustered databases with tested failover and real on-call rotations, Keycloak is one more workload of a familiar kind. If it doesn't, Keycloak will be the first system where an outage locks every user out.
  • Is identity core to our product? Custom login flows, unusual token claims, or multi-tenant federation as a selling point justify owning the stack. If login is plumbing, buy it.
  • What do enterprise customers require? Contractual data residency in specific regions, or per-customer SAML and OIDC federation at volume, favour self-hosting. Managed tiers often gate those features behind higher plans.
  • What does our MAU growth curve look like? Steep, predictable growth toward the break-even point favours building. Flat or uncertain growth favours buying.

Self-host if you have operational identity expertise, strict residency needs, or need deep customization and predictable pricing. Avoid it if you are a small team without on-call depth. Saved license fees don't cover a 3 a.m. auth outage that nobody is equipped to fix.

There are also alternatives to consider. Other managed identity providers have different pricing models. Other open-source IdPs vary in feature depth and operational weight. Managed Keycloak hosting gives you Keycloak's data model and portability while someone else runs it.

Signal Build (Keycloak) Buy (Auth0) Buy, plan exit
HA ops maturity Strong Weak Growing
Identity is core Yes No Not yet
Residency/SSO demands Strict Standard Emerging
MAU trajectory Large, predictable Small or flat Rising, uncertain
On-call depth Dedicated Minimal Building

How OneEnv can help

Disclosure: OneEnv is the product behind this blog.

OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.

Applied to keycloak vs auth0 cost, this is where it helps:

Saves time

  • Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
  • One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
  • Changing a shared variable is one edit and one review instead of editing every service's .env by hand.

Saves cost

  • Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
  • Less duplicated configuration to maintain: one shared definition inherited by many services.
  • A wrong or stale value is caught at review time by the services it affects, not by a failed deploy.
  • OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.

These are qualitative benefits, not measured results — how much you save depends on how many services share the value.

Want to try it? Start at oneenv.io.