Skip to content

No documentation on how to implement custom JWT validation #1851

@distinctdan

Description

@distinctdan

Expected Behavior

It looks like all the necessary classes exist in micronaut-security, but I can't find a single piece of documentation on how to use them correctly. JWT validation is common and token formats vary a lot, so I would expect this to come up a lot. Am I missing something, or is this undocumented?

Here's more information about my use case and the things I've looked at:

  • Our token format: we don't have a simple roles property, instead we have a map with additional information for each role, like the locations for which the user has that role. I can generate a roles list from the token, but I'm not sure where to put the logic. The docs briefly mention JsonWebTokenParser, but it only outputs claims, not roles?
  • Signature verification: The docs say to use ReactiveJsonWebTokenValidator but provide no information about how to do that. I'm also surprised this isn't on by default, or at least the docs sound like you have to do additional work to make it verify. If signatures aren't verified, then there isn't any security.
  • Custom Authentication class. I need to parse the token once to get the claims, then pass the parsed object down through my controller and services layer to do security checks. The Authentication class is loosely typed and doesn't appear to support generics. I'm using Kotlin, and I would consider strong typing of the claims to be a requirement here.

I hope I'm just missing things here, is there a more advanced guide available that fully walks through how to set up custom JWT auth? Thanks.

Actual Behaviour

No response

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

4.6.3

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions