mirror of
https://github.com/int128/kubelogin.git
synced 2026-08-23 21:06:15 +00:00
* fix(authcode): Set Origin header on token request Allow passing Azure AD CORS checks. on-behalf-of: @eon-se opensource@eon.com Signed-off-by: Maximilian Blatt <maximilian.blatt.external@eon.com> * Add `--oidc-request-header` flag * Add doc --------- Signed-off-by: Maximilian Blatt <maximilian.blatt.external@eon.com> Co-authored-by: Maximilian Blatt <maximilian.blatt.external@eon.com>
22 lines
609 B
Go
22 lines
609 B
Go
package transport
|
|
|
|
import "net/http"
|
|
|
|
// WithHeader is a RoundTripper that adds custom headers to each request.
|
|
//
|
|
// Token retrievel fails when an auth code has been retrieved using Azure AD
|
|
// Single Page Application due to the missing "Origin" header for CORS
|
|
// validation.
|
|
// https://github.com/int128/kubelogin/issues/1048
|
|
type WithHeader struct {
|
|
Base http.RoundTripper
|
|
RequestHeaders map[string]string
|
|
}
|
|
|
|
func (t *WithHeader) RoundTrip(req *http.Request) (*http.Response, error) {
|
|
for key, value := range t.RequestHeaders {
|
|
req.Header.Set(key, value)
|
|
}
|
|
return t.Base.RoundTrip(req)
|
|
}
|