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)
| 297 | // Additionally, if any error occurs while retrieving the claim, e.g., when its |
| 298 | // the wrong type, an ErrTokenUnverifiable error will be returned. |
| 299 | func (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. |