Skip to content

Commit 3a94202

Browse files
authored
Document New Supabase auth - addition of JWT secret (#47)
* New Supabase auth * More supabase auth references
1 parent 8ac6040 commit 3a94202

File tree

11 files changed

+43
-44
lines changed

11 files changed

+43
-44
lines changed
71.2 KB
Loading
71.4 KB
Loading
107 KB
Loading

images/integration-2.png

-17.5 KB
Binary file not shown.

images/integration-4.png

-165 KB
Binary file not shown.

installation/authentication-setup/supabase-auth.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ You can implement various types of auth:
1717
* [Example](https://github.com/powersync-ja/powersync-jwks-example/)
1818
* Experimental: We've also heard from the community that Supabase's newly released [support for external auth providers works](https://supabase.com/blog/third-party-auth-mfa-phone-send-hooks), but we don't have any examples for this yet.
1919

20-
<Note>
21-
The "Supabase Auth" setting no longer works for Supabase projects created after 25 November 2024. While we are working with Supabase on a fix, please apply this workaround: https://releases.powersync.com/announcements/important-notice-for-supabase-users-using-supabase-jwts
22-
</Note>
20+
To implement either **Supabase Auth** or **Anonymous Sign-Ins**, enable the "Use Supabase Auth" setting on the PowerSync instance, and provide your Supabase JWT Secret. Internally, this setting allows PowerSync to verify and use Supabase JWTs directly using HS256 and the provided secret.
2321

24-
To implement either Supabase Auth or Anonymous Sign-Ins, enable the "Use Supabase Auth" setting on the PowerSync instance. (This is also [covered in the Supabase & PowerSync integration guide](/integration-guides/supabase-+-powersync#configuring-powersync))
22+
Enabling Supabase Auth is also [covered in the Supabase & PowerSync integration guide](/integration-guides/supabase-+-powersync#configuring-powersync).
2523

26-
Internally, Supabase auth signs the token using HS256, using a secret available as `current_setting('app.settings.jwt_secret')` on the database.
24+
To rotate the secret, generate a new secret in the your Supabase project's API Settings:
2725

28-
To rotate the secret, generate a new secret in the Supabase project settings. The new secret will be automatically picked up by PowerSync within 5 minutes. In this period, some authentication failures are expected.
26+
<Frame>
27+
<img src="/images/authentication/supabase-jwt-secret.png"/>
28+
</Frame>
2929

30-
The Supabase user UUID will be available as `token_parameters.user_id`. To use a different identifier as the user ID in sync rules (for example user email), use [Custom authentication](/installation/authentication-setup/custom).
30+
The Supabase user UUID will be available as `request.user_id()` in Sync Rules. To use a different identifier as the user ID in sync rules (for example user email), use [Custom authentication](/installation/authentication-setup/custom).

self-hosting/appendix/database-connection.mdx

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,34 @@ Below, you can find provider-specific instructions to obtain connection details
88

99
<AccordionGroup>
1010
<Accordion title="Supabase">
11-
1. In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab.
12-
2. Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.
13-
14-
<Frame>
15-
<img src="/images/self-hosting-3.avif"/>
16-
</Frame>
17-
1. Copy the connection string. The hostname should be `db.<PROJECT-ID>.supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`.
18-
2. Paste this URI into the `uri` field under `replication` \> `connections` in your configuration file, for example:
19-
20-
```yaml
21-
# config.yaml
22-
23-
replication:
24-
connections:
25-
- type: postgresql
26-
uri: postgresql://postgres:[YOUR-PASSWORD]@db.abc.supabase.co:5432/postgres
27-
```
28-
29-
1. Replace `[YOUR-PASSWORD]` with the password for the `postgres` user in your Supabase database.
30-
* Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_.
31-
2. PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates.
32-
3. Under `client_auth` enable Supabase Auth:
33-
34-
```yaml
35-
client_auth:
36-
supabase: true
37-
```
11+
1. In your Supabase dashboard, navigate to **"Project Settings"** \-> **"Database" -> "Connection string**" and select the "URI" tab.
12+
2. Uncheck the "**Display connection pooler**" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.
13+
<Frame>
14+
<img src="/images/self-hosting-3.avif"/>
15+
</Frame>
16+
3. Copy the connection string. The hostname should be `db.<PROJECT-ID>.supabase.co`, and not, for example, `aws-0-us-west-1.pooler.supabase.com`.
17+
4. Paste this URI into the `uri` field under `replication` \> `connections` in your configuration file, for example:
18+
19+
```yaml
20+
# config.yaml
21+
22+
replication:
23+
connections:
24+
- type: postgresql
25+
uri: postgresql://postgres:[YOUR-PASSWORD]@db.abc.supabase.co:5432/postgres
26+
```
27+
28+
5. Replace `[YOUR-PASSWORD]` with the password for the `postgres` user in your Supabase database.
29+
* Supabase also [refers to this password](https://supabase.com/docs/guides/database/managing-passwords) as the _database password_ or _project password_.
30+
6. PowerSync has the Supabase CA certificate pre-configured — `verify-full` SSL mode can be used directly, without any custom certificates.
31+
7. Under `client_auth` enable Supabase Authentication:
32+
33+
```yaml
34+
client_auth:
35+
supabase: true
36+
supabase_jwt_secret: [secret]
37+
```
38+
For more details, see [Supabase Auth](/installation/authentication-setup/supabase-auth).
3839
</Accordion>
3940
<Accordion title="AWS RDS">
4041
Add your connection details under `replication` \> `connections` in your configuration file.

self-hosting/installation/client-side-setup.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ If you are using Supabase or Firebase authentication, PowerSync can verify JWTs
9797

9898
### Supabase Auth
9999

100-
Under `client_auth` in your config file, enable `supabase` authentication:
100+
Under `client_auth` in your config file, enable Supabase authentication:
101101

102102
```yaml
103103
# config.yaml
104104
105105
client_auth:
106106
# Enable this if using Supabase Auth
107107
supabase: true
108+
supabase_jwt_secret: [secret]
108109
```
109110

110111
For more details, see [Supabase Auth](/installation/authentication-setup/supabase-auth).

self-hosting/installation/powersync-service-setup.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ sync_rules:
113113
client_auth:
114114
# Enable this if using Supabase Auth
115115
# supabase: true
116+
# supabase_jwt_secret: [secret]
116117
117118
# JWKS URIs can be specified here.
118119
jwks_uri: http://demo-backend:6060/api/auth/keys

snippets/create-cloud-instance.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
1. In the [PowerSync Dashboard](/usage/tools/powersync-dashboard) Project tree, click on "**Create new instance**":
22

33
<Frame>
4-
<img src="/images/integration-2.png" width="60%" />
4+
<img src="/images/installation/create-new-instance.png" width="60%" />
55
</Frame>
66

77
2. Give your instance a name, such as "Testing".

0 commit comments

Comments
 (0)