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

Method verifySubject

validator.go:299–310  ·  view source on GitHub ↗

verifySubject compares the sub claim against cmp. If sub is not set, it will succeed if the claim is not required, otherwise ErrTokenRequiredClaimMissing will be returned. Additionally, if any error occurs while retrieving the claim, e.g., when its the wrong type, an ErrTokenUnverifiable error wil

(claims Claims, cmp string, required bool)

Source from the content-addressed store, hash-verified

297// Additionally, if any error occurs while retrieving the claim, e.g., when its
298// the wrong type, an ErrTokenUnverifiable error will be returned.
299func (v *Validator) verifySubject(claims Claims, cmp string, required bool) error {
300 sub, err := claims.GetSubject()
301 if err != nil {
302 return err
303 }
304
305 if sub == "" {
306 return errorIfRequired(required, "sub")
307 }
308
309 return errorIfFalse(sub == cmp, ErrTokenInvalidSubject)
310}
311
312// errorIfFalse returns the error specified in err, if the value is true.
313// Otherwise, nil is returned.

Callers 2

ValidateMethod · 0.95

Calls 3

errorIfRequiredFunction · 0.85
errorIfFalseFunction · 0.85
GetSubjectMethod · 0.65

Tested by 1