auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

#107 : remove only Gotrue hash parameters from url after setting sess…

Open tartard opened this issue 4 years ago • 2 comments

…ion from Url.

What kind of change does this PR introduce?

Fixes #107

What is the current behavior?

After setting session from url, gotrue-js removes all the url hash. This can be a problem if the app uses a hash-based router, this would automatically redirect the user at the root location '#/' . This might not be the desired behavior for the developer, and currently the developer has no control over this behavior.

What is the new behavior?

After setting session from url, gotrue-js removes only the Gotrue parameters from the hash. This doesn't change other things which might be in the hash, like the path of the router.

tartard avatar Jul 29 '21 07:07 tartard

Really waiting for this pr to be merged. My Github Pages application cannot be connected via OAuth2 because of this hash removal bug. Also, why don't gotrue itself use query params for this purpose?

DavraYoung avatar Aug 20 '21 13:08 DavraYoung

thanks everyone for pitching in, we'll try and get this out asap

awalias avatar Aug 22 '21 12:08 awalias

hey @tartard and @sduduzog, thanks for taking the time to work on this PR. Unfortunately, i don't think this is the appropriate fix to enable your use-case with hash-based redirects in svelte.

@DavraYoung the tokens are placed behind a query fragment because gotrue follows an oauth2 protocol known as the implicit grant flow.

I've tried to reproduce the following cases with the correct redirect urls in the allow list:

  1. https://project-ref.supabase.co/auth/v1/authorize?provider=google&redirect_to=http://localhost3000/#/password Redirected to: http://localhost3000/#. Note that Gotrue doesn't even include the /#/password in the query fragment during the redirect here. The redirected url initially contains the #access_token=..... fragments but not the /password path.
  2. https://project-ref.supabase.co/auth/v1/authorize?provider=google&redirect_to=http://localhost3000/welcome Redirected to: http://localhost3000/welcome#. This is expected and correct.

Will be transfer this to the gotrue backlog.

kangmingtay avatar Sep 28 '22 04:09 kangmingtay