Keats / jsonwebtoken

JWT lib in rust
MIT License
1.67k stars 266 forks source link

Support for aud field accepting both a String and a List of Strings #299

Closed hvdrumsta closed 1 year ago

hvdrumsta commented 1 year ago

Hi there, according to JWT spec, the aud could be either an array of Strings or if it's a single element it could be just a String that's not inside a list.

I was wondering how to decode a JWT into a claims structure that could accept both a List of String and a single String?

Keats commented 1 year ago

You will need to make the aud an enum like in https://github.com/Keats/jsonwebtoken/blob/master/src/validation.rs#L181-L186

This library already handles both cases

hvdrumsta commented 1 year ago

Thank you, that worked.