Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultProvider does not work with Custom OAuth #928

Open
tschni opened this issue Oct 16, 2024 · 2 comments
Open

defaultProvider does not work with Custom OAuth #928

tschni opened this issue Oct 16, 2024 · 2 comments
Labels
question A question about NuxtAuth

Comments

@tschni
Copy link

tschni commented Oct 16, 2024

Environment

  • Operating System: Windows_NT
  • Node Version: v20.18.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: pnpm@8.15.3
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/tschni/sidebase-nuxt-auth-default-provider-issue

Describe the bug

I have set up a custom OAuth provider with Authjs. In nuxt.config.ts I have set this as defaultProvider and activated the globalAppMiddleware.

Now I would have expected that when I opened the Nuxt app, I would automatically be redirected to the login page of my OAuth provider. This also fits with the following statement from the documentation: “Setting this here will also affect the global middleware behavior. For instance, when you set it to github and the user is unauthorized, they will be directly forwarded to the Github OAuth page instead of seeing the app-login page”.

However, there is a redirect to /api/auth/signin, where I first have to click a sign in button. Since I have only defined this one provider, I would of course like to skip this step and be redirected directly to the login page of my provider.

image
image

There seems to have been the same error before, but without a helpful solution: #531

Additional context

No response

Logs

No response

@tschni tschni added bug A bug that needs to be resolved pending An issue waiting for triage labels Oct 16, 2024
@phoenix-ru
Copy link
Collaborator

phoenix-ru commented Oct 17, 2024

Could you please check that your CSRF token is verified?

https://github.com/nextauthjs/next-auth/blob/c15d9a5b7a435f4301572745add89cc99db30aef/packages/next-auth/src/core/index.ts#L241-L253

Sadly, I can't provide much other help as I don't have enough context and haven't set up custom providers with next-auth. Their current guide is lacking a section about CSRF protection
https://next-auth.js.org/configuration/providers/oauth#using-a-custom-provider

@phoenix-ru phoenix-ru added question A question about NuxtAuth and removed bug A bug that needs to be resolved pending An issue waiting for triage labels Oct 17, 2024
@tschni
Copy link
Author

tschni commented Oct 17, 2024

How do I check the CSRF token? I'm not really familiar with next-auth unfortunately. However, I did not set anything out of the ordinary and strictly followed the instructions in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about NuxtAuth
Projects
None yet
Development

No branches or pull requests

2 participants