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

Method GetClient

auth/oidc.go:247–274  ·  view source on GitHub ↗

GetClient initializes the client on first successful request.

(ctx context.Context, buildCallbackURLFunc OIDCCallbackURLFunc)

Source from the content-addressed store, hash-verified

245
246// GetClient initializes the client on first successful request.
247func (op *OIDCProvider) GetClient(ctx context.Context, buildCallbackURLFunc OIDCCallbackURLFunc) (*OIDCClient, error) {
248 // If the callback URL isn't defined for the provider, uses buildCallbackURLFunc to construct (based on current request)
249
250 if op.clientInit.IsTrue() {
251 return op.client, nil
252 }
253 op.clientInitLock.Lock()
254 defer op.clientInitLock.Unlock()
255
256 // Check again to see if the previous lock holder initialized the client
257 if op.clientInit.IsTrue() {
258 return op.client, nil
259 }
260
261 // If the redirect URL is not defined for the provider generate it from the
262 // handler request and set it on the provider
263 if op.CallbackURL == nil || *op.CallbackURL == "" {
264 callbackURL := buildCallbackURLFunc(op.Name, op.IsDefault)
265 if callbackURL != "" {
266 op.CallbackURL = &callbackURL
267 }
268 }
269 if err := op.initOIDCClient(ctx); err != nil {
270 return nil, err
271 }
272 op.clientInit.Set(true)
273 return op.client, nil
274}
275
276// To support multiple providers referencing the same issuer, the user prefix used to build the SG usernames for
277// a provider is based on the issuer

Callers 4

verifyTokenMethod · 0.95
handleOIDCCommonMethod · 0.80
handleOIDCCallbackMethod · 0.80
handleOIDCRefreshMethod · 0.80

Calls 5

initOIDCClientMethod · 0.95
IsTrueMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected