[Feature Request] Add optional authentication for the admin API/UI (currently fully unauthenticated) (middleware-manager #115)

:octopus: GitHub issue middleware-manager #115, opened by fukajan on GitHub

Problem

api/server.go (setupRoutes) registers all administrative routes — /api/middlewares, /api/resources/* (middleware/service/router assignment), /api/plugins/install, /api/mtls/* (CA creation, client cert issuance/revocation), /api/security/* (TLS hardening, secure headers toggles) — as well as the web UI (static.Serve(“/”, …)) with no authentication. router.Use() only registers gin.Recovery(), an optional logger, and optional CORS — there’s no auth middleware anywhere in the chain.

Anyone who can reach the configured port has full administrative control: install/remove Traefik plugins, issue or revoke mTLS client certificates, disable TLS hardening, reassign middlewares on any resource — with zero credentials. Given this tool’s job (managing the security-relevant middleware/plugin/mTLS layer in front of production services), this is a real gap for anyone who can’t fully air-gap the container on its own network — and the docs’ own quick-start examples show ports: [“3456:3456”] published directly, which doesn’t help.

Proposed direction — two options, open to either

Both keep the current behavior as default (auth disabled) so existing deployments relying on network isolation aren’t affected.

Option A — Basic Auth with a generated token

MM_AUTH_ENABLED=true
MM_AUTH_USER=admin
MM_AUTH_TOKEN=<random secret, not a human-chosen password>
  • Single gin.BasicAuth()-based middleware, registered via router.Use() before setupRoutes() runs, so it covers …

:speech_balloon: Discuss it here. Status, fixes and code review stay on GitHub.