Commit 8c2a07fa authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #45575 from wanghaoran1988/fix_44476

Automatic merge from submit-queue Make gcp auth provider not to override the Auth header if it's already exits **What this PR does / why we need it**: Make AuthProvider not wrap the transport if beartoken or basic auth is enabled **Which issue this PR fixes** : fixes #44476 **Special notes for your reviewer**: **Release note**: ``` GCP auth plugin no longer overwrites existing Authorization headers. ```
parents 9f23149a 9760dd99
......@@ -124,10 +124,7 @@ func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister restcli
}
func (g *gcpAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper {
return &oauth2.Transport{
Source: g.tokenSource,
Base: rt,
}
return &conditionalTransport{&oauth2.Transport{Source: g.tokenSource, Base: rt}}
}
func (g *gcpAuthProvider) Login() error { return nil }
......@@ -284,3 +281,14 @@ func parseJSONPath(input interface{}, name, template string) (string, error) {
}
return buf.String(), nil
}
type conditionalTransport struct {
oauthTransport *oauth2.Transport
}
func (t *conditionalTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if len(req.Header.Get("Authorization")) != 0 {
return t.oauthTransport.Base.RoundTrip(req)
}
return t.oauthTransport.RoundTrip(req)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment