@@ -200,7 +200,17 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
200
200
func (p * Provider ) validateClaims (claims map [string ]interface {}) (time.Time , error ) {
201
201
audience := getClaimValue (claims , []string {audienceClaim })
202
202
if audience != p .ClientKey {
203
- return time.Time {}, errors .New ("audience in token does not match client key" )
203
+ found := false
204
+ audiences := getClaimValues (claims , []string {audienceClaim })
205
+ for _ , aud := range audiences {
206
+ if aud == p .ClientKey {
207
+ found = true
208
+ break
209
+ }
210
+ }
211
+ if ! found {
212
+ return time.Time {}, errors .New ("audience in token does not match client key" )
213
+ }
204
214
}
205
215
206
216
issuer := getClaimValue (claims , []string {issuerClaim })
@@ -355,6 +365,24 @@ func getClaimValue(data map[string]interface{}, claims []string) string {
355
365
return ""
356
366
}
357
367
368
+ func getClaimValues (data map [string ]interface {}, claims []string ) []string {
369
+ var result []string
370
+
371
+ for _ , claim := range claims {
372
+ if value , ok := data [claim ]; ok {
373
+ if stringValues , ok := value .([]interface {}); ok {
374
+ for _ , stringValue := range stringValues {
375
+ if s , ok := stringValue .(string ); ok && len (s ) > 0 {
376
+ result = append (result , s )
377
+ }
378
+ }
379
+ }
380
+ }
381
+ }
382
+
383
+ return result
384
+ }
385
+
358
386
// decodeJWT decodes a JSON Web Token into a simple map
359
387
// http://openid.net/specs/draft-jones-json-web-token-07.html
360
388
func decodeJWT (jwt string ) (map [string ]interface {}, error ) {
0 commit comments