jsonwebtoken icon indicating copy to clipboard operation
jsonwebtoken copied to clipboard

Treat empty audience as equivalent to no audience

Open MarcusGrass opened this issue 2 years ago • 0 comments

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.

MarcusGrass avatar Dec 08 '23 14:12 MarcusGrass