From c18b6bcd6c223c6c9168d9a8648cb5ee07181f10 Mon Sep 17 00:00:00 2001 From: Carlos Cobo <699969+toqueteos@users.noreply.github.com> Date: Tue, 23 Jul 2024 23:33:29 +0200 Subject: [PATCH] Read Console credentials from environment variables first --- server/config.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/config.go b/server/config.go index dc9e3bee0c..b693b2b1d6 100644 --- a/server/config.go +++ b/server/config.go @@ -977,8 +977,8 @@ func NewConsoleConfig() *ConsoleConfig { ReadTimeoutMs: 10 * 1000, WriteTimeoutMs: 60 * 1000, IdleTimeoutMs: 300 * 1000, - Username: "admin", - Password: "password", + Username: getEnvOr("NAKAMA_CONSOLE_USERNAME", "admin"), + Password: getEnvOr("NAKAMA_CONSOLE_PASSWORD", "password"), TokenExpirySec: 86400, SigningKey: "defaultsigningkey", } @@ -1116,3 +1116,11 @@ type StorageConfig struct { func NewStorageConfig() *StorageConfig { return &StorageConfig{} } + +func getEnvOr(key, fallback string) string { + value := strings.TrimSpace(os.Getenv(key)) + if value == "" { + return fallback + } + return value +}