Skip to content

iat/nbf/exp should accept only numeric date #1486

@cboitel

Description

@cboitel

Describe the bug

When parsing tokens, jwt.Parse will by default accept string formatted dates. When enabling pedantic, string formatted dates are effectively not accepted.

Extract from RFC

NumericDate
      A JSON numeric value representing the number of seconds from
      1970-01-01T00:00:00Z UTC until the specified UTC date/time,
      ignoring leap seconds.  This is equivalent to the IEEE Std 1003.1,
      2013 Edition [[POSIX.1](https://datatracker.ietf.org/doc/html/rfc7519#ref-POSIX.1)] definition "Seconds Since the Epoch", in
      which each day is accounted for by exactly 86400 seconds, other
      than that non-integer values can be represented.  See [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339)
      [[RFC3339](https://datatracker.ietf.org/doc/html/rfc3339)] for details regarding date/times in general and UTC in
      particular.

Please attach the output of go version

To Reproduce / Expected behavior

N/A

Additional context

Since ensuring non-string dates would break v3 compatibility, it should be at least warned in documentation that pedantic should be enabled if user wants strict RFC compliant behaviour

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions