Skip to content

Utilize override_messages in JWT authentication middleware #7687

@olenotron

Description

@olenotron

Is your feature request related to a problem? Please describe.
override_messages lets users customize error code and messages globally. While it works with AuthKey and oauth2, it is not supported in JWT auth.

Describe the solution you'd like
Since, for example, I can already set custom errors for AuthKey like this:

{
    "override_messages": {
      "auth.auth_field_missing": {
        "code": 401,
        "message": "Authorization field missing"
      }
    }
}

I want to be able to set custom errors for JWT auth like this:

{
    "override_messages": {
      "jwt.auth_field_missing": {
        "code": 401,
        "message": "Authorization field missing"
      }
    }
}

Additional context
I'll be glad to create a PR if you agree with the enhancement. I won't rehaul all the errors, only the ones that look easily replaceable with standard ones.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions