Skip to content

Unexpected 5xx error code when accessing "/auth/v1/oauth/token" #2339

@Kroppeb

Description

@Kroppeb

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I am trying to debug an issue I have been having an came across this bug which has caused the underlying issue to be obfuscated it seems.

I am triggering this line (I think, it's the error message that gets logged in the Supabase logs)

return "", fmt.Errorf("HS256 is not supported for ID token signing")

This error then gets converted into a InternalServerError here:
idToken, err := tokenService.GenerateIDToken(tokens.GenerateIDTokenParams{
User: user,
ClientID: client.ID,
Nonce: nonce,
AuthTime: user.LastSignInAt,
Scopes: scopeList,
})
if err != nil {
return apierrors.NewInternalServerError("Error generating ID token").WithInternalError(err)
}

Resulting in a 5xx error code instead of an expected 4xx error code.

The software I'm using will retry when seeing a 5xx error. But given that the error was produced after the token was destroyed (as they are single use) this then results in a 403 error with "invalid_grant" "Invalid authorization code".

To Reproduce

Given the line I assume you can repro this by using HS256 signing. I can't actually give a setup that triggers this as I have a dev and a prod setup and although they have the same settings as far as I can see. One setup is running in this problem, while the other isn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions