Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Allow int types in MapClaims validations #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions map_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func (m MapClaims) VerifyAudience(cmp string, req bool) bool {
// If required is false, this method will return true if the value matches or is unset
func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool {
switch exp := m["exp"].(type) {
case int64:
return verifyExp(exp, cmp, req)
case int:
return verifyExp(int64(exp), cmp, req)
case float64:
return verifyExp(int64(exp), cmp, req)
case json.Number:
Expand All @@ -34,6 +38,10 @@ func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool {
// If required is false, this method will return true if the value matches or is unset
func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool {
switch iat := m["iat"].(type) {
case int64:
return verifyIat(iat, cmp, req)
case int:
return verifyIat(int64(iat), cmp, req)
case float64:
return verifyIat(int64(iat), cmp, req)
case json.Number:
Expand All @@ -54,6 +62,10 @@ func (m MapClaims) VerifyIssuer(cmp string, req bool) bool {
// If required is false, this method will return true if the value matches or is unset
func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool {
switch nbf := m["nbf"].(type) {
case int64:
return verifyNbf(nbf, cmp, req)
case int:
return verifyNbf(int64(nbf), cmp, req)
case float64:
return verifyNbf(int64(nbf), cmp, req)
case json.Number:
Expand Down