@@ -23,7 +23,8 @@ type openShiftAuth struct {
23
23
}
24
24
25
25
type openShiftConfig struct {
26
- client * http.Client
26
+ k8sClient * http.Client
27
+ oauthClient * http.Client
27
28
issuerURL string
28
29
cookiePath string
29
30
secureCookies bool
@@ -52,7 +53,7 @@ func newOpenShiftAuth(ctx context.Context, c *openShiftConfig) (oauth2.Endpoint,
52
53
return oauth2.Endpoint {}, nil , err
53
54
}
54
55
55
- resp , err := c .client .Do (req .WithContext (ctx ))
56
+ resp , err := c .k8sClient .Do (req .WithContext (ctx ))
56
57
if err != nil {
57
58
return oauth2.Endpoint {}, nil , err
58
59
}
@@ -86,6 +87,19 @@ func newOpenShiftAuth(ctx context.Context, c *openShiftConfig) (oauth2.Endpoint,
86
87
return oauth2.Endpoint {}, nil , err
87
88
}
88
89
90
+ // Make sure we can talk to the token endpoint.
91
+ req , err = http .NewRequest (http .MethodHead , metadata .Token , nil )
92
+ if err != nil {
93
+ return oauth2.Endpoint {}, nil , err
94
+ }
95
+
96
+ resp , err = c .oauthClient .Do (req .WithContext (ctx ))
97
+ if err != nil {
98
+ return oauth2.Endpoint {}, nil , fmt .Errorf ("request to OAuth token endpoint %s failed: %v" ,
99
+ metadata .Token , err )
100
+ }
101
+ defer resp .Body .Close ()
102
+
89
103
kubeAdminLogoutURL := proxy .SingleJoiningSlash (metadata .Issuer , "/logout" )
90
104
return oauth2.Endpoint {
91
105
AuthURL : metadata .Auth ,
0 commit comments