Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
add OIDC issuer config field, checks for it being set, and placeholde…
Browse files Browse the repository at this point in the history
…r config map entries
  • Loading branch information
DoctorVin committed May 9, 2024
1 parent 90551d5 commit 8b2899f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 6 additions & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
image:
repo: "localhost:5001/component-inventory"
repo: "localhost:5001"
tag: latest
pullPolicy: Always

Expand All @@ -15,3 +15,8 @@ fleetdb:
env:
endpoint: http://fleetdb:8000
disable_oauth: true
audience_endpoint: "placeholder"
issuer_endpoint: "placeholder"
client_id: "placeholder"
client_scopes:
- "placeholder"
16 changes: 12 additions & 4 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,39 @@ func envVarOverrides(v *viper.Viper, cfg *Configuration) error {
}

if cfg.FleetDBOpts.AudienceEndpoint == "" {
return errors.New("fleetdb client secret not defined")
return errors.New("fleetdb OIDC audience endpoint not defined")
}

if v.GetString("fleetdb.issuer.endpoint") != "" {
cfg.FleetDBOpts.IssuerEndpoint = v.GetString("fleetdb.issuer.endpoint")
}

if cfg.FleetDBOpts.IssuerEndpoint == "" {
return errors.New("fleetdb OIDC issuer endpoint not defined")
}

if v.GetString("fleetdb.client.id") != "" {
cfg.FleetDBOpts.ClientID = v.GetString("fleetdb.client.id")
}

if cfg.FleetDBOpts.ClientID == "" {
return errors.New("fleetdb client id not defined")
return errors.New("fleetdb OIDC client id not defined")
}

if v.GetString("fleetdb.client.secret") != "" {
cfg.FleetDBOpts.ClientSecret = v.GetString("fleetdb.client.secret")
}

if cfg.FleetDBOpts.ClientSecret == "" {
return errors.New("fleetdb client secret not defined")
return errors.New("fleetdb OIDC client secret not defined")
}

if v.GetString("fleetdb.client.scopes") != "" {
cfg.FleetDBOpts.ClientScopes = v.GetStringSlice("fleetdb.client.scopes")
}

if len(cfg.FleetDBOpts.ClientScopes) == 0 {
return errors.New("fleetdb client scopes not defined")
return errors.New("fleetdb OIDC client scopes not defined")
}

return nil
Expand Down
1 change: 1 addition & 0 deletions internal/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type FleetDBAPIOptions struct {
Endpoint string `mapstructure:"endpoint"`
DisableOAuth bool `mapstructure:"disable_oauth"`
AudienceEndpoint string `mapstructure:"audience_endpoint"`
IssuerEndpoint string `mapstructure:"issuer_endpoint"`
ClientID string `mapstructure:"client_id"`
ClientSecret string `mapstructure:"client_secret"`
ClientScopes []string `mapstructure:"client_scopes"`
Expand Down

0 comments on commit 8b2899f

Please sign in to comment.