diff --git a/claims.go b/claims.go index ffd5dba..b07ac02 100644 --- a/claims.go +++ b/claims.go @@ -238,7 +238,7 @@ func verifyExp(exp *time.Time, now time.Time, required bool) bool { if exp == nil { return !required } - return now.Before(*exp) || now.Equal(*exp) + return now.Before(*exp) } func verifyIat(iat *time.Time, now time.Time, required bool) bool { diff --git a/map_claims_test.go b/map_claims_test.go index 05f56e1..b8b9eb7 100644 --- a/map_claims_test.go +++ b/map_claims_test.go @@ -2,6 +2,7 @@ package jwt import ( "testing" + "time" ) func TestVerifyAud(t *testing.T) { @@ -97,3 +98,26 @@ func TestMapclaimsVerifyExpiresAtInvalidTypeString(t *testing.T) { t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) } } + +func TestMapClaimsVerifyExpiresAtExpire(t *testing.T) { + exp := time.Now().Unix() + mapClaims := MapClaims{ + "exp": float64(exp), + } + want := false + got := mapClaims.VerifyExpiresAt(exp, true) + if want != got { + t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) + } + + got = mapClaims.VerifyExpiresAt(exp + 1, true) + if want != got { + t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) + } + + want = true + got = mapClaims.VerifyExpiresAt(exp - 1, true) + if want != got { + t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) + } +}