Skip to content

feat: add proxy auth#971

Merged
perber merged 3 commits into
mainfrom
feature/reverse-proxy-auth
May 8, 2026
Merged

feat: add proxy auth#971
perber merged 3 commits into
mainfrom
feature/reverse-proxy-auth

Conversation

@perber

@perber perber commented May 8, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 8, 2026 12:16
@perber
perber force-pushed the feature/reverse-proxy-auth branch from bd5cc45 to 166caa3 Compare May 8, 2026 12:18
Handle returned errors from test cleanup callbacks in reverse proxy auth tests so errcheck passes in CI.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + InjectRemoteUser middleware; add /api/auth/me; plumb new CLI flags and config fields through /api/config.
  • Frontend: add config flags, bootstrap auth via /api/auth/me when proxy auth is enabled, and support proxy logout redirect.
  • Testing/CI: add e2e-proxy Docker 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.

Comment thread internal/http/middleware/auth/reverse_proxy.go
Comment thread internal/http/middleware/auth/auth.go Outdated
Validate upstream user context before RequireAuth short-circuits and return 500 for reverse proxy auth misconfiguration instead of panicking.
@perber
perber merged commit 81ad519 into main May 8, 2026
6 checks passed
@perber
perber deleted the feature/reverse-proxy-auth branch May 13, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Trusted-proxy header auth (auto-login from a reverse proxy)

2 participants