Skip to content

feat: allow custom auth HTML templates#169

Open
jowgo wants to merge 1 commit into
sigbit:mainfrom
jowgo:lunar/feature-custom-auth-pages
Open

feat: allow custom auth HTML templates#169
jowgo wants to merge 1 commit into
sigbit:mainfrom
jowgo:lunar/feature-custom-auth-pages

Conversation

@jowgo

@jowgo jowgo commented May 27, 2026

Copy link
Copy Markdown

Summary

Adds an auth template override directory so deployments can customize the HTML auth pages without rebuilding the binary or forking embedded templates. The new --auth-template-dir / AUTH_TEMPLATE_DIR setting loads matching login.html, unauthorized.html, error.html, and optional styles.html files from a mounted directory, while falling back to embedded defaults for missing files.

Type of Change

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to our CI configuration files and scripts
  • chore: Other changes that do not modify src or test files
  • revert: Reverts a previous commit

Related Issues

Copilot AI review requested due to automatic review settings May 27, 2026 12:18

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for overriding embedded auth HTML templates via a configurable template directory, wiring it through CLI/env into the proxy’s auth router construction.

Changes:

  • Added --auth-template-dir / AUTH_TEMPLATE_DIR to pass a custom auth template directory into the server.
  • Implemented NewAuthRouterWithTemplateDir with helpers to load templates from disk with embedded fallbacks (plus optional styles.html).
  • Added unit tests and updated existing tests to cover the new parameter/flag.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/mcp-proxy/main.go Threads authTemplateDir into Run() and uses the new auth constructor.
pkg/mcp-proxy/main_test.go Updates Run test invocations to include the new parameter.
pkg/auth/auth.go Adds template-dir validation and template loading/parsing with disk/embedded fallback.
pkg/auth/auth_test.go Adds tests for custom template directory loading and missing-dir rejection.
main.go Adds CLI flag/env var and passes authTemplateDir into runner.
main_test.go Adds CLI flag test and updates runner signatures in other tests.
docs/docs/configuration.md Documents the new flag/env var and template override behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/auth/auth.go Outdated
Comment thread docs/docs/configuration.md Outdated
@jowgo jowgo force-pushed the lunar/feature-custom-auth-pages branch from 4940916 to 8577049 Compare May 27, 2026 12:21
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/auth/auth.go 95.91% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@jowgo jowgo force-pushed the lunar/feature-custom-auth-pages branch from 8577049 to f73c691 Compare May 27, 2026 12:57
@jowgo jowgo requested a review from a team as a code owner May 27, 2026 12:57
@jowgo jowgo requested review from hrntknr and removed request for a team May 27, 2026 12:57
@jowgo jowgo force-pushed the lunar/feature-custom-auth-pages branch from f73c691 to 75c909d Compare May 27, 2026 14:07
Production sidecars need branding changes without carrying a source fork or rebuilding embedded templates for each environment. The proxy now accepts an auth template directory and loads matching page files from it while keeping embedded defaults for missing files.

Constraint: Existing embedded templates must remain the default behavior when no override directory is configured

Rejected: Add separate flags for each template file | A single directory is easier to mount in containers and supports incremental overrides

Confidence: high

Scope-risk: narrow

Directive: Keep template data contracts stable when editing default auth pages; external templates depend on those fields

Tested: go test ./...

Tested: go build -o bin/mcp-auth-proxy .
@jowgo jowgo force-pushed the lunar/feature-custom-auth-pages branch from 75c909d to ec9edc1 Compare May 27, 2026 14:19
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.

3 participants