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

Method verifyNotBefore

validator.go:217–228  ·  view source on GitHub ↗

verifyNotBefore compares the nbf claim in claims against cmp. This function will return true if cmp >= nbf. Additional leeway is taken into account. If nbf is not set, it will succeed if the claim is not required, otherwise ErrTokenRequiredClaimMissing will be returned. Additionally, if any error

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

Source from the content-addressed store, hash-verified

215// Additionally, if any error occurs while retrieving the claim, e.g., when its
216// the wrong type, an ErrTokenUnverifiable error will be returned.
217func (v *Validator) verifyNotBefore(claims Claims, cmp time.Time, required bool) error {
218 nbf, err := claims.GetNotBefore()
219 if err != nil {
220 return err
221 }
222
223 if nbf == nil {
224 return errorIfRequired(required, "nbf")
225 }
226
227 return errorIfFalse(!cmp.Before(nbf.Add(-v.leeway)), ErrTokenNotValidYet)
228}
229
230// verifyAudience compares the aud claim against cmp.
231//

Callers 2

ValidateMethod · 0.95

Calls 3

errorIfRequiredFunction · 0.85
errorIfFalseFunction · 0.85
GetNotBeforeMethod · 0.65

Tested by 1