Skip to content

Commit 01ec753

Browse files
adela-bytebasetianzhouCopilot
authored
docs: add open source pg auth blog (#893)
* add open source pg auth * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Tianzhou <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 0be0105 commit 01ec753

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
title: Top Open-Source Postgres Auth Solutions in 2025
3+
author: Adela
4+
updated_at: 2025/09/22 09:15:26
5+
feature_image: /content/blog/top-open-source-postgres-auth-solution/cover.webp
6+
tags: Industry
7+
description: Top open-source Postgres authentication solutions for 2025.
8+
---
9+
10+
**Postgres has become the go-to database for modern apps. But authentication (who a user is) and authorization (what they can do) are just as critical.**
11+
12+
In 2025, you have plenty of open-source options. To make it simple, here are the most relevant solutions, grouped by type, with clear "best for" recommendations.
13+
14+
## 1. Platforms (Postgres + Auth bundled)
15+
16+
These give you Postgres, authentication, and APIs in one package. Ideal if you want **RLS (Row Level Security) to work out of the box**.
17+
18+
### 🔹 [Supabase Auth](https://supabase.com/docs/guides/auth)
19+
20+
![Supabase Auth](/content/blog/top-open-source-postgres-auth-solution/supabase-auth.webp)
21+
22+
- **Features:** Email/password, magic links, OAuth, phone, Web3 logins.
23+
- **Integration:** Deep RLS support (`auth.uid()`, `auth.jwt()` directly usable in policies).
24+
- **Third-party support:** Can trust IdPs like Clerk, Firebase Auth, Cognito, WorkOS, etc. but only if they issue **asymmetric JWTs**. Key rotation can lag \~30 min. Supabase Auth itself can’t be disabled.
25+
- **Best for:** Startups and teams that want the **fastest path** to secure Postgres apps.
26+
27+
### 🔹 [Nhost](https://nhost.io/product/auth) (Hasura-based)
28+
29+
![Nhost](/content/blog/top-open-source-postgres-auth-solution/nhost-auth.webp)
30+
31+
- **Features:** Postgres + Hasura GraphQL API + Auth.
32+
- **Integration:** Auth ties into Hasura permissions, which map back to Postgres RLS.
33+
- **Best for:** Teams building **GraphQL-first apps** who want a fully open-source stack.
34+
35+
## 2. Libraries (you own the server)
36+
37+
These plug into your backend, store users in Postgres, and issue JWTs. You stay in control.
38+
39+
### 🔹 [Auth.js](https://authjs.dev/)
40+
41+
![Auth.js](/content/blog/top-open-source-postgres-auth-solution/authjs.webp)
42+
43+
- **Features:** 50+ OAuth providers, session handling, JWT support.
44+
- **Integration:** Postgres adapter for users and sessions.
45+
- **Best for:** Apps with custom backends, especially **Next.js** or full-stack JS.
46+
47+
### 🔹 [Better Auth](https://better-auth.com/)
48+
49+
![better-auth](/content/blog/top-open-source-postgres-auth-solution/better-auth.webp)
50+
51+
- **Features:** TypeScript-first, supports multi-tenancy, 2FA, org management.
52+
- **Integration:** Native Postgres support with Kysely/Drizzle + schema migration tooling.
53+
- **Best for:** **TypeScript-heavy teams** who want modern DX and self-hosted control.
54+
55+
### 🔹 [Lucia](https://lucia-auth.com/) (maintenance mode)
56+
57+
![lucia](/content/blog/top-open-source-postgres-auth-solution/lucia-auth.webp)
58+
59+
- **Features:** Educational focus, lightweight packages.
60+
- **Status:** v3 is deprecated, supported only until March 2025.
61+
- **Best for:** Existing projects. Not recommended for new ones.
62+
63+
## 3. Identity Servers (standalone IdP)
64+
65+
These are separate services that act as the **source of truth for identity**. They issue JWTs for your apps.
66+
67+
### 🔹 [Ory Kratos](https://www.ory.sh/kratos/)
68+
69+
- **Features:** Registration, recovery, passwordless login, customizable flows.
70+
- **Integration:** Uses Postgres as identity store; issues JWTs consumed by RLS.
71+
- **Best for:** Centralized identity across multiple services.
72+
73+
### 🔹 [Keycloak](https://www.keycloak.org/)
74+
75+
- **Features:** Enterprise-grade IdP with OIDC, SAML, LDAP, and multi-realm/org support.
76+
- **Integration:** Runs on Postgres and issues JWTs for your apps.
77+
- **Best for:** Large orgs needing **enterprise SSO** and federation features.
78+
79+
### 🔹 [ZITADEL](https://zitadel.com/)
80+
81+
- **Features:** Modern IdP with org/project/role management.
82+
- **Integration:** Postgres/Cockroach backend; OIDC → Postgres RLS.
83+
- **Best for:** Cloud-native teams who want a modern, OSS alternative to commercial IdPs.
84+
85+
## 4. Other OSS Options
86+
87+
### 🔹 [SuperTokens](https://supertokens.com/)
88+
89+
- **Features:** Recipes for email/password, social login, passwordless, session management.
90+
- **Integration:** Native Postgres support; cloud or self-host.
91+
- **Best for:** Developers who want **prebuilt flows** but remain OSS-first.
92+
93+
## 5. [Postgres-Native Pattern](/blog/postgres-native-pattern/) (minimalist)
94+
95+
You can also skip heavy auth systems:
96+
97+
- Issue JWTs (from a small service or IdP).
98+
- Validate them at the API edge (PostgREST, Supabase, or a proxy).
99+
- Let **RLS** enforce access inside Postgres.
100+
101+
**Best for:** Small-to-mid apps where you want **maximum simplicity** and DB-driven auth.
102+
103+
104+
## Comparison Table
105+
106+
| Solution | Type | Hosting | Postgres Integration | Learning Curve | Best for |
107+
| --------------------------- | -------------------- | ----------------- | -------------------------- | -------------- | ----------------------------- |
108+
| Supabase Auth | Platform (BaaS) | Cloud / Self-host | Native (RLS, JWT helpers) | Low | Startups, all-in-one apps |
109+
| Nhost | Platform (GraphQL) | Cloud / Self-host | Hasura + RLS | Medium | GraphQL-first teams |
110+
| Auth.js | Library | Self-host | Postgres adapter | Medium | Flexible, multi-provider apps |
111+
| Better Auth | Library | Self-host | Native schema + migrations | Medium | TypeScript-first projects |
112+
| Lucia (v3) | Library (deprecated) | Self-host | Postgres adapter | High | Legacy projects only |
113+
| Ory Kratos | Identity server | Self-host | Postgres identity store | High | Multi-app identity |
114+
| Keycloak | Identity server | Self-host | Native Postgres | High | Enterprise SSO |
115+
| ZITADEL | Identity server | Self-host / Cloud | Postgres/Cockroach backend | Medium | Cloud-native IdP |
116+
| SuperTokens | Library / Service | Cloud / Self-host | Native Postgres | Medium | Prebuilt flows |
117+
| Postgres-native (JWT → RLS) | Pattern | Self-host | Direct via RLS claims | Low | Minimalist DB-driven |
118+
119+
## Conclusion
120+
121+
- **Fastest startup path****Supabase Auth**
122+
- **GraphQL-first stack****Nhost**
123+
- **Custom backend****Auth.js** or **Better Auth**
124+
- **Enterprise / multi-app identity****Keycloak, Ory Kratos, ZITADEL**
125+
- **Minimalist & DB-driven** → Postgres-native JWT → RLS
126+
- **Prebuilt recipes****SuperTokens**
127+
128+
No matter which tool you pick, the principle is the same: **JWT claims flow into Postgres RLS**, making the database itself the final gatekeeper.
70.6 KB
Loading
52.4 KB
Loading
35 KB
Loading
101 KB
Loading
88.9 KB
Loading
109 KB
Loading

0 commit comments

Comments
 (0)