internal: better error message when outpost API controller couldn't fetch outposts

closes #4642

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-02-08 14:13:12 +01:00
parent 9398fbcf9e
commit 5aa43eeb04
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -55,7 +55,13 @@ func NewAPIController(akURL url.URL, token string) *APIController {
config.Host = akURL.Host config.Host = akURL.Host
config.Scheme = akURL.Scheme config.Scheme = akURL.Scheme
config.HTTPClient = &http.Client{ config.HTTPClient = &http.Client{
Transport: web.NewUserAgentTransport(constants.OutpostUserAgent(), web.NewTracingTransport(rsp.Context(), GetTLSTransport())), Transport: web.NewUserAgentTransport(
constants.OutpostUserAgent(),
web.NewTracingTransport(
rsp.Context(),
GetTLSTransport(),
),
),
} }
config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token)) config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token))
@ -73,6 +79,9 @@ func NewAPIController(akURL url.URL, token string) *APIController {
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)
return NewAPIController(akURL, token) return NewAPIController(akURL, token)
} }
if len(outposts.Results) < 1 {
panic("No outposts found with given token, ensure the given token corresponds to an authenitk Outpost")
}
outpost := outposts.Results[0] outpost := outposts.Results[0]
log.WithField("name", outpost.Name).Debug("Fetched outpost configuration") log.WithField("name", outpost.Name).Debug("Fetched outpost configuration")