connect performs provider discovery and populates the oauth2 config and token verifier. It is idempotent and safe for concurrent callers.
(ctx context.Context)
| 76 | // connect performs provider discovery and populates the oauth2 config and token |
| 77 | // verifier. It is idempotent and safe for concurrent callers. |
| 78 | func (c *Client) connect(ctx context.Context) error { |
| 79 | c.mu.Lock() |
| 80 | defer c.mu.Unlock() |
| 81 | if c.provider != nil { |
| 82 | return nil |
| 83 | } |
| 84 | provider, err := oidc.NewProvider(ctx, c.cfg.IssuerURL) |
| 85 | if err != nil { |
| 86 | return fmt.Errorf("oidc: discover provider: %w", err) |
| 87 | } |
| 88 | c.provider = provider |
| 89 | c.verifier = provider.Verifier(&oidc.Config{ClientID: c.cfg.ClientID}) |
| 90 | c.oauth2 = &oauth2.Config{ |
| 91 | ClientID: c.cfg.ClientID, |
| 92 | ClientSecret: c.cfg.ClientSecret, |
| 93 | RedirectURL: c.cfg.RedirectURI, |
| 94 | Endpoint: provider.Endpoint(), |
| 95 | Scopes: c.scopes, |
| 96 | } |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | func parseScopes(s string) []string { |
| 101 | if s == "" { |
no outgoing calls
no test coverage detected