-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
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.