MCPcopy
hub / github.com/golang-jwt/jwt / verifyExpiresAt

Method verifyExpiresAt

validator.go:175–186  ·  view source on GitHub ↗

verifyExpiresAt compares the exp claim in claims against cmp. This function will succeed if cmp < exp. Additional leeway is taken into account. If exp is not set, it will succeed if the claim is not required, otherwise ErrTokenRequiredClaimMissing will be returned. Additionally, if any error occur

(claims Claims, cmp time.Time, required bool)

Source from the content-addressed store, hash-verified

173// Additionally, if any error occurs while retrieving the claim, e.g., when its
174// the wrong type, an ErrTokenUnverifiable error will be returned.
175func (v *Validator) verifyExpiresAt(claims Claims, cmp time.Time, required bool) error {
176 exp, err := claims.GetExpirationTime()
177 if err != nil {
178 return err
179 }
180
181 if exp == nil {
182 return errorIfRequired(required, "exp")
183 }
184
185 return errorIfFalse(cmp.Before((exp.Time).Add(+v.leeway)), ErrTokenExpired)
186}
187
188// verifyIssuedAt compares the iat claim in claims against cmp. This function
189// will succeed if cmp >= iat. Additional leeway is taken into account.

Callers 2

ValidateMethod · 0.95

Calls 3

errorIfRequiredFunction · 0.85
errorIfFalseFunction · 0.85
GetExpirationTimeMethod · 0.65

Tested by 1