feat: wire GITEA_TOKEN env var as auth fallback for single-user deployments
Update Auth middleware to accept a fallbackToken parameter. When no per-user cookie token is present and GITEA_TOKEN is set in the environment, the middleware uses the env token instead of redirecting to /settings. Cookie tokens still take precedence over the fallback. Add three new unit tests covering: fallback used when no cookie, cookie takes precedence over fallback, and redirect when neither is set. Closes leeworks-agents/gitea-mobile#125 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ func main() {
|
||||
|
||||
// Apply middleware chain: logging -> auth.
|
||||
var handler http.Handler = mux
|
||||
handler = middleware.Auth(cfg.SessionSecret)(handler)
|
||||
handler = middleware.Auth(cfg.SessionSecret, cfg.GiteaToken)(handler)
|
||||
handler = middleware.Logging()(handler)
|
||||
|
||||
slog.Info("server starting", "addr", cfg.ListenAddr, "gitea_url", cfg.GiteaURL)
|
||||
|
||||
Reference in New Issue
Block a user