Skip to content

Requests missing the jwt do not result in 401 Unauthorized but instead in 400 Bad Request #38

@turtletramp

Description

@turtletramp

In jwt.go:117 a custom error exists for this purpose to return 401

// ErrJWTMissing denotes an error raised when JWT token value could not be extracted from request
var ErrJWTMissing = echo.NewHTTPError(http.StatusUnauthorized, "missing or malformed jwt")

But when trying to extract the jwt instead of returning ErrJWTMissing another new error is created and returned with status 400.

jwt.go.258

if lastTokenErr == nil {
	return echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt").SetInternal(err)
}

I think the intention is to do the following instead

if lastTokenErr == nil {
	return ErrJWTMissing.SetInternal(err)
}

... not sure about the .SetInternal(err) though

This behavior seems to be against the definition of 401. Or is there a reason for that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions