Auth0 with nextjs and graphql (client / server architecture)

Hello

I would like to authenticate and authorize users using auth0.

I’m a little lost, any pointers would be appreciated.

My app is using Next JS for the client/frontend and GraphQL (typescript / type-graphql) for the server/backend.

I see the flow as follows.

  1. User logs in to the application successfully
  2. A JWT is attached/exposed to the request object
  3. I can pass/expose req.headers.authorization on context on GraphQL.
  4. Handle the req object on type-graphql with custom decorators.
  5. Validate if user is “authorized” to access resolver
  • One of the questions I have is how to handle authentication on a SSG/SSRS hybrid scenario?
    (since static generation happens on the client I will not have access to the reqobject.)

  • Does the library auth0/nextjs-auth0 uses jsonwebtokens and attaches the decoded user on the req object (if success login)?

  • Do I need additional middleware in order to use JWT?

  • Should I validate JWT for authorization using a JWKS? (on resolvers)

Thanks!

1 Like

I am also interested in implementing a similar stack. Did you get anywhere with this? I will let you know how I get on.

1 Like