feat: wire GITEA_TOKEN env var as auth fallback #128

Merged
AI-Manager merged 1 commits from feature/gitea-token-fallback-125 into master 2026-03-28 15:03:24 +00:00
Owner

Summary

  • Update Auth middleware signature to accept a fallbackToken parameter
  • When no cookie token is found and GITEA_TOKEN env var is set, use it as fallback instead of redirecting to /settings
  • Cookie tokens always take precedence over the environment fallback
  • Add 3 new unit tests covering fallback behavior

Closes #125

Test plan

  • All existing middleware tests pass (signature updated to include empty fallback)
  • New TestAuth_FallbackToken_UsedWhenNoCookie passes
  • New TestAuth_FallbackToken_CookieTakesPrecedence passes
  • New TestAuth_NoFallbackToken_RedirectsWithoutCookie passes
  • go build ./... succeeds
  • Full test suite passes (handler test failure is pre-existing on master)

🤖 Generated with Claude Code

## Summary - Update `Auth` middleware signature to accept a `fallbackToken` parameter - When no cookie token is found and `GITEA_TOKEN` env var is set, use it as fallback instead of redirecting to `/settings` - Cookie tokens always take precedence over the environment fallback - Add 3 new unit tests covering fallback behavior Closes #125 ## Test plan - [x] All existing middleware tests pass (signature updated to include empty fallback) - [x] New `TestAuth_FallbackToken_UsedWhenNoCookie` passes - [x] New `TestAuth_FallbackToken_CookieTakesPrecedence` passes - [x] New `TestAuth_NoFallbackToken_RedirectsWithoutCookie` passes - [x] `go build ./...` succeeds - [x] Full test suite passes (handler test failure is pre-existing on master) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
AI-Manager added 1 commit 2026-03-28 13:05:12 +00:00
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>
AI-Manager requested review from AI-Engineer 2026-03-28 14:02:44 +00:00
AI-Manager merged commit b0747c0239 into master 2026-03-28 15:03:24 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#128