Skip to content

Commit 90c081d

Browse files
Merge branch 'master' into feat/get-path-should-append-existing-query-strings
2 parents 8d91ee8 + aa0ac5b commit 90c081d

File tree

15 files changed

+566
-39
lines changed

15 files changed

+566
-39
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ coverage.out
1212

1313
.DS_Store
1414
.vscode
15+
.idea
1516
www/dist/
1617
www/.DS_Store
1718
www/node_modules

README.md

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It is originally based on the excellent
1616

1717
If you wish to contribute to the project, please refer to the [contributing guide](/CONTRIBUTING.md).
1818

19-
## Table Of Contents
19+
## Table of Contents
2020

2121
- [Quick Start](#quick-start)
2222
- [Running in Production](#running-in-production)
@@ -25,9 +25,9 @@ If you wish to contribute to the project, please refer to the [contributing guid
2525

2626
## Quick Start
2727

28-
Create a `.env` file to store your own custom env vars. See [`example.env`](example.env)
28+
Create a `.env` file to store your own custom environment variables. See [`example.env`](example.env)
2929

30-
1. Start the local postgres database in a postgres container: `docker-compose -f docker-compose-dev.yml up postgres`
30+
1. Start the local Postgres database in a Postgres container: `docker-compose -f docker-compose-dev.yml up postgres`
3131
2. Build the auth binary: `make build` . You should see an output like this:
3232

3333
```bash
@@ -37,22 +37,22 @@ GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/supabase/auth/cmd.Versi
3737

3838
3. Execute the auth binary: `./auth`
3939

40-
### If you have docker installed
40+
### If you have Docker installed
4141

4242
Create a `.env.docker` file to store your own custom env vars. See [`example.docker.env`](example.docker.env)
4343

4444
1. `make build`
4545
2. `make dev`
46-
3. `docker ps` should show 2 docker containers (`auth-auth-1` and `auth-postgres-1`)
47-
4. That's it! Visit the [health checkendpoint](http://localhost:9999/health) to confirm that auth is running.
46+
3. `docker ps` should show two Docker containers (`auth-auth-1` and `auth-postgres-1`)
47+
4. That's it! Visit the [health check endpoint](http://localhost:9999/health) to confirm that auth is running.
4848

4949
## Running in production
5050

5151
Running an authentication server in production is not an easy feat. We
5252
recommend using [Supabase Auth](https://supabase.com/auth) which gets regular
5353
security updates.
5454

55-
Otherwise, please make sure you setup a process to promptly update to the
55+
Otherwise, please make sure you set up a process to promptly update to the
5656
latest version. You can do that by following this repository, specifically the
5757
[Releases](https://github.com/supabase/auth/releases) and [Security
5858
Advisories](https://github.com/supabase/auth/security/advisories) sections.
@@ -65,8 +65,8 @@ further clarifications on backward compatibility guarantees:
6565
**Go API compatibility**
6666

6767
Auth is not meant to be used as a Go library. There are no guarantees on
68-
backward API compatibility when used this way regardless which version number
69-
changes.
68+
backward API compatibility when used this way regardless of which version
69+
number changes.
7070

7171
**Patch**
7272

@@ -145,9 +145,12 @@ comprehensive list of those features:
145145
3. Super admin via the `is_super_admin` column.
146146
4. Group information in JWTs via `GOTRUE_JWT_ADMIN_GROUP_NAME` and other
147147
configuration fields.
148-
5. Symmetrics JWTs. In the future it is very likely that Auth will begin
149-
issuing asymmetric JWTs (subject to configuration), so do not rely on the
150-
assumption that only HS256 signed JWTs will be issued long term.
148+
5. JWT signing. Supabase Auth supports asymmetric keys (RS256 by default;
149+
ECC/Ed25519 optional). HS256 is still supported for compatibility, but
150+
migrating to asymmetric keys is recommended for easier validation and
151+
rotation. Future deprecations will be announced in the changelog. See the
152+
[JWT Signing Keys](https://supabase.com/docs/guides/auth/signing-keys) and
153+
[JWTs guide](https://supabase.com/docs/guides/auth/jwts) for details.
151154

152155
Note that this is not an exhaustive list and it may change.
153156

@@ -158,7 +161,7 @@ compatibility with Auth:
158161

159162
1. Do not modify the schema managed by Auth. You can see all of the
160163
migrations in the `migrations` directory.
161-
2. Do not rely on schema and structure of data in the database. Always use
164+
2. Do not rely on the schema and the structure of data in the database. Always use
162165
Auth APIs and JWTs to infer information about users.
163166
3. Always run Auth behind a TLS-capable proxy such as a load balancer, CDN,
164167
nginx or other similar software.
@@ -180,7 +183,7 @@ The base URL your site is located at. Currently used in combination with other s
180183

181184
`URI_ALLOW_LIST` - `string`
182185

183-
A comma separated list of URIs (e.g. `"https://foo.example.com,https://*.foo.example.com,https://bar.example.com"`) which are permitted as valid `redirect_to` destinations. Defaults to []. Supports wildcard matching through globbing. e.g. `https://*.foo.example.com` will allow `https://a.foo.example.com` and `https://b.foo.example.com` to be accepted. Globbing is also supported on subdomains. e.g. `https://foo.example.com/*` will allow `https://foo.example.com/page1` and `https://foo.example.com/page2` to be accepted.
186+
A comma-separated list of URIs (e.g. `"https://foo.example.com,https://*.foo.example.com,https://bar.example.com"`) which are permitted as valid `redirect_to` destinations. Defaults to []. Supports wildcard matching through globbing. e.g. `https://*.foo.example.com` will allow `https://a.foo.example.com` and `https://b.foo.example.com` to be accepted. Globbing is also supported on subdomains. e.g. `https://foo.example.com/*` will allow `https://foo.example.com/page1` and `https://foo.example.com/page2` to be accepted.
184187

185188
For more common glob patterns, check out the [following link](https://pkg.go.dev/github.com/gobwas/glob#Compile).
186189

@@ -195,19 +198,19 @@ When signup is disabled the only way to create new users is through invites. Def
195198

196199
`GOTRUE_EXTERNAL_EMAIL_ENABLED` - `bool`
197200

198-
Use this to disable email signups (users can still use external oauth providers to sign up / sign in)
201+
Use this to disable email signups (users can still use external OAuth providers to sign up / sign in)
199202

200203
`GOTRUE_EXTERNAL_PHONE_ENABLED` - `bool`
201204

202-
Use this to disable phone signups (users can still use external oauth providers to sign up / sign in)
205+
Use this to disable phone signups (users can still use external OAuth providers to sign up / sign in)
203206

204207
`GOTRUE_RATE_LIMIT_HEADER` - `string`
205208

206209
Header on which to rate limit the `/token` endpoint.
207210

208211
`GOTRUE_RATE_LIMIT_EMAIL_SENT` - `string`
209212

210-
Rate limit the number of emails sent per hr on the following endpoints: `/signup`, `/invite`, `/magiclink`, `/recover`, `/otp`, & `/user`.
213+
Rate limit the number of emails sent per hour on the following endpoints: `/signup`, `/invite`, `/magiclink`, `/recover`, `/otp`, & `/user`.
211214

212215
`GOTRUE_PASSWORD_MIN_LENGTH` - `int`
213216

@@ -217,7 +220,7 @@ Minimum password length, defaults to 6.
217220

218221
`GOTRUE_SECURITY_REFRESH_TOKEN_ROTATION_ENABLED` - `bool`
219222

220-
If refresh token rotation is enabled, auth will automatically detect malicious attempts to reuse a revoked refresh token. When a malicious attempt is detected, gotrue immediately revokes all tokens that descended from the offending token.
223+
If refresh token rotation is enabled, auth will automatically detect malicious attempts to reuse a revoked refresh token. When a malicious attempt is detected, GoTrue immediately revokes all tokens that descended from the offending token.
221224

222225
`GOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVAL` - `string`
223226

@@ -247,7 +250,7 @@ Controls what endpoint Netlify can access this API on.
247250

248251
`API_EXTERNAL_URL` - `string` **required**
249252

250-
The URL on which Gotrue might be accessed at.
253+
The URL on which GoTrue might be accessed at.
251254

252255
`REQUEST_ID_HEADER` - `string`
253256

@@ -307,7 +310,7 @@ Auth has basic observability built in. It is able to export
307310

308311
To enable tracing configure these variables:
309312

310-
`GOTRUE_TRACING_ENABLED` - `boolean`
313+
`GOTRUE_TRACING_ENABLED` - `bool`
311314

312315
`GOTRUE_TRACING_EXPORTER` - `string` only `opentelemetry` supported
313316

@@ -498,7 +501,7 @@ To try out external authentication with Apple locally, you will need to do the f
498501
3. Generate the crt and key file. See [here](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) for more information.
499502
4. Generate the `GOTRUE_EXTERNAL_APPLE_SECRET` by following this [post](https://medium.com/identity-beyond-borders/how-to-configure-sign-in-with-apple-77c61e336003)!
500503

501-
### E-Mail
504+
### Email
502505

503506
Sending email is not required, but highly recommended for password recovery.
504507
If enabled, you must provide the required values below.
@@ -546,7 +549,7 @@ If you do not require email confirmation, you may set this to `true`. Defaults t
546549

547550
`MAILER_OTP_EXP` - `number`
548551

549-
Controls the duration an email link or otp is valid for.
552+
Controls the duration an email link or OTP is valid for.
550553

551554
`MAILER_URLPATHS_INVITE` - `string`
552555

@@ -740,6 +743,47 @@ Default Content (if template is unavailable):
740743

741744
Whether to send a notification email when a user's phone number is changed. Defaults to `false`.
742745

746+
`GOTRUE_MAILER_TEMPLATES_IDENTITY_LINKED_NOTIFICATION` - `string`
747+
748+
URL path to an email template to use when notifying a user that a new identity has been linked to their account. (e.g. `https://www.example.com/path-to-email-template.html`)
749+
`Email` and `Provider` variables are available.
750+
751+
Default Content (if template is unavailable):
752+
753+
```html
754+
<h2>A new identity has been linked</h2>
755+
756+
<p>
757+
A new identity ({{ .Provider }}) has been linked to your account {{ .Email }}.
758+
</p>
759+
<p>If you did not make this change, please contact support immediately.</p>
760+
```
761+
762+
`GOTRUE_MAILER_NOTIFICATIONS_IDENTITY_LINKED_ENABLED` - `bool`
763+
764+
Whether to send a notification email when a new identity is linked to a user's account. Defaults to `false`.
765+
766+
`GOTRUE_MAILER_TEMPLATES_IDENTITY_UNLINKED_NOTIFICATION` - `string`
767+
768+
URL path to an email template to use when notifying a user that an identity has been unlinked from their account. (e.g. `https://www.example.com/path-to-email-template.html`)
769+
`Email` and `Provider` variables are available.
770+
771+
Default Content (if template is unavailable):
772+
773+
```html
774+
<h2>An identity has been unlinked</h2>
775+
776+
<p>
777+
An identity ({{ .Provider }}) has been unlinked from your account {{ .Email
778+
}}.
779+
</p>
780+
<p>If you did not make this change, please contact support immediately.</p>
781+
```
782+
783+
`GOTRUE_MAILER_NOTIFICATIONS_IDENTITY_UNLINKED_ENABLED` - `bool`
784+
785+
Whether to send a notification email when an identity is unlinked from a user's account. Defaults to `false`.
786+
743787
`GOTRUE_MAILER_TEMPLATES_MFA_FACTOR_ENROLLED_NOTIFICATION` - `string`
744788

745789
URL path to an email template to use when notifying a user that they have enrolled in a new MFA factor. (e.g. `https://www.example.com/path-to-email-template.html`)
@@ -790,15 +834,15 @@ If you do not require phone confirmation, you may set this to `true`. Defaults t
790834

791835
`SMS_MAX_FREQUENCY` - `number`
792836

793-
Controls the minimum amount of time that must pass before sending another sms otp. The value is the number of seconds. Defaults to 60 (1 minute)).
837+
Controls the minimum amount of time that must pass before sending another SMS OTP. The value is the number of seconds. Defaults to 60 (1 minute).
794838

795839
`SMS_OTP_EXP` - `number`
796840

797-
Controls the duration an sms otp is valid for.
841+
Controls the duration an SMS OTP is valid for.
798842

799843
`SMS_OTP_LENGTH` - `number`
800844

801-
Controls the number of digits of the sms otp sent.
845+
Controls the number of digits of the SMS OTP sent.
802846

803847
`SMS_PROVIDER` - `string`
804848

@@ -825,7 +869,7 @@ Whether captcha middleware is enabled
825869

826870
`SECURITY_CAPTCHA_PROVIDER` - `string`
827871

828-
for now the only options supported are: `hcaptcha` and `turnstile`
872+
for now the only options supported are: hCaptcha and Turnstile
829873

830874
- `SECURITY_CAPTCHA_SECRET` - `string`
831875
- `SECURITY_CAPTCHA_TIMEOUT` - `string`
@@ -1080,7 +1124,7 @@ Returns:
10801124
}
10811125
```
10821126

1083-
Verify a phone signup or sms otp. Type should be set to `sms`.
1127+
Verify a phone signup or SMS OTP. Type should be set to `sms`.
10841128

10851129
```json
10861130
{
@@ -1130,7 +1174,7 @@ or show an account confirmed/welcome message in the case of `signup`, or direct
11301174

11311175
### **POST /otp**
11321176

1133-
One-Time-Password. Will deliver a magiclink or sms otp to the user depending on whether the request body contains an "email" or "phone" key.
1177+
One-Time-Password. Will deliver a magic link or SMS OTP to the user depending on whether the request body contains an "email" or "phone" key.
11341178

11351179
If `"create_user": true`, user will not be automatically signed up if the user doesn't exist.
11361180

@@ -1176,7 +1220,7 @@ Returns:
11761220
{}
11771221
```
11781222

1179-
when clicked the magic link will redirect the user to `<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=magiclink` (see `/verify` above)
1223+
When the magic link is clicked, it will redirect to `<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=magiclink` (see `/verify` above)
11801224

11811225
### **POST /recover**
11821226

@@ -1273,7 +1317,7 @@ Returns:
12731317
### **PUT /user**
12741318

12751319
Update a user (Requires authentication). Apart from changing email/password, this
1276-
method can be used to set custom user data. Changing the email will result in a magiclink being sent out.
1320+
method can be used to set custom user data. Changing the email will result in a magic link being sent out.
12771321

12781322
```json
12791323
{
@@ -1326,7 +1370,7 @@ headers: {
13261370
Logout a user (Requires authentication).
13271371

13281372
This will revoke all refresh tokens for the user. Remember that the JWT tokens
1329-
will still be valid for stateless auth until they expires.
1373+
will still be valid for stateless auth until they expire.
13301374

13311375
### **GET /authorize**
13321376

@@ -1342,11 +1386,11 @@ scopes=<optional additional scopes depending on the provider (email and name are
13421386

13431387
Redirects to provider and then to `/callback`
13441388

1345-
For apple specific setup see: <https://github.com/supabase/auth#apple-oauth>
1389+
For Apple-specific setup see: <https://github.com/supabase/auth#apple-oauth>
13461390

13471391
### **GET /callback**
13481392

1349-
External provider should redirect to here
1393+
External provider should redirect to this endpoint
13501394

13511395
Redirects to `<GOTRUE_SITE_URL>#access_token=<access_token>&refresh_token=<refresh_token>&provider_token=<provider_oauth_token>&expires_in=3600&provider=<provider_name>`
13521396
If additional scopes were requested then `provider_token` will be populated, you can use this to fetch additional data from the provider or interact with their services

example.env

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ GOTRUE_MAILER_SUBJECTS_INVITE="You have been invited"
3838
GOTRUE_MAILER_SUBJECTS_PASSWORD_CHANGED_NOTIFICATION="Your password has been changed"
3939
GOTRUE_MAILER_SUBJECTS_EMAIL_CHANGED_NOTIFICATION="Your email address has been changed"
4040
GOTRUE_MAILER_SUBJECTS_PHONE_CHANGED_NOTIFICATION="Your phone number has been changed"
41+
GOTRUE_MAILER_SUBJECTS_IDENTITY_LINKED_NOTIFICATION="A new identity has been linked"
42+
GOTRUE_MAILER_SUBJECTS_IDENTITY_UNLINKED_NOTIFICATION="An identity has been unlinked"
4143
GOTRUE_MAILER_SUBJECTS_MFA_FACTOR_ENROLLED_NOTIFICATION="MFA factor enrolled"
4244
GOTRUE_MAILER_SUBJECTS_MFA_FACTOR_UNENROLLED_NOTIFICATION="MFA factor unenrolled"
4345
GOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED="true"
@@ -51,13 +53,17 @@ GOTRUE_MAILER_TEMPLATES_EMAIL_CHANGE=""
5153
GOTRUE_MAILER_TEMPLATES_PASSWORD_CHANGED_NOTIFICATION=""
5254
GOTRUE_MAILER_TEMPLATES_EMAIL_CHANGED_NOTIFICATION=""
5355
GOTRUE_MAILER_TEMPLATES_PHONE_CHANGED_NOTIFICATION=""
56+
GOTRUE_MAILER_TEMPLATES_IDENTITY_LINKED_NOTIFICATION=""
57+
GOTRUE_MAILER_TEMPLATES_IDENTITY_UNLINKED_NOTIFICATION=""
5458
GOTRUE_MAILER_TEMPLATES_MFA_FACTOR_ENROLLED_NOTIFICATION=""
5559
GOTRUE_MAILER_TEMPLATES_MFA_FACTOR_UNENROLLED_NOTIFICATION=""
5660

5761
# Account changes notifications configuration
5862
GOTRUE_MAILER_NOTIFICATIONS_PASSWORD_CHANGED_ENABLED="false"
5963
GOTRUE_MAILER_NOTIFICATIONS_EMAIL_CHANGED_ENABLED="false"
6064
GOTRUE_MAILER_NOTIFICATIONS_PHONE_CHANGED_ENABLED="false"
65+
GOTRUE_MAILER_NOTIFICATIONS_IDENTITY_LINKED_ENABLED="false"
66+
GOTRUE_MAILER_NOTIFICATIONS_IDENTITY_UNLINKED_ENABLED="false"
6167
GOTRUE_MAILER_NOTIFICATIONS_MFA_FACTOR_ENROLLED_ENABLED="false"
6268
GOTRUE_MAILER_NOTIFICATIONS_MFA_FACTOR_UNENROLLED_ENABLED="false"
6369

@@ -108,7 +114,7 @@ GOTRUE_EXTERNAL_FIGMA_CLIENT_ID=""
108114
GOTRUE_EXTERNAL_FIGMA_SECRET=""
109115
GOTRUE_EXTERNAL_FIGMA_REDIRECT_URI="https://localhost:9999/callback"
110116

111-
# Gitlab OAuth config
117+
# GitLab OAuth config
112118
GOTRUE_EXTERNAL_GITLAB_ENABLED="false"
113119
GOTRUE_EXTERNAL_GITLAB_CLIENT_ID=""
114120
GOTRUE_EXTERNAL_GITLAB_SECRET=""
@@ -120,7 +126,7 @@ GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID=""
120126
GOTRUE_EXTERNAL_GOOGLE_SECRET=""
121127
GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI="http://localhost:9999/callback"
122128

123-
# Github OAuth config
129+
# GitHub OAuth config
124130
GOTRUE_EXTERNAL_GITHUB_ENABLED="false"
125131
GOTRUE_EXTERNAL_GITHUB_CLIENT_ID=""
126132
GOTRUE_EXTERNAL_GITHUB_SECRET=""
@@ -138,7 +144,7 @@ GOTRUE_EXTERNAL_NOTION_CLIENT_ID=""
138144
GOTRUE_EXTERNAL_NOTION_SECRET=""
139145
GOTRUE_EXTERNAL_NOTION_REDIRECT_URI="https://localhost:9999/callback"
140146

141-
# Twitter OAuth1 config
147+
# Twitter (X) OAuth1 config
142148
GOTRUE_EXTERNAL_TWITTER_ENABLED="false"
143149
GOTRUE_EXTERNAL_TWITTER_CLIENT_ID=""
144150
GOTRUE_EXTERNAL_TWITTER_SECRET=""
@@ -163,7 +169,7 @@ GOTRUE_EXTERNAL_KEYCLOAK_SECRET=""
163169
GOTRUE_EXTERNAL_KEYCLOAK_REDIRECT_URI="http://localhost:9999/callback"
164170
GOTRUE_EXTERNAL_KEYCLOAK_URL="https://keycloak.example.com/auth/realms/myrealm"
165171

166-
# Linkedin OAuth config
172+
# LinkedIn OAuth config
167173
GOTRUE_EXTERNAL_LINKEDIN_ENABLED="true"
168174
GOTRUE_EXTERNAL_LINKEDIN_CLIENT_ID=""
169175
GOTRUE_EXTERNAL_LINKEDIN_SECRET=""

0 commit comments

Comments
 (0)