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

Backchannel Logout: Return HTTP Status Code 200 #1854

Open
6 tasks done
SiebelsTim opened this issue Dec 20, 2024 · 1 comment
Open
6 tasks done

Backchannel Logout: Return HTTP Status Code 200 #1854

SiebelsTim opened this issue Dec 20, 2024 · 1 comment

Comments

@SiebelsTim
Copy link

Checklist

Description

The spec states (https://openid.net/specs/openid-connect-backchannel-1_0.html#BCResponse)

If the logout succeeded, the RP MUST respond with HTTP 200 OK. However, note that some Web frameworks will substitute an HTTP 204 No Content response for an HTTP 200 OK when the HTTP body is empty. Therefore, OPs should be prepared to also process an HTTP 204 No Content response as a successful response.

In contrast to the spec, it is hardcoded to be 204.

Reproduction

See referenced link to sourcecode

Additional context

In v3, we could overwrite the route handlers and change this ourselves:

export const POST = withErrorHandler(async function (
  request: NextRequest,
  context: AppRouteHandlerFnContext,
): Promise<Response> {
  const response = await getAuth0Instance().handleBackchannelLogout(request, context);
  // OpenID Connect Back-Channel Logout Spec requires a 200 response
  // Auth0 returns a 204 response, so we need to convert it to a 200
  if (response.status === 204) {
    return new Response(response.body, {
      status: 200,
      statusText: response.statusText,
      headers: response.headers,
    });
  }
  return response;
});

In v4, this is not working anymore as this is tightly coupled into the middleware.

nextjs-auth0 version

3,4

Next.js version

14

Node.js version

22

@guabu
Copy link

guabu commented Jan 3, 2025

Hey @SiebelsTim 👋 Could you share what the use case for overriding the status code is? I ask because Auth0 accepts a 204 response and since we don't return a response body we are consistent with the spec:

However, note that some Web frameworks will substitute an HTTP 204 No Content response for an HTTP 200 OK when the HTTP body is empty. Therefore, OPs should be prepared to also process an HTTP 204 No Content response as a successful response.

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

No branches or pull requests

2 participants