Keats / jsonwebtoken

JWT lib in rust
MIT License
1.61k stars 253 forks source link

Treat empty audience as equivalent to no audience #350

Open MarcusGrass opened 7 months ago

MarcusGrass commented 7 months ago

Hello,

There's a specific case where audience is supplied but empty, which I think should be treated as the same as audience not being supplied.

Ie:

{
    "iss": ...,
    "aud": [],
    "exp": ...
    ...
}

Will fail validation if options.aud is None. While (no aud)

{
    "iss": ...,
    "exp": ...
    ...
}

passes validation in that same case where options.aud is None.

The user could just turn off audience validation, but the default is audience validation on, which is reasonable, but then it should accept the supplied but empty audience.

This could also be fixed by changing the deserialization, an empty vec gets deserialized into Multiple but it could be deserialized into NotPresent, but that is a bit trickier.