auth: Broken Invitation Links - http://kong is the domain
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Currently, when sending an invitation to a user, the invitation link in the email is http://kong/auth/v1/verify?token=xxx rather than the proper domain.
To Reproduce
Steps to reproduce the behaviour, please provide code snippets or a repository:
- Setup docker Supabase
- Go to the authentication
- Click “Add user”
- Select “Send Invitation”
- Check the invitation link in the email
Expected behaviour
It was expected that the invitation URL to contain the configured URLs in the .env file rather than http://kong as the domain.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 49 (6 by maintainers)
Commits related to this issue
- fix: external host validation (#1808) Adds a new config option `GOTRUE_MAILER_EXTERNAL_HOSTS` that serves as an allowlist to all the acceptable hosts provided to the APIs. Fixes #1228 — committed to supabase/auth by hf 2 years ago
- chore(master): release 2.163.1 (#1809) :robot: I have created a release *beep* *boop* --- ## [2.163.1](https://github.com/supabase/auth/compare/v2.163.0...v2.163.1) (2024-10-22) ### Bug ... — committed to supabase/auth by github-actions[bot] 2 years ago
This was bugging me hard. So I added a force no-change environment variable and submitted a PR.
With the changes:
API_EXTERNAL_URLenvironment variable as you normally would.API_FORCE_EXTERNAL_URLto equal true..env:
Kubernetes:
Fix repo: nickmitchko/auth Fix container (latest): nickmitchko/gotrue:latest Fix PR: #1571
@Vokturz, @Chipsnet, @hf
I’m not sure if anyone has realized but in the docker-compose.yml it states
SUPABASE_URL: http://kong/changing this to use theAPI_EXTERNAL_URLvariable should solve your issue. Or so one would think I have changed it to the local ip and i am getting it in the email link but I don’t get the port. Which in my case is 8000 the api is supposed to be directed too.hi everyone, we fixed this issue recently by specifying a new config param -
GOTRUE_MAILER_EXTERNAL_HOSTSwhich specifies the list of hosts that can be used. If this is empty, it will just default to use theAPI_EXTERNAL_URLthis is somewhat similar to the suggestion @nickmitchko proposed but we’re solving it with an allow list rather than a flag to disable it
MAILER_URLPATHS_CONFIRMATION=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_INVITE=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_RECOVERY=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_EMAIL_CHANGE=“${API_EXTERNAL_URL}/auth/v1/verify”
this works
I’m facing the same problem. My temporary fix is to switch to “supabase/gotrue:v2.67.0” in my docker-compose.yml
There is some breaking change in a minor release:
v2.67.1(https://github.com/supabase/gotrue/compare/v2.67.0...v2.67.1).In our case, after upgrading Docker image to anything above
v2.67.1(including current latest) turns the account confirmation URL fromhttpstohttps, there are also some other minor changes.v2.67.0 (correct)
v2.67.1 (broken)
I’ve tried to reproduce this outside of the docker environment, kong etc. by injecting our configuration through
.env, so I can run the debugger onmain.go. I’ve set up breakpoints on:ConfirmationMailandisValidExternalHostand problem doesn’t exist for some reason.Unfortunately I don’t have much time currently to add some additional logging to the code, compile the binary and debug/run it from the Docker context, to understand at which stage the URL does get broken.
I am experiencing a similar issue with the storage API,
createSignedUrlin the js SDK is returning a URL with kong:8000 as the domain.In the docker-compose.yml file there is a line SUPABASE_URL: http://kong Replace that with your project’s URL, then stop and create the containers again:
This worked for me and the Invite emails are now giving the correct link.
@Obeyed just tested again on latest supabase version 1.25.03, adding GOTRUE_MAILER_EXTERNAL_HOST get rid of the error. So was probably a problem with the version i was trying to deploy. The noop part was a misnamed env var for the smtp host. Mail are finally being sent ! Thanks for your help
Check my repo for the changes I made and build your own fork. IMO the change that introduced this issue was bad logic that can easily be changed.
Ps, I don’t update the fork nickmitchko/auth.
However, this means that STUDIO will attempt to access kong from the outside
For security reasons, it is recommended that studio access kong from within the docker container
While helpful in the short term, this problem needs to be fixed in the long term.
Hi @Obeyed, I am not sure if I can help here. In our case we’re running fork with a couple amendments. Most importantly this line needs changing: https://github.com/supabase/gotrue/commit/c1f0ec8da6e8c19361789cb3d182a4c77c2763e5#diff-97dfc3310e5139b4d9c7a160bd077aeb81ca1e7b8d7cfa837a402f54b4c03a3dR213
Given that Supabase team is likely busy with other items your best bet is either to wait or apply it yourself and build a Docker image, alternatively use our build:
s3drive/gotrue:v2.129.1(https://hub.docker.com/layers/s3drive/gotrue/v2.129.1/images/sha256-a8176564a48f34b20598884848f284ed78cb8db0b5d44fea20d2ed8d37a4eab9?context=explore) which is the most recent Supabase version with these two fixes applied: https://github.com/supabase/gotrue/compare/master...tomekit:gotrue:master however please be aware that you shouldn’t really use unofficial images for your organization… after all it’s auth.Good luck !