outposts: cleanup UserAgent config for API Client
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
061c549a40
commit
a426a1a0b6
|
@ -41,10 +41,11 @@ type APIController struct {
|
|||
// NewAPIController initialise new API Controller instance from URL and API token
|
||||
func NewAPIController(akURL url.URL, token string) *APIController {
|
||||
config := api.NewConfiguration()
|
||||
config.UserAgent = pkg.UserAgent()
|
||||
config.Host = akURL.Host
|
||||
config.Scheme = akURL.Scheme
|
||||
config.HTTPClient = &http.Client{
|
||||
Transport: SetUserAgent(GetTLSTransport(), pkg.UserAgent()),
|
||||
Transport: GetTLSTransport(),
|
||||
}
|
||||
config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package ak
|
||||
|
||||
import "net/http"
|
||||
|
||||
func SetUserAgent(inner http.RoundTripper, userAgent string) http.RoundTripper {
|
||||
return &addUGA{
|
||||
inner: inner,
|
||||
Agent: userAgent,
|
||||
}
|
||||
}
|
||||
|
||||
type addUGA struct {
|
||||
inner http.RoundTripper
|
||||
Agent string
|
||||
}
|
||||
|
||||
func (ug *addUGA) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
r.Header.Set("User-Agent", ug.Agent)
|
||||
return ug.inner.RoundTrip(r)
|
||||
}
|
|
@ -54,9 +54,10 @@ func (pi *ProviderInstance) Bind(username string, bindDN, bindPW string, conn ne
|
|||
config := api.NewConfiguration()
|
||||
config.Host = pi.s.ac.Client.GetConfig().Host
|
||||
config.Scheme = pi.s.ac.Client.GetConfig().Scheme
|
||||
config.UserAgent = pkg.UserAgent()
|
||||
config.HTTPClient = &http.Client{
|
||||
Jar: jar,
|
||||
Transport: newTransport(ak.SetUserAgent(ak.GetTLSTransport(), pkg.UserAgent()), map[string]string{
|
||||
Transport: newTransport(ak.GetTLSTransport(), map[string]string{
|
||||
"X-authentik-remote-ip": host,
|
||||
}),
|
||||
}
|
||||
|
|
Reference in New Issue