You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before generating JWTs for PostgreSQL, create the database role referenced by the token's `role` claim and grant it the permissions CloudSync needs.
498
+
499
+
### 8a. Create and grant the JWT role
500
+
501
+
Create the role:
502
+
503
+
```bash
504
+
cd /data/cloudsync-postgres
505
+
docker compose exec db psql -U postgres -d postgres -c "CREATE ROLE rls_role NOLOGIN;"
506
+
```
507
+
508
+
Grant schema and table permissions on current and future tables:
509
+
510
+
```bash
511
+
cd /data/cloudsync-postgres
512
+
docker compose exec db psql -U postgres -d test_database_1 -c "GRANT USAGE ON SCHEMA public TO rls_role;"
513
+
docker compose exec db psql -U postgres -d test_database_1 -c "GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO rls_role;"
514
+
docker compose exec db psql -U postgres -d test_database_1 -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO rls_role;"
515
+
docker compose exec db psql -U postgres -d test_database_1 -c "GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO rls_role;"
516
+
docker compose exec db psql -U postgres -d test_database_1 -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO rls_role;"
517
+
```
518
+
519
+
Allow the connection-string user to switch into that role:
520
+
521
+
```bash
522
+
cd /data/cloudsync-postgres
523
+
docker compose exec db psql -U postgres -d postgres -c "GRANT rls_role TO postgres;"
524
+
```
525
+
526
+
Verify:
527
+
528
+
```bash
529
+
cd /data/cloudsync-postgres
530
+
docker compose exec db psql -U postgres -d postgres -c "SELECT rolname, rolsuper, rolcanlogin, rolbypassrls FROM pg_roles WHERE rolname = 'rls_role';"
Copy file name to clipboardExpand all lines: docs/postgresql/quickstarts/postgres.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,8 @@ On the **Client Integration** tab you'll find your **Database ID** and authentic
129
129
130
130
The fastest way to test CloudSync without per-user access control — no JWT setup needed.
131
131
132
+
With API key authentication, CloudSync uses the database role resolved from the API-key-authenticated connection when available; otherwise it falls back to the role from the connection string.
1. Set **Row Level Security** to **Yes, enforce RLS**
141
143
2. Under **Authentication (JWT)**, click **Configure authentication** and choose:
142
-
- **HMAC Secret (HS256):** Enter your JWT secret (or generate one: `openssl rand -base64 32`)
143
-
- **JWKS Issuer Validation:** Enter the issuer base URL from your token's `iss` claim (e.g. `https://your-auth-domain`). CloudSync automatically fetches the JWKS document from `<issuer-url>/.well-known/jwks.json`
144
-
3. In your client code:
144
+
- **HMAC Secret (HS256):**
145
+
- Enter your JWT secret (or generate one: `openssl rand -base64 32`)
146
+
- Optionally add **Expected audiences**. When configured, a token's `aud` claim must contain at least one of the configured audience values.
147
+
- **JWKS Issuer Validation:**
148
+
- Enter the issuer base URL from your token's `iss` claim (for example `https://your-auth-domain`)
149
+
- By default, CloudSync uses OIDC discovery: it requests `<issuer>/.well-known/openid-configuration` and reads the returned `jwks_uri`
150
+
- Optionally set an **Explicit JWKS URI** to bypass OIDC discovery and use a specific JWKS endpoint directly. This must be a full HTTPS URI.
151
+
- Optionally add **Expected audiences**. When configured, a token's `aud` claim must contain at least one of the configured audience values.
152
+
3. CloudSync validates JWTs as follows:
153
+
- **HS256:** uses the configured JWT secret
154
+
- **JWKS:** uses the explicit `jwksUri` when provided; otherwise CloudSync requests `<issuer>/.well-known/openid-configuration` and reads `jwks_uri`
155
+
- CloudSync does not fall back directly to `<issuer>/.well-known/jwks.json` when discovery is used
Use the tag that matches your Supabase Postgres base image exactly. Convenience tags `sqlitecloud/sqlite-sync-supabase:15` and `sqlitecloud/sqlite-sync-supabase:17` are also published, but the exact Supabase tag is the safest choice.
24
+
Use the CloudSync image tag that matches your Supabase PostgreSQL major version. The published major tags `sqlitecloud/sqlite-sync-supabase:15` and `sqlitecloud/sqlite-sync-supabase:17` are the standard choice. Exact Supabase base-image tags may also be published for some releases, but they are optional and not required for normal setup.
@@ -130,6 +130,8 @@ On the **Client Integration** tab you'll find your **Database ID** and authentic
130
130
131
131
The fastest way to test CloudSync without per-user access control — no JWT setup needed.
132
132
133
+
With API key authentication, CloudSync uses the database role resolved from the API-key-authenticated connection when available; otherwise it falls back to the role from the connection string.
1. Set **Row Level Security** to **Yes, enforce RLS**
142
144
2. Under **Authentication (JWT)**, click **Configure authentication** and choose:
143
-
- **HMAC Secret (HS256):** Enter your `JWT_SECRET` from Supabase's `.env`
144
-
- **JWKS Issuer Validation:** Enter the issuer base URL from your token's `iss` claim (e.g. `https://your-auth-domain`). CloudSync automatically fetches the JWKS document from `<issuer-url>/.well-known/jwks.json`
145
-
3. In your client code:
145
+
- **HMAC Secret (HS256):**
146
+
- Enter your `JWT_SECRET` from Supabase's `.env`
147
+
- Optionally add **Expected audiences**. When configured, a token's `aud` claim must contain at least one of the configured audience values.
148
+
- **JWKS Issuer Validation:**
149
+
- Enter the issuer base URL from your token's `iss` claim (for example `https://your-auth-domain`)
150
+
- By default, CloudSync uses OIDC discovery: it requests `<issuer>/.well-known/openid-configuration` and reads the returned `jwks_uri`
151
+
- Optionally set an **Explicit JWKS URI** to bypass OIDC discovery and use a specific JWKS endpoint directly. This must be a full HTTPS URI.
152
+
- Optionally add **Expected audiences**. When configured, a token's `aud` claim must contain at least one of the configured audience values.
153
+
3. CloudSync validates JWTs as follows:
154
+
- **HS256:** uses the configured JWT secret
155
+
- **JWKS:** uses the explicit `jwksUri` when provided; otherwise CloudSync requests `<issuer>/.well-known/openid-configuration` and reads `jwks_uri`
156
+
- CloudSync does not fall back directly to `<issuer>/.well-known/jwks.json` when discovery is used
0 commit comments