mirror of https://github.com/golang-jwt/jwt.git
Apply suggestions from code review
Co-authored-by: Micah Parks <66095735+MicahParks@users.noreply.github.com>
This commit is contained in:
parent
eedf3ebe01
commit
91f51d0f6b
|
@ -89,7 +89,7 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
|
|||
if !p.SkipClaimsValidation {
|
||||
// Make sure we have at least a default validator
|
||||
if p.validator == nil {
|
||||
p.validator = DefaultValidator
|
||||
p.validator = NewValidator()
|
||||
}
|
||||
|
||||
if err := p.validator.Validate(claims); err != nil {
|
||||
|
|
|
@ -28,6 +28,7 @@ func WithoutClaimsValidation() ParserOption {
|
|||
}
|
||||
}
|
||||
|
||||
// WithValidator is an option to include a claims validator.
|
||||
func WithValidator(v *Validator) ParserOption {
|
||||
return func(p *Parser) {
|
||||
p.validator = v
|
||||
|
|
|
@ -42,6 +42,7 @@ func NewValidator(opts ...ValidatorOption) *Validator {
|
|||
return v
|
||||
}
|
||||
|
||||
// Validate validates the given claims. It will also perform any custom validation if claims implements the CustomValidator interface.
|
||||
func (v *Validator) Validate(claims Claims) error {
|
||||
var now time.Time
|
||||
vErr := new(ValidationError)
|
||||
|
@ -156,7 +157,7 @@ func verifyAud(aud []string, cmp string, required bool) bool {
|
|||
}
|
||||
|
||||
// case where "" is sent in one or many aud claims
|
||||
if len(stringClaims) == 0 {
|
||||
if stringClaims == "" {
|
||||
return !required
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue