Only some registered claims can be optionally required
I noticed that only a subset of the registered claims can be configured to be required.
PR #351, for example, adds the requireExp field to the core Validator.
Other fields like iat are hard-coded to not be required.
We also have a 'expected' claims like expectedIss which are hard-coded to be required.
Semantically, I find the line between "expected" and "required" to be extremely thin. I propose moving to a system like expiratedAt where no required field is hard-coded and all can be configured with ParserOptions
This change would standardize on a two boolean system for each registered claims:
WithFoowhich determines which claims should be verified if provided. For example, seeWithIssuedAtandWithIssuedAtWithFooRequiredwhich determines which claims should be required. For example, seeWithExpirationRequired
The existing API (from what I can see) will remain the same. This change would only add ParserOption funcs to fill in the missing gaps.
I'd be happy to work on a PR. Is this a welcome change? Does anyone have any feedback?
Source: golang-jwt/jwt