ValidFor returns whether the issuer matches, and one of the audiences matches
(ctx context.Context, issuer string, audiences audience)
| 77 | |
| 78 | // ValidFor returns whether the issuer matches, and one of the audiences matches |
| 79 | func (j JWTConfigCommon) ValidFor(ctx context.Context, issuer string, audiences audience) bool { |
| 80 | if j.Issuer != issuer { |
| 81 | return false |
| 82 | } |
| 83 | // Nil ClientID is invalid (checked by config validation), but empty-string disables audience checking |
| 84 | if j.ClientID == nil { |
| 85 | base.ErrorfCtx(ctx, "JWTConfigCommon.ClientID nil - should never happen (for issuer %v)", base.UD(j.Issuer)) |
| 86 | return false |
| 87 | } |
| 88 | if *j.ClientID == "" { |
| 89 | return true |
| 90 | } |
| 91 | for _, aud := range audiences { |
| 92 | if aud == *j.ClientID { |
| 93 | return true |
| 94 | } |
| 95 | } |
| 96 | return false |
| 97 | } |
| 98 | |
| 99 | var ErrNoMatchingProvider = errors.New("no matching OIDC/JWT provider") |
| 100 |
no test coverage detected