feat: add proxy auth#971
Merged
Merged
Conversation
perber
force-pushed
the
feature/reverse-proxy-auth
branch
from
May 8, 2026 12:18
bd5cc45 to
166caa3
Compare
Handle returned errors from test cleanup callbacks in reverse proxy auth tests so errcheck passes in CI.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds reverse-proxy (header-based) authentication support end-to-end: backend can inject a user from a trusted proxy header, UI can bootstrap the session via /api/auth/me, and CI gains a Docker+nginx integration test suite to validate the flow.
Changes:
- Backend: introduce trusted-proxy parsing +
InjectRemoteUsermiddleware; add/api/auth/me; plumb new CLI flags and config fields through/api/config. - Frontend: add config flags, bootstrap auth via
/api/auth/mewhen proxy auth is enabled, and support proxy logout redirect. - Testing/CI: add
e2e-proxyDocker Compose + Go tests and a dedicated GitHub Actions workflow and Makefile target.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/leafwiki-ui/src/stores/config.ts | Stores new proxy-auth config flags from /api/config. |
| ui/leafwiki-ui/src/lib/bootstrapAuth.ts | Bootstraps user via /api/auth/me when proxy auth is enabled. |
| ui/leafwiki-ui/src/lib/api/config.ts | Extends config API type with proxy-auth fields. |
| ui/leafwiki-ui/src/lib/api/auth.ts | Adds fetchMe() helper to load current user via /api/auth/me. |
| ui/leafwiki-ui/src/components/UserToolbar.tsx | Redirects to proxy logout URL (when configured) and conditionally shows Logout. |
| Makefile | Adds run-proxy-e2e target and help text. |
| internal/wiki/wiki.go | Exposes UserService() getter for wiring middleware. |
| internal/wiki/auth/routes.go | Adds /api/auth/me and returns proxy-auth flags in /api/config. |
| internal/http/router.go | Wires reverse-proxy auth middleware behind new router options. |
| internal/http/middleware/auth/trusted_proxies.go | Implements trusted proxy IP/CIDR parsing and matching. |
| internal/http/middleware/auth/trusted_proxies_test.go | Unit tests for trusted proxy parsing/matching. |
| internal/http/middleware/auth/reverse_proxy.go | Adds InjectRemoteUser middleware to resolve user from header. |
| internal/http/middleware/auth/reverse_proxy_test.go | Unit tests for InjectRemoteUser and RequireAuth short-circuiting. |
| internal/http/middleware/auth/auth.go | Allows RequireAuth to short-circuit when a user is already injected. |
| internal/core/auth/user_service.go | Adds GetUserByUsername used by proxy middleware. |
| e2e-proxy/setup_test.go | E2E test harness setup + stack reachability check. |
| e2e-proxy/run.sh | Script to start stack, run tests, and tear down. |
| e2e-proxy/proxy_auth_test.go | End-to-end verification of proxy header auth and JWT fallback via nginx. |
| e2e-proxy/nginx/nginx.conf | Nginx config for forwarding/overwriting Remote-User in tests. |
| e2e-proxy/go.mod | Separate Go module for proxy E2E tests. |
| e2e-proxy/docker-compose.yml | LeafWiki + nginx compose stack for proxy E2E. |
| .github/workflows/proxy-auth-e2e.yml | CI workflow to run proxy-auth E2E tests on PRs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Validate upstream user context before RequireAuth short-circuits and return 500 for reverse proxy auth misconfiguration instead of panicking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.