@@ -93,9 +93,9 @@ type Config struct {
93
93
ClientSecret string
94
94
Scope []string
95
95
96
- // DiscoveryCA is required for OpenShift OAuth metadata discovery. This is the CA
96
+ // K8sCA is required for OpenShift OAuth metadata discovery. This is the CA
97
97
// used to talk to the master, which might be different than the issuer CA.
98
- DiscoveryCA string
98
+ K8sCA string
99
99
100
100
SuccessURL string
101
101
ErrorURL string
@@ -140,33 +140,37 @@ func newHTTPClient(issuerCA string, includeSystemRoots bool) (*http.Client, erro
140
140
// NewAuthenticator initializes an Authenticator struct. It blocks until the authenticator is
141
141
// able to contact the provider.
142
142
func NewAuthenticator (ctx context.Context , c * Config ) (* Authenticator , error ) {
143
- a , err := newUnstartedAuthenticator (c )
144
- if err != nil {
145
- return nil , err
146
- }
147
-
148
143
// Retry connecting to the identity provider a few times
149
144
backoff := time .Second * 2
150
- maxSteps := 5
145
+ maxSteps := 7
151
146
steps := 0
152
147
153
148
for {
154
149
var (
150
+ a * Authenticator
155
151
lm loginMethod
156
152
endpoint oauth2.Endpoint
157
153
err error
158
154
)
155
+
156
+ a , err = newUnstartedAuthenticator (c )
157
+ if err != nil {
158
+ return nil , err
159
+ }
160
+
159
161
switch c .AuthSource {
160
162
case AuthSourceOpenShift :
161
163
// Use the k8s CA for OAuth metadata discovery.
162
- var client * http.Client
163
- client , err = newHTTPClient (c .DiscoveryCA , false )
164
+ var k8sClient * http.Client
165
+ // Don't include system roots when talking to the API server.
166
+ k8sClient , err = newHTTPClient (c .K8sCA , false )
164
167
if err != nil {
165
168
return nil , err
166
169
}
167
170
168
171
endpoint , lm , err = newOpenShiftAuth (ctx , & openShiftConfig {
169
- client : client ,
172
+ k8sClient : k8sClient ,
173
+ oauthClient : a .client ,
170
174
issuerURL : c .IssuerURL ,
171
175
cookiePath : c .CookiePath ,
172
176
secureCookies : c .SecureCookies ,
@@ -183,11 +187,11 @@ func NewAuthenticator(ctx context.Context, c *Config) (*Authenticator, error) {
183
187
if err != nil {
184
188
steps ++
185
189
if steps > maxSteps {
186
- log .Errorf ("error contacting openid connect provider: %v" , err )
190
+ log .Errorf ("error contacting auth provider: %v" , err )
187
191
return nil , err
188
192
}
189
193
190
- log .Errorf ("error contacting openid connect provider (retrying in %s): %v" , backoff , err )
194
+ log .Errorf ("error contacting auth provider (retrying in %s): %v" , backoff , err )
191
195
192
196
time .Sleep (backoff )
193
197
backoff *= 2
0 commit comments