MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / ValidFor

Method ValidFor

auth/jwt.go:79–97  ·  view source on GitHub ↗

ValidFor returns whether the issuer matches, and one of the audiences matches

(ctx context.Context, issuer string, audiences audience)

Source from the content-addressed store, hash-verified

77
78// ValidFor returns whether the issuer matches, and one of the audiences matches
79func (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
99var ErrNoMatchingProvider = errors.New("no matching OIDC/JWT provider")
100

Callers 1

Calls 2

ErrorfCtxFunction · 0.92
UDFunction · 0.92

Tested by

no test coverage detected