Skip to content

Commit

Permalink
Update configuration settings (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmv authored Feb 4, 2025
1 parent 6539684 commit d58ee06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ SD_DB=postgresql://pg:pass@localhost:5432/status_dashboard
SD_CACHE=internal
SD_LOG_LEVEL=devel
SD_WEB_URL=http://localhost:9000
SD_HOSTNAME=localhost
SD_SSL_DISABLED=false
SD_HOSTNAME=http://localhost:8000
SD_PORT=8000
SD_AUTHENTICATION_DISABLED=false
SD_KEYCLOAK_URL=http://localhost:8080
Expand Down
15 changes: 3 additions & 12 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,11 @@ func New(cfg *conf.Config, log *zap.Logger, database *db.DB) (*API, error) {
oa2Prov := &auth.Provider{Disabled: true}

if !cfg.AuthenticationDisabled {
hostURI := fmt.Sprintf("%s:%s", cfg.Hostname, cfg.Port)

if cfg.SSLDisabled {
hostURI = fmt.Sprintf("http://%s", hostURI)
} else {
hostURI = fmt.Sprintf("https://%s", hostURI)
}

var err error
oa2Prov, err = auth.NewProvider(
if oa2Prov, err = auth.NewProvider(
cfg.Keycloak.URL, cfg.Keycloak.Realm, cfg.Keycloak.ClientID,
cfg.Keycloak.ClientSecret, hostURI, cfg.WebURL,
)
if err != nil {
cfg.Keycloak.ClientSecret, cfg.Hostname, cfg.WebURL,
); err != nil {
return nil, fmt.Errorf("could not initialise the OAuth provider, err: %w", err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ type Config struct {
LogLevel string `envconfig:"LOG_LEVEL"`
// App port
Port string `envconfig:"PORT"`
// Hostname for the app, mostly used to generate a callback URL for keycloak
// Hostname for the app, used to generate a callback URL for keycloak
// Example: https://api.example.com
Hostname string `envconfig:"HOSTNAME"`
// Enable SSL for the app
SSLDisabled bool `envconfig:"SSL_DISABLED"`
// Web URL for the app
// Example: https://web.example.com
WebURL string `envconfig:"WEB_URL"`
// Disable authentication for any reasons it doesn't work with hostname like "*prod*"
AuthenticationDisabled bool `envconfig:"AUTHENTICATION_DISABLED"`
Expand Down

0 comments on commit d58ee06

Please sign in to comment.