outpost: load global config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
6433b5982e
commit
2015d91484
|
@ -26,10 +26,12 @@ const ConfigErrorReportingEnvironment = "error_reporting_environment"
|
||||||
type APIController struct {
|
type APIController struct {
|
||||||
Client *api.APIClient
|
Client *api.APIClient
|
||||||
Outpost api.Outpost
|
Outpost api.Outpost
|
||||||
token string
|
GlobalConfig api.Config
|
||||||
|
|
||||||
Server Outpost
|
Server Outpost
|
||||||
|
|
||||||
|
token string
|
||||||
|
|
||||||
logger *log.Entry
|
logger *log.Entry
|
||||||
|
|
||||||
reloadOffset time.Duration
|
reloadOffset time.Duration
|
||||||
|
@ -54,12 +56,18 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
||||||
|
|
||||||
log := log.WithField("logger", "authentik.outpost.ak-api-controller")
|
log := log.WithField("logger", "authentik.outpost.ak-api-controller")
|
||||||
|
|
||||||
|
akConfig, _, err := apiClient.RootApi.RootConfigRetrieve(context.Background()).Execute()
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Error("Failed to fetch global configuration")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Because we don't know the outpost UUID, we simply do a list and pick the first
|
// Because we don't know the outpost UUID, we simply do a list and pick the first
|
||||||
// The service account this token belongs to should only have access to a single outpost
|
// The service account this token belongs to should only have access to a single outpost
|
||||||
outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute()
|
outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("Failed to fetch configuration")
|
log.WithError(err).Error("Failed to fetch outpost configuration")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
outpost := outposts.Results[0]
|
outpost := outposts.Results[0]
|
||||||
|
@ -67,8 +75,9 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
||||||
|
|
||||||
ac := &APIController{
|
ac := &APIController{
|
||||||
Client: apiClient,
|
Client: apiClient,
|
||||||
token: token,
|
GlobalConfig: akConfig,
|
||||||
|
|
||||||
|
token: token,
|
||||||
logger: log,
|
logger: log,
|
||||||
|
|
||||||
reloadOffset: time.Duration(rand.Intn(10)) * time.Second,
|
reloadOffset: time.Duration(rand.Intn(10)) * time.Second,
|
||||||
|
|
Reference in New Issue