Commit 958e422
fix: validate numeric type of iat, nbf and exp claims in encode (#634)
* fix: validate numeric type of iat, nbf and exp claims in encode
The decode() path already rejected non-numeric iat/nbf/exp values, but
encode() accepted any type and silently produced an invalid token. Add
the same is_numeric guards in encode() and cover them with unit tests.
Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
* test: add regression test for numeric string timestamps in encode
Covers the case where iat/nbf/exp are passed as numeric strings
(e.g. (string) time()), which must remain accepted to avoid a
breaking change.
Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
---------
Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
Co-authored-by: Brent Shaffer <betterbrent@google.com>1 parent bc9b2ad commit 958e422
2 files changed
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
227 | 236 | | |
228 | 237 | | |
229 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
612 | 651 | | |
613 | 652 | | |
614 | 653 | | |
| |||
0 commit comments