Show HN: TwerkOS – A WorkOS Clone. Built on Keycloak 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. 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 for WorkOS AuthKit and the WorkOS SDKs run against it by changing only their configuration, and teams manage it from an admin UI that uses WorkOS's concepts and terms. Try it with your agent. Paste this into Claude Code or another coding agent: Start TwerkOS locally using the setup guide at https://raw.githubusercontent.com/xgp/TwerkOS/main/docs/quickstart.md Or follow the quickstart https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md yourself: one docker run , then the admin UI, a plain OpenID Connect app and WorkOS's AuthKit example, in about ten minutes. 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 . Keycloak https://www.keycloak.org is an open-source identity and access management server. It keeps users, credentials and sessions. It runs sign-in for OpenID Connect, OAuth 2.0 and SAML applications, and brokers sign-in to other identity providers. Everything in it can be extended through service-provider interfaces SPIs . TwerkOS uses Phase Two's Keycloak https://github.com/p2-inc/phasetwo-containers , which adds organizations keycloak-orgs , an SSO setup wizard idp-wizard , an Admin Portal, magic links and email themes. On top of that, it adds one extension, an admin UI and a sign-in theme: | WorkOS concept | In TwerkOS | |---|---| | 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 | | 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 | | 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 | | 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 | | SSO connections, Admin Portal | Keycloak identity providers SAML and OIDC , set up through Phase Two's idp-wizard and Admin Portal | | Applications, API keys | Keycloak clients with client … IDs; hashed sk … keys in the extension's tables | | Sessions, events, webhooks | The extension's own tables, fed by Keycloak's event listener; webhooks go through an outbox with retries | | 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 | It is checked with unchanged SDKs: @workos-inc/node 12.4.0 and @workos-inc/authkit-nextjs 4.6.3, workos Python 10.9.0, and @workos-inc/node 12.3.0 as a regression pin. The claim covers the operations in supported-operations.md https://github.com/xgp/TwerkOS/blob/main/docs/supported-operations.md ; the last runs are in conformance/evidence/RESULTS.md https://github.com/xgp/TwerkOS/blob/main/conformance/evidence/RESULTS.md . - Open source core. Keycloak is Apache-licensed and a CNCF project, with no per-user pricing and no closed core. TwerkOS is Apache-licensed too. - Security hardened over a decade. Keycloak has been in production since 2014 at very large deployments. It has a public security process and regular releases. TwerkOS adds WorkOS's API on top of it; it does not replace Keycloak's credential, session or token handling. - Full protocol compliance. OpenID Connect Keycloak is OpenID certified , OAuth 2.0 with PKCE, SAML 2.0, identity brokering, WebAuthn passkeys and OTP. Applications that speak these protocols can use the same environment as WorkOS-SDK applications step 4 of the quickstart does . - You own the stack. It runs on your infrastructure, with your database, your signing keys and your users' data. You can extend any part of it with Keycloak's SPIs. An application moves by changing its WorkOS settings: WORKOS API HOSTNAME with WORKOS API PORT and WORKOS API HTTPS if needed , a new API key, and its client ID. What changes, and what helps today: - Data. workos-keycloak-migrator https://github.com/xgp/workos-keycloak-migrator copies users, organizations, memberships, roles with their permissions, and directory users from the WorkOS API into a Keycloak realm. It can re-run idempotently and keep syncing through WorkOS webhooks until you switch 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 with PUT /admin/realms/{realm}/workos/environment extension/README.md https://github.com/xgp/TwerkOS/blob/main/extension/README.md . The migrator and TwerkOS share these conventions, but they have not yet been run together end to end. - Passwords. WorkOS does not export password hashes. The migrator's slow-migration extension checks a user's password against WorkOS at their first sign-in, then keeps it in Keycloak. - Client IDs can be kept: an application can be created with your existing client … ID operator API, or an environment template https://github.com/xgp/TwerkOS/blob/main/docs/templates.md . - API keys and webhook secrets cannot be exported; create new ones. - Sessions do not move; users sign in once more. - SSO connections. WorkOS does not export IdP secrets or SSO URLs, so the migrator creates stub connections to complete. Each customer's identity provider also needs TwerkOS's callback URLs; the Admin Portal link gives their IT team the setup wizard. - Not covered. Directory Sync, Audit Logs, Fine-Grained Authorization and some other products answer 501 not-implemented.md https://github.com/xgp/TwerkOS/blob/main/docs/not-implemented.md . Behaviour that differs from WorkOS is listed 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 . | Read | For | |---|---| | docs/quickstart.md https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md | Try it locally, by hand or with a coding agent | | docs/docker.md https://github.com/xgp/TwerkOS/blob/main/docs/docker.md | Run the image in production quay.io/garth/twerkos | | docs/templates.md https://github.com/xgp/TwerkOS/blob/main/docs/templates.md | Environment templates: environments, users and team members from a JSON file | | 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 | | 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 | | docs/data-model.md https://github.com/xgp/TwerkOS/blob/main/docs/data-model.md | What the extension stores, and what stays in Keycloak | | extension/README.md https://github.com/xgp/TwerkOS/blob/main/extension/README.md | The extension: settings, operator API, configuration keys | | .dev/ https://github.com/xgp/TwerkOS/blob/main/.dev/README.md | For contributors: design decisions, specifications, plans and the development stack | | Path | What | |---|---| | 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 | | stack/ | Docker Compose for development: Postgres, Keycloak Phase Two's image , Caddy TLS , Mailpit. setup/ builds the environments | | 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 | | demo/ | The quickstart's demo template and its OpenID Connect app docs/quickstart.md https://github.com/xgp/TwerkOS/blob/main/docs/quickstart.md | | 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 | | 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 | | tools/ | The webhook sample builder; the scripts behind the docs' screenshots and the demo video tools/media/ | | .dev/ | Contributor material: decisions, specifications, plans, the development stack's guide, captures | | bin/poc | One entry point | Contributors: start with .dev/README.md https://github.com/xgp/TwerkOS/blob/main/.dev/README.md , which indexes the design decisions, the specifications and the development stack's guide. Prerequisites: Docker, Java 21+, Maven, Node 22+, Google Chrome; uv and Python 3.13 for the Python suite. bin/poc up build the extension, start the stack https://env-a.localhost:8443, https://env-b.localhost:8443, http://localhost:8090 bin/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 bin/poc apps example app :3000 env-a , :3001 env-b , :3004 env-c ; switch harness :3002; custom UI :5176 env-d bin/poc test all suites on the regression pins; writes conformance/evidence/twerkos/ SDK SET=latest bin/poc apps && SDK SET=latest bin/poc test the same on the latest SDK set; writes conformance/evidence/twerkos-latest/ bin/poc python the Python SDK suite against env-c; writes conformance/evidence/python/ bin/poc emulator the target-agnostic suites against @workos/emulate, for comparison bin/poc down bin/poc setup issues new API keys, so run bin/poc apps after it. The app servers trust the stack's local CA through NODE EXTRA CA CERTS set by the scripts . Keycloak admin: https://kc.localhost:8443/admin admin/admin, local only . Mail: http://127.0.0.1:18025 . Test users password correct horse battery staple : dana@acme.test Acme admin, Umbrella and Globex member , solo@umbrella.test Umbrella admin , nobody@example.test no organization ; at the corporate IdP: sam@globex.test , gina@globex.test , ian@initech.test , olly@outside.test . Licence: Apache License 2.0, see LICENSE . The Phase Two extensions in the base image keycloak-orgs and others keep their own licences.