Skip to content

Commit ca1d34c

Browse files
committed
Rename variable for clarity and make expected auds check more specific
1 parent 8f964e5 commit ca1d34c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

parser_option.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func WithAudience(aud string) ParserOption {
8989
func WithAudiences(auds []string, matchAll bool) ParserOption {
9090
return func(p *Parser) {
9191
p.validator.expectedAuds = auds
92-
p.validator.expectedAudsMatchAll = matchAll
92+
p.validator.matchAllAud = matchAll
9393
}
9494
}
9595

validator.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ type Validator struct {
5959
// []string will disable auds checking.
6060
expectedAuds []string
6161

62-
// expectedAudsMatchAll specifies whether all expected audiences must match all auds from claim
63-
expectedAudsMatchAll bool
62+
// matchAllAud specifies whether all expected audiences must match all auds from claim
63+
matchAllAud bool
6464

6565
// expectedIss contains the issuer this token expects. Supplying an empty
6666
// string will disable iss checking.
@@ -134,10 +134,10 @@ func (v *Validator) Validate(claims Claims) error {
134134
}
135135

136136
// If we have expected audiences, we also require the audiences claim
137-
if len(v.expectedAuds) != 0 {
138-
if err := v.verifyAudiences(claims, v.expectedAuds, true, v.expectedAudsMatchAll); err != nil {
139-
errs = append(errs, err)
140-
}
137+
if len(v.expectedAuds) > 0 {
138+
if err := v.verifyAudiences(claims, v.expectedAuds, true, v.matchAllAud); err != nil {
139+
errs = append(errs, err)
140+
}
141141
}
142142

143143
// If we have an expected issuer, we also require the issuer claim
@@ -331,7 +331,7 @@ func (v *Validator) verifyAudiences(claims Claims, cmps []string, required bool,
331331

332332
matchFound := false
333333

334-
// Label to break out of both loops if a match is found
334+
// Label to break out of both loops if a match is found
335335
outer:
336336

337337
// Check all aud values

0 commit comments

Comments
 (0)