Commit e8e5b83
authored
mapclaims: stop treating exp=0 as a missing claim (#509)
* mapclaims: stop treating exp=0 as a missing claim
MapClaims.parseNumericDate short-circuited and returned nil whenever a
float64 value happened to be 0. That made the very-much-set exp claim
"exp": 0 invisible to verifyExpiresAt, so the token was treated as
valid instead of expired.
The json.Number branch doesn't have the same carve-out, so parsing the
exact same token via WithJSONNumber() correctly came back as expired.
Drop the special case so both branches agree and an exp of 0 means
"this token expired at the unix epoch", which is what the JWT spec
calls for.
Fixes #496.
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
* mapclaims: test that string exp comes back as ErrInvalidType
Pins down the corner case raised in review: empty-string exp must
surface as ErrInvalidType rather than slipping into the float64
branch and looking like a 0 (i.e. epoch) value.
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
---------
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>1 parent 9a70137 commit e8e5b83
2 files changed
Lines changed: 44 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 53 | | |
58 | 54 | | |
59 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
0 commit comments