gatsby-theme-auth0 icon indicating copy to clipboard operation
gatsby-theme-auth0 copied to clipboard

Netlify login page spinning

Open Qurus opened this issue 4 years ago • 12 comments

Hello can you help please with netlify deploy. On local working without problem but once I upload to netlify login page is not redirecting. Do I have to do extra step to make it work on netlify? Thanks.

Qurus avatar Jun 16 '20 18:06 Qurus

@Qurus

  1. Make sure auth0 Application URIs are configured correctly:
  1. Make sure netlify Environment variables are configured correctly:

epilande avatar Jun 16 '20 23:06 epilande

Thanks for your quick reply @epilande . All the settings are seems correct. I did exactly how your screen with my domain credentials.

Qurus avatar Jun 17 '20 01:06 Qurus

I had a similar issue on my app. After some digging I narrowed down the issue to Safari ( Catalina+ ) stripping the hash from the redirect. The hash is used to trigger handleAuthentication and without it the auth stalls even though you're actually logged in.

Easy fix: Add a trailing slash to your callback URL.

More details here: https://github.com/IdentityModel/oidc-client-js/issues/238#issuecomment-271105795

jacobcarrington avatar Aug 19 '20 10:08 jacobcarrington

@jacobcarrington Would you suggest the default for gatsby-theme-auth0 should be /auth/callback/ for the callback URL instead? Currently, it's /auth/callback without the trailing slash.

DoctorDerek avatar Nov 10 '20 23:11 DoctorDerek

@Qurus Did you get it working? I'm having the same issues with Netlify. I think it has to do with the /auth/callback/ path not having a trailing slash.

DoctorDerek avatar Nov 10 '20 23:11 DoctorDerek

@DoctorDerek No luck with me. I did try with trailing slash too.

Qurus avatar Nov 10 '20 23:11 Qurus

@jacobcarrington Would you suggest the default for gatsby-theme-auth0 should be /auth/callback/ for the callback URL instead? Currently, it's /auth/callback without the trailing slash.

I would, but even then, Safari's third party cookie policy is soo strict I think I eventually use a custom domain for Auth0. Which is not supported. If you're interested, I'll share the overrides that made this possible.

Personally I think this plugin in it's current should probably be dropped in support for a solution that uses auth0-react or spa instead of auth0-js.

jacobcarrington avatar Nov 10 '20 23:11 jacobcarrington

Hey @jacobcarrington That would be great, as I'm working on a tutorial based on this plugin.

I'd also love to hear if you have a suggestion for a auth0-react or -spa plugin for Gatsby instead.

--

@Qurus Yeah me neither, I haven't been able to get it to work on Netlify.

DoctorDerek avatar Nov 11 '20 00:11 DoctorDerek

config.ts

import { config as masterConfig } from "gatsby-theme-auth0/src/auth/config"

export const config = Object.assign(masterConfig, {
  tenant: process.env.GATSBY_AUTH0_TENANT,
  token_issuer: process.env.GATSBY_AUTH0_CUSTOM_DOMAIN
})

service.ts ~ line: 26

  private auth0 = process.env.AUTH0_DOMAIN
    ? new auth0.WebAuth({
        ...config,
        auto_login: false,
        domain: config.token_issuer,
        overrides: {
          __tenant: config.tenant,
          __token_issuer: `https://${config.token_issuer}/`
        }
      })
    : undefined

jacobcarrington avatar Nov 11 '20 00:11 jacobcarrington

@jacobcarrington Awesome, thank you so much!! I'll try it out tomorrow. That does seem a little weird, but I'm not super familiar with it.

DoctorDerek avatar Nov 11 '20 00:11 DoctorDerek

@jacobcarrington Awesome, thank you so much!! I'll try it out tomorrow. That does seem a little weird, but I'm not super familiar with it.

Just shadow the plugin in your project. The main thing is that you need to pass in overrides into the Auth0 config. Auth0 will reject the token on a custom domain if the token_issuer is not set correctly.

jacobcarrington avatar Nov 11 '20 00:11 jacobcarrington

Great, thank you 👍

DoctorDerek avatar Nov 11 '20 00:11 DoctorDerek