Skip to content

Typed JWT claim values

Choose a tag to compare

@flash548 flash548 released this 04 Dec 15:49
· 6 commits to main since this release
7c15e74

Ability to now indicate claim values in the JWT to have a JSON type (before ,everything was a string)

Now fields can be appended with /i or /b for JSON number coercion or boolean (true/false) coercion.

Example:

:user_id/i would coerce the user record 'user_id' field to number type in the JWT. 'user_id' is a varchar in the database; so this is a way to coerce that to JSON numeric format for downstream services. Likewise for /b for JSON 'true' or JSON 'false' value via Mojo::JSON->true/false.

Note this doesn't have any affect if the claim is an ARRAY ref type -- the array will be flattened to a string and any dynamic elements (e.g. :user_id/i) will just be string values like present.