Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
Detect type of aud in MapClaims
Browse files Browse the repository at this point in the history
  • Loading branch information
dklesev committed Aug 27, 2019
1 parent f6eb27a commit e951383
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion map_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ type MapClaims map[string]interface{}
// Compares the aud claim against cmp.
// If required is false, this method will return true if the value matches or is unset
func (m MapClaims) VerifyAudience(cmp string, req bool) bool {
aud, _ := m["aud"].(Audience)

aud := Audience{}
switch m["aud"].(type) {
case string:
aud = Audience{m["aud"].(string)}
case interface{}:
for _, s := range m["aud"].([]interface{}) {
aud = append(aud, s.(string))
}
}

return verifyAud(aud, []string{cmp}, req)
}

Expand Down

0 comments on commit e951383

Please sign in to comment.