- Clear default passwords in all service configs, require env vars
- Add JWT auth + role middleware to WebSocket endpoints
- Add origin whitelist to WebSocket upgrader (CORS protection)
- Fix goroutine leak in WS proxy (double errCh read)
- Update docker-compose to require secrets via ${VAR:?...} syntax
- Mark deprecated k8s configmap passwords as REPLACE_AT_DEPLOY_TIME
Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
907 B
Go
36 lines
907 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
Port string
|
|
JWTSecret string
|
|
AuthServiceURL string
|
|
PurchaserServiceURL string
|
|
TextileServiceURL string
|
|
WashingServiceURL string
|
|
AllowOrigins []string
|
|
}
|
|
|
|
func Load() *Config {
|
|
return &Config{
|
|
Port: getEnv("PORT", "8080"),
|
|
JWTSecret: getEnv("JWT_SECRET", ""),
|
|
AuthServiceURL: getEnv("AUTH_SERVICE_URL", "http://localhost:8081"),
|
|
PurchaserServiceURL: getEnv("PURCHASER_SERVICE_URL", "http://localhost:8082"),
|
|
TextileServiceURL: getEnv("TEXTILE_SERVICE_URL", "http://localhost:8083"),
|
|
WashingServiceURL: getEnv("WASHING_SERVICE_URL", "http://localhost:8084"),
|
|
AllowOrigins: strings.Split(getEnv("ALLOW_ORIGINS", "*"), ","),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|