Skip to content

HTTP Error should be 403 (Forbidden) on missing JWT #1552

@perpetual-hydrofoil

Description

@perpetual-hydrofoil

In the JWT middleware (and corresponding tests), BadRequest is currently used instead of Forbidden for nearly all aspects of broken JWTs. This is arguably correct behavior, because we want to help people fix any broken JWTs, but this one should probably be Forbidden instead:

ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt")

Generally, failed logins should be met with StatusForbidden. However, this minor change possibly could break existing client code that is depending on StatusBadRequest (as the tests are).

Still, it seems like a worthwhile change to distinguish those who are simply not logged in from those who actually have a bad request due to a broken or malformed JWT.

These could also be two different errors: one for a malformed (broken) JWT, and one for one that's simply missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions