feat: Google OAuth login + server sessions (user_key u:<sub>)

This commit is contained in:
asepharyana
2026-09-15 16:29:57 +07:00
parent fee313ce97
commit 1881e7c6b1
6 changed files with 410 additions and 1 deletions
+14
View File
@@ -29,6 +29,17 @@ type Config struct {
Watchlist []string
// StaticDir serves the prebuilt web dist (WEB_DIST_DIR). Empty = API only.
StaticDir string
// Google OAuth (login). Empty client ID = auth endpoints 404.
GoogleClientID string
GoogleClientSecret string
GoogleRedirectURL string
}
// HasGoogle reports whether Google OAuth login is configured.
func (c Config) HasGoogle() bool {
return strings.TrimSpace(c.GoogleClientID) != "" &&
strings.TrimSpace(c.GoogleClientSecret) != "" &&
strings.TrimSpace(c.GoogleRedirectURL) != ""
}
// HasSectorsKey reports whether live Sectors API calls are possible.
@@ -86,5 +97,8 @@ func Load() Config {
CreditCapPerCycle: getenvInt("CREDIT_CAP_PER_CYCLE", 120),
Watchlist: tickers,
StaticDir: os.Getenv("WEB_DIST_DIR"),
GoogleClientID: os.Getenv("GOOGLE_CLIENT_ID"),
GoogleClientSecret: os.Getenv("GOOGLE_CLIENT_SECRET"),
GoogleRedirectURL: os.Getenv("GOOGLE_REDIRECT_URL"),
}
}