{"slug": "show-hn-twerkos-a-workos-clone-built-on-keycloak", "title": "Show HN: TwerkOS – A WorkOS Clone. Built on Keycloak", "summary": "A developer released TwerkOS, an Apache-licensed, self-hosted open-source clone of WorkOS built on Keycloak and Phase Two's Keycloak extensions, which it says runs applications written for WorkOS AuthKit and the WorkOS SDKs after only a configuration change. TwerkOS maps WorkOS concepts onto Keycloak primitives — environments become realms, users and organizations become Keycloak users and Phase Two organizations, and AuthKit hosted sign-in becomes Keycloak authentication flows with a Keycloakify theme — and answers unimplemented WorkOS API routes with HTTP 501. The project reports conformance testing with unchanged SDKs, including @workos-inc/node 12.4.0, @workos-inc/authkit-nextjs 4.6.3 and the Python workos 10.9.0, with @workos-inc/node 12.3.0 as a regression pin, and offers a one-command docker run quickstart.", "body_md": "TwerkOS is a self-hosted, open-source stand-in for [WorkOS](https://workos.com), built on [Keycloak](https://keycloak.org) with [Phase Two's](https://phasetwo.io) extensions. Applications written\nfor WorkOS AuthKit and the WorkOS SDKs run against it by changing only their configuration, and teams\nmanage it from an admin UI that uses WorkOS's concepts and terms.\n\n**Try it with your agent.** Paste this into Claude Code or another coding agent:\n\n```\nStart TwerkOS locally using the setup guide at https://raw.githubusercontent.com/xgp/TwerkOS/main/docs/quickstart.md\n```\n\nOr follow [the quickstart](https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md) yourself: one `docker run`, then the admin UI, a plain\nOpenID Connect app and WorkOS's AuthKit example, in about ten minutes.\n\n*A one-minute tour of the quickstart's demo, at 1.5× speed. [Full-quality video (MP4)](https://github.com/xgp/TwerkOS/blob/main/docs/images/demo.mp4).*\n\n[Keycloak](https://www.keycloak.org) is an open-source identity and access management server. It\nkeeps users, credentials and sessions. It runs sign-in for OpenID Connect, OAuth 2.0 and SAML\napplications, and brokers sign-in to other identity providers. Everything in it can be extended\nthrough service-provider interfaces (SPIs). TwerkOS uses\n[Phase Two's Keycloak](https://github.com/p2-inc/phasetwo-containers), which adds organizations\n(keycloak-orgs), an SSO setup wizard (idp-wizard), an Admin Portal, magic links and email themes. On\ntop of that, it adds one extension, an admin UI and a sign-in theme:\n\n| WorkOS concept | In TwerkOS | \n|---|---|\n| Environment (Staging, Production) | A Keycloak realm, with its own hostname. A pre-matching filter routes WorkOS API paths ( `/user_management/…` ,`/organizations/…` ) on that hostname to the realm | \n| WorkOS API | The extension's REST resources, answering WorkOS's wire format (IDs, field order, errors, pagination), checked by acceptance suites through the unchanged SDKs. What it does not cover answers 501 ( [not-implemented.md](https://github.com/xgp/TwerkOS/blob/main/docs/not-implemented.md) ) | \n| Users, organizations, memberships, roles | Keycloak users, Phase Two organizations and their roles, with WorkOS IDs and fields stored as attributes ( [data-model.md](https://github.com/xgp/TwerkOS/blob/main/docs/data-model.md) ) | \n| AuthKit hosted sign-in | Keycloak authentication flows and a Keycloakify sign-in theme, bridged to WorkOS's `authorize` /`authenticate` . Codes use PKCE, and tokens are signed with the realm's keys | \n| SSO connections, Admin Portal | Keycloak identity providers (SAML and OIDC), set up through Phase Two's idp-wizard and Admin Portal | \n| Applications, API keys | Keycloak clients with `client_…` IDs; hashed`sk_…` keys in the extension's tables | \n| Sessions, events, webhooks | The extension's own tables, fed by Keycloak's event listener; webhooks go through an outbox with retries | \n| Dashboard and team | A React admin UI served by Keycloak from the master realm. Team members are master-realm users; their team roles grant Keycloak admin permissions on each environment | \n\nIt is checked with unchanged SDKs: `@workos-inc/node` 12.4.0 and `@workos-inc/authkit-nextjs` 4.6.3,\n`workos` (Python) 10.9.0, and `@workos-inc/node` 12.3.0 as a regression pin. The claim covers the\noperations in [supported-operations.md](https://github.com/xgp/TwerkOS/blob/main/docs/supported-operations.md); the last runs are in\n[conformance/evidence/RESULTS.md](https://github.com/xgp/TwerkOS/blob/main/conformance/evidence/RESULTS.md).\n\n- **Open source core.** Keycloak is Apache-licensed and a CNCF project, with no per-user pricing and\nno closed core. TwerkOS is Apache-licensed too.\n- **Security hardened over a decade.** Keycloak has been in production since 2014 at very large\ndeployments. It has a public security process and regular releases. TwerkOS adds WorkOS's API on\ntop of it; it does not replace Keycloak's credential, session or token handling.\n- **Full protocol compliance.** OpenID Connect (Keycloak is OpenID certified), OAuth 2.0 with PKCE,\nSAML 2.0, identity brokering, WebAuthn passkeys and OTP. Applications that speak these protocols\ncan use the same environment as WorkOS-SDK applications (step 4 of the quickstart does).\n- **You own the stack.** It runs on your infrastructure, with your database, your signing keys and\nyour users' data. You can extend any part of it with Keycloak's SPIs.\n\nAn application moves by changing its WorkOS settings: `WORKOS_API_HOSTNAME` (with `WORKOS_API_PORT` and\n`WORKOS_API_HTTPS` if needed), a new API key, and its client ID. What changes, and what helps today:\n\n- **Data.**[workos-keycloak-migrator](https://github.com/xgp/workos-keycloak-migrator) copies users,\norganizations, memberships, roles with their permissions, and directory users from the WorkOS API\ninto a Keycloak realm. It can re-run idempotently and keep syncing through WorkOS webhooks until you\nswitch over. It stores each object's WorkOS ID as`workos.id` , and TwerkOS serves those IDs, so`user_…` and`org_…` IDs in your database stay valid. Bind the migrated realm as an environment\nwith`PUT /admin/realms/{realm}/workos/environment` ([extension/README.md](https://github.com/xgp/TwerkOS/blob/main/extension/README.md) ).\nThe migrator and TwerkOS share these conventions, but they have not yet been run together end to\nend.\n- **Passwords.** WorkOS does not export password hashes. The migrator's slow-migration extension\nchecks a user's password against WorkOS at their first sign-in, then keeps it in Keycloak.\n- **Client IDs** can be kept: an application can be created with your existing`client_…` ID\n(operator API, or an[environment template](https://github.com/xgp/TwerkOS/blob/main/docs/templates.md) ).\n- **API keys and webhook secrets** cannot be exported; create new ones.\n- **Sessions** do not move; users sign in once more.\n- **SSO connections.** WorkOS does not export IdP secrets or SSO URLs, so the migrator creates stub\nconnections to complete. Each customer's identity provider also needs TwerkOS's callback URLs; the\nAdmin Portal link gives their IT team the setup wizard.\n- **Not covered.** Directory Sync, Audit Logs, Fine-Grained Authorization and some other products\nanswer 501 ([not-implemented.md](https://github.com/xgp/TwerkOS/blob/main/docs/not-implemented.md) ). Behaviour that differs from WorkOS is\nlisted under the stated limits in[supported-operations.md](https://github.com/xgp/TwerkOS/blob/main/docs/supported-operations.md) and in[admin-ui-differences.md](https://github.com/xgp/TwerkOS/blob/main/docs/admin-ui-differences.md) .\n\n| Read | For | \n|---|---|\n| [docs/quickstart.md](https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md) | Try it locally, by hand or with a coding agent | \n| [docs/docker.md](https://github.com/xgp/TwerkOS/blob/main/docs/docker.md) | Run the image in production ( `quay.io/garth/twerkos` ) | \n| [docs/templates.md](https://github.com/xgp/TwerkOS/blob/main/docs/templates.md) | Environment templates: environments, users and team members from a JSON file | \n| [docs/supported-operations.md](https://github.com/xgp/TwerkOS/blob/main/docs/supported-operations.md) ,[docs/not-implemented.md](https://github.com/xgp/TwerkOS/blob/main/docs/not-implemented.md) | What the WorkOS API covers, and what it does not | \n| [docs/admin-ui-differences.md](https://github.com/xgp/TwerkOS/blob/main/docs/admin-ui-differences.md) | Where the admin UI differs from WorkOS's dashboard | \n| [docs/data-model.md](https://github.com/xgp/TwerkOS/blob/main/docs/data-model.md) | What the extension stores, and what stays in Keycloak | \n| [extension/README.md](https://github.com/xgp/TwerkOS/blob/main/extension/README.md) | The extension: settings, operator API, configuration keys | \n| [.dev/](https://github.com/xgp/TwerkOS/blob/main/.dev/README.md) | For contributors: design decisions, specifications, plans and the development stack | \n\n| Path | What | \n|---|---|\n| `extension/` | The Keycloak provider JAR (Java 21, Keycloak 26.8.2, keycloak-orgs 0.200). Built to the Phase Two extension standards ( `extension/README.md` ,`extension/CLAUDE.md` ). Routing filter,`workos` realm resource and operator API, JPA store, token issuer, hosted bridge, headless grants; management writes, roles, invitations, portal links, event log, webhook outbox, Keycloak event listener, purge job | \n| `stack/` | Docker Compose for development: Postgres, Keycloak (Phase Two's image), Caddy (TLS), Mailpit. `setup/` builds the environments | \n| `Dockerfile` ,`docker/` | The image, built from source on `quay.io/phasetwo/phasetwo-keycloak` , and a production Compose file with Postgres ([docs/docker.md](https://github.com/xgp/TwerkOS/blob/main/docs/docker.md) ) | \n| `demo/` | The quickstart's demo template and its OpenID Connect app ( [docs/quickstart.md](https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md) ) | \n| `apps/` | Scripts to fetch the upstream example app and WorkOS's custom-UI example, each with only its SDK pins changed; the org-switch harness app; the outbound-request observer | \n| `conformance/` | Acceptance suites through the unchanged SDKs ( `node:test` , Playwright driving Google Chrome;`sdk-latest/` for the latest Node set,`python/` for the Python SDK), evidence, report | \n| `tools/` | The webhook sample builder; the scripts behind the docs' screenshots and the demo video ( `tools/media/` ) | \n| `.dev/` | Contributor material: decisions, specifications, plans, the development stack's guide, captures | \n| `bin/poc` | One entry point | \n\nContributors: start with [.dev/README.md](https://github.com/xgp/TwerkOS/blob/main/.dev/README.md), which indexes the design decisions, the\nspecifications and the development stack's guide.\n\nPrerequisites: Docker, Java 21+, Maven, Node 22+, Google Chrome; `uv` and Python 3.13 for the Python suite.\n\n```\nbin/poc up          # build the extension, start the stack (https://env-a.localhost:8443, https://env-b.localhost:8443, http://localhost:8090)\nbin/poc setup       # create environments env-a to env-d (with their roles and permissions) and the stand-in corporate IdP; writes local/stack.json (untracked: API keys)\nbin/poc apps        # example app :3000 (env-a), :3001 (env-b), :3004 (env-c); switch harness :3002; custom UI :5176 (env-d)\nbin/poc test        # all suites on the regression pins; writes conformance/evidence/twerkos/\nSDK_SET=latest bin/poc apps && SDK_SET=latest bin/poc test   # the same on the latest SDK set; writes conformance/evidence/twerkos-latest/\nbin/poc python      # the Python SDK suite against env-c; writes conformance/evidence/python/\nbin/poc emulator    # the target-agnostic suites against @workos/emulate, for comparison\nbin/poc down\n```\n\n`bin/poc setup` issues new API keys, so run `bin/poc apps` after it. The app servers trust the\nstack's local CA through `NODE_EXTRA_CA_CERTS` (set by the scripts). Keycloak admin:\n`https://kc.localhost:8443/admin` (admin/admin, local only). Mail: `http://127.0.0.1:18025`.\n\nTest users (password `correct horse battery staple`): `dana@acme.test` (Acme admin, Umbrella and\nGlobex member), `solo@umbrella.test` (Umbrella admin), `nobody@example.test` (no organization);\nat the corporate IdP: `sam@globex.test`, `gina@globex.test`, `ian@initech.test`, `olly@outside.test`.\n\nLicence: Apache License 2.0, see `LICENSE`. The Phase Two extensions in the base image (keycloak-orgs and others) keep their own licences.", "url": "https://wpnews.pro/news/show-hn-twerkos-a-workos-clone-built-on-keycloak", "canonical_source": "https://github.com/xgp/TwerkOS", "published_at": "2026-12-04 14:35:50+00:00", "updated_at": "2026-12-04 14:47:28.849592+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["TwerkOS", "WorkOS", "Keycloak", "Phase Two", "AuthKit", "@workos-inc/node", "@workos-inc/authkit-nextjs", "Claude Code"], "also_reported_by": [], "takeaway": "TwerkOS lets apps built on WorkOS AuthKit and the WorkOS SDKs run against self-hosted Keycloak by changing only configuration, with unimplemented WorkOS API routes returning HTTP 501.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-twerkos-a-workos-clone-built-on-keycloak", "markdown": "https://wpnews.pro/news/show-hn-twerkos-a-workos-clone-built-on-keycloak.md", "text": "https://wpnews.pro/news/show-hn-twerkos-a-workos-clone-built-on-keycloak.txt", "jsonld": "https://wpnews.pro/news/show-hn-twerkos-a-workos-clone-built-on-keycloak.jsonld"}}