auth0 / nextjs-auth0

Next.js SDK for signing in with Auth0
MIT License
2.08k stars 391 forks source link

v4 beta 8 - Logging out does not delete session #1826

Open mluttmann opened 18 hours ago

mluttmann commented 18 hours ago

Checklist

Description

When redirecting the user to /auth/logout, the session is not deleted and the user is still logged in. The server logs The Auth0 client does not have RP-initiated logout enabled, the user will be redirected to the '/v2/logout' endpoint instead. Learn how to enable it here: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0#enable-endpoint-discovery. It appears that the RP logout option is part of the Enterprise tier, but is unlikely to be related to the problem described.

Reproduction

  1. Create Next.js app (answer everything with yes)

    npx create-next-app@latest test-app
    cd test-app
  2. Setup auth0 v4 beta 8 as describe in v4.0.0-beta.8/README.md

  3. Add button for logout in test-app/src/app/page.tsx

    <main>
      <h1>Welcome, {session.user.name}!</h1>
      <a href="/auth/logout">Log out</a>
    </main>
  4. Start application, log in and try to log out

Additional context

No response

nextjs-auth0 version

4.0.0-beta.8

Next.js version

15.0.3

Node.js version

22.11.0

guabu commented 3 hours ago

Hi @mluttmann 👋 Thanks for reporting this — it looks like the cookie is not being cleared for the /v2/logout redirect. We'll get a fix for this in the upcoming release!

For the time being, you can enable RP-initiated logout which is available to all customers (not only for paid plans). The link provided in the log provides the steps on how to enable it: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0#enable-endpoint-discovery