From 3ef1a37046228e800583b8875cba7b79e5c15bce Mon Sep 17 00:00:00 2001 From: Tine Date: Fri, 16 Feb 2024 14:23:07 +0100 Subject: [PATCH] fix(config): read all env variables --- example.env | 15 ++++++--------- internal/config/config.go | 3 +-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/example.env b/example.env index a4e161e..896d376 100644 --- a/example.env +++ b/example.env @@ -1,19 +1,16 @@ -# PORT +# Zdravko PORT=8000 ROOT_URL=http://localhost:8000 - -# SQLite -ZDRAVKO_DATABASE_PATH=zdravko.db -TEMPORAL_DATABASE_PATH=temporal.db - -# Session +DATABASE_PATH=zdravko.db SESSION_SECRET=your_secret +# Temporal +TEMPORAL_DATABASE_PATH=temporal.db + # OAUTH2 -# The redirect/callback url is ${ROOT_URL}/auth/callback +# The redirect/callback url is ${ROOT_URL}/oauth2/callback OAUTH2_CLIENT_ID=your_client_id OAUTH2_CLIENT_SECRET=your_client_secret -OAUTH2_SCOPES=openid,profile,email OAUTH2_ENDPOINT_TOKEN_URL=https://your_oauth2_provider/token OAUTH2_ENDPOINT_AUTH_URL=https://your_oauth2_provider/auth OAUTH2_ENDPOINT_USER_INFO_URL=https://your_oauth2_provider/userinfo diff --git a/internal/config/config.go b/internal/config/config.go index 84f4bb8..cfc36aa 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -88,7 +88,6 @@ func NewConfig() *Config { viper.SetDefault("port", GetEnvOrDefault("PORT", "8000")) viper.SetDefault("rooturl", GetEnvOrDefault("ROOT_URL", "http://localhost:8000")) viper.SetDefault("databasepath", GetEnvOrDefault("DATABASE_PATH", "zdravko.db")) - viper.SetDefault("oauth2.scopes", GetEnvOrDefault("OAUTH2_ENDPOINT_SCOPE", "openid profile email")) viper.SetDefault("sessionsecret", os.Getenv("SESSION_SECRET")) viper.SetDefault("temporal.databasepath", GetEnvOrDefault("TEMPORAL_DATABASE_PATH", "temporal.db")) viper.SetDefault("temporal.listenaddress", GetEnvOrDefault("TEMPORAL_LISTEN_ADDRESS", "0.0.0.0")) @@ -96,7 +95,7 @@ func NewConfig() *Config { viper.SetDefault("temporal.serverhost", GetEnvOrDefault("TEMPORAL_SERVER_HOST", "127.0.0.1:7233")) viper.SetDefault("oauth2.clientid", os.Getenv("OAUTH2_CLIENT_ID")) viper.SetDefault("oauth2.clientsecret", os.Getenv("OAUTH2_CLIENT_SECRET")) - viper.SetDefault("oauth2.scope", os.Getenv("OAUTH2_ENDPOINT_SCOPE")) + viper.SetDefault("oauth2.scopes", GetEnvOrDefault("OAUTH2_ENDPOINT_SCOPES", "openid profile email")) viper.SetDefault("oauth2.endpointtokenurl", os.Getenv("OAUTH2_ENDPOINT_TOKEN_URL")) viper.SetDefault("oauth2.endpointauthurl", os.Getenv("OAUTH2_ENDPOINT_AUTH_URL")) viper.SetDefault("oauth2.endpointuserinfourl", os.Getenv("OAUTH2_ENDPOINT_USER_INFO_URL"))