Skip to content

Ostiary: a self-hosted, open-source Auth0 alternative

Ostiary is an open-source Auth0 alternative you host yourself, built on Better Auth: an OpenID Connect provider, passkeys, SSO and an admin console.

Published on Updated on 7 min read

If you are looking for a self-hosted Auth0 alternative, you probably want two things at once: the building blocks of a hosted identity platform (one sign-in for all your apps, social login, passkeys, enterprise SSO, an admin console) and the ownership that comes with running it yourself. Ostiary is an open-source identity provider built for exactly that. It is a Next.js app you deploy, MIT licensed, built on Better Auth, and your users live in your own Postgres database.

This post explains what Ostiary provides, how it differs from adding Better Auth to each of your apps, and when a hosted platform is still the better choice.

What Ostiary is

Ostiary is a standalone identity provider. Your applications do not import it; they talk to it over open standards. It is an OAuth 2.1 and OpenID Connect provider, so any app that speaks OIDC can sign in with it: a Next.js or Remix app, a mobile app using AppAuth, a CLI, or an API that verifies tokens.

The repository is a small TypeScript monorepo:

apps/auth       Sign-in, sign-up, consent, OIDC endpoints, account dashboard
apps/admin      Admin console (optional): users, clients, organizations, SSO, audit
packages/core   Better Auth configuration, database schema and migrations, emails, UI, translations

Both apps run the same Better Auth configuration against one database. The admin app only exposes an allowlist of auth endpoints; sign-in and the OIDC protocol stay on the auth app.

The name comes from the ostiarius, the doorkeeper of the Middle Ages: the one who held the keys and decided who came in. That is the job: one front door in front of every app you ship.

What you get

The feature list mirrors what you would otherwise rent from a hosted platform. Everything below is described in the README and the guides in docs/.

For your users

  • Email and password with verification, username sign-in and password reset.
  • Passwordless sign-in with a 6-digit code sent by email, and passkeys (WebAuthn). See passkeys in a self-hosted identity server.
  • Two-factor authentication with an authenticator app (TOTP) and backup codes.
  • Social sign-in with every Better Auth provider (Google, Apple, Microsoft, GitHub and 32 more), set up from the admin console, plus Google One Tap.
  • Enterprise single sign-on with OIDC or SAML 2.0, once the company proves its email domain with a DNS record.
  • An account dashboard: profile, sessions, passkeys, connected accounts, connected apps, and Your data, where people export everything as JSON or delete their account.
  • 20 locales, in light and dark themes.

For your apps

  • An OAuth 2.1 / OpenID Connect provider: discovery, PKCE, refresh tokens, consent, UserInfo, introspection and JWKS. The details are in running an OpenID Connect provider on Better Auth.
  • Machine-to-machine tokens (client credentials) with per-client scopes, and API keys for scripts.
  • Device sign-in (RFC 8628) for CLIs, TVs and other apps without a browser.
  • JWT access tokens scoped to your APIs, with the user's role as a claim.
  • Custom claims per application in the ID token, access token and UserInfo: fixed values or user attributes such as the role or the active organization, declared in the console, with no scripts.
  • Organizations with members, roles and invitations, and SCIM 2.0 provisioning per organization. See SAML SSO and organizations for B2B apps.
  • Self-registration for MCP clients and AI agents through Dynamic Client Registration or Client ID Metadata Documents, off by default. See OAuth for MCP clients.
  • Webhooks signed with the Standard Webhooks headers, retried, with a delivery log.

For you: the admin console

  • Users: search, roles, bans, sessions, impersonation and two-factor reset.
  • User import from an Auth0 export or a CSV file, with a dry run first; imported bcrypt password hashes keep working. See migrating users from Auth0.
  • Sign-in providers turned on and off without a redeploy, with their credentials stored encrypted.
  • OAuth clients, organizations, SSO providers, API keys and an App usage page.
  • Sign-in branding per application: display name, logo, accent color (with WCAG contrast checks) and tagline.
  • An audit log of every admin action, plus sign-in activity and failed sign-in monitoring. The users list and the audit log export to CSV.
  • Signing keys with automatic rotation on a schedule, or rotation on demand, and a grace period during which old tokens keep verifying.

Ostiary or Better Auth on its own?

Better Auth is a TypeScript authentication framework. You add it to an application, and that application handles its own sign-in. That is a great fit for a single app.

Ostiary answers a different question: what if you have several apps and want one account, one sign-in and one place to manage users? It runs Better Auth as a separate identity provider, and your apps connect to it with OpenID Connect instead of each embedding its own auth. On top of Better Auth's plugins, the Ostiary repository adds the parts that turn a library into a product:

  • An admin console, as a second app sharing the same database, with the audit log, signing key management, sign-in providers, SSO providers, organizations and per-app branding.
  • Guards for self-registered clients. Clients that register themselves may only request the scopes you allow, use the authorization code flow with PKCE, and always see the consent screen. An anonymous registration always becomes a public client: Better Auth would otherwise default it to a confidential client and hand back a secret.
  • Locked-down management endpoints. Only platform admins manage OAuth clients and SSO providers, from the admin console; Better Auth's own endpoints for them are closed.
  • Rate limits that hold on serverless. Better Auth counts requests per client IP and endpoint; Ostiary keeps those counts in Postgres instead of each server's memory, because on Vercel every function instance has its own memory.
  • A guard in front of the SAML ACS. SAML runs on Better Auth's @better-auth/sso plugin; Ostiary adds the console, checks on the identity provider's metadata, and refuses responses with a DOCTYPE, entity declarations, or SHA-1 signatures.
  • Branding per app, safely. Sign-in screens can show the app a person came from, but only for clients registered by an admin. Self-registered clients get an Unverified app warning, and Ostiary's own mark stays on every screen.
  • Data export and account deletion covering the GDPR rights of access, portability and erasure, described in Your data.
  • Translations, emails and a deployment path: 20 locales, and a Vercel template whose build applies the database migrations.

If you only need sign-in inside one app, Better Auth alone may be all you need. If you want a central identity provider that your apps, CLIs and AI agents share, Ostiary saves you from assembling those pieces yourself.

Your data stays in your database

Everything Ostiary stores lives in your Postgres database: accounts, sessions, OAuth clients, consents, audit entries. There is no per-user pricing; it costs what your hosting costs. And because the code is a readable monorepo under the MIT license, you can audit it, fork it, or change how it behaves.

Standard protocols keep you flexible in the other direction too. Ostiary does not ship an SDK you have to adopt: your apps use the OIDC library they already have, configured with the issuer URL, a client ID and a secret. The Connect an app guide shows the Auth.js setup, and the landing page has the same example.

When a hosted platform is the better choice

Owning your identity layer also means operating it. Ostiary does not come with compliance certifications or a service-level agreement. The README says it plainly: Ostiary is a good fit when you want to own your identity layer; if you need a managed service with compliance certifications and an SLA, a hosted platform is the better choice. The comparison table on the home page lists the same trade-off.

Ostiary is also a young project: its first release, 0.1.0, is listed in the changelog. It already runs in production at Cyber Auth, the single sign-on for CyberCTF, Cyber Courses and Cyber Bench.

Try it

If you want the overview first, the feature list on the home page shows every building block at a glance.

Related articles

How Ostiary turns Better Auth's OAuth provider plugin into a self-hosted OpenID Connect server: discovery, clients, API scopes, signing keys, device flow.
Move users from Auth0 to Ostiary with a dry run first. Imported bcrypt hashes keep working and become scrypt at sign-in, with no password reset.
How Ostiary tells your apps when users change: user and membership webhook events, Standard Webhooks signatures, retries, and a receiver to copy.