feat: optional custom admin login path — matches a Remnawave-listed security measure Marzban doesn't have
Pulled a fresh copy of docs.rw's own Remnawave-vs-Marzban comparison table (not working from memory of an earlier read) to check what's still genuinely different after tonight's run of fixes — most rows already match or beat both panels (multi-admin, 2FA, HWID limits, backup/restore, host sorting, config validation, node autonomy, on-hold status as of a few commits ago). One concrete, bounded, unclaimed row: "Security measures in documentation" lists CF zero trust / custom path / Telegram OAuth / 2FA for Remnawave, nothing for Marzban. We already had 2FA and rate-limiting; custom path was the missing, actually implementable piece — everything else in that row is deployment guidance, not panel code. New ADMIN_PATH env var (config.py, defaults to "admin" — every existing install keeps working exactly as before with zero action needed). The page-serving route moves to whatever path is configured; root() on PANEL_DOMAIN only falls through to serving admin.html when ADMIN_PATH is still the default, otherwise it shows the same branded landing page every other domain gets — so a scanner or a human guessing "/admin" finds nothing once this is set, not even a redirect that confirms something lives there. Deliberately scoped to ONLY the page route. /admin/api/* stays fixed — it's already behind real cookie+session auth (verified this while auditing: every mutating admin route either calls require_admin() or the equivalent _require_current_admin(), checked programmatically via ast rather than trusting my memory of having added the check everywhere — found nothing actually missing, which is itself worth knowing, not just assumed). Moving the API namespace too would be a much bigger, riskier rewrite of every @app decorator in the file for no real security gain over what auth already provides. Deliberately NOT exposed in the Settings UI, unlike almost everything else made live-editable tonight. This one genuinely needs a process restart to take effect (FastAPI resolves routes at import time, not per-request), and a typo saved through the UI followed by a restart is a real self-lockout risk with no web-based way back — same tier as PANEL_DOMAIN/SUB_DOMAIN, which are also .env-only for the same reason. .env + SSH is the correct blast radius for a setting that can lock you out. Verification: config.py's normalization (strip slashes, empty/lone- slash/repeated-slash input all falling back to "admin" rather than accidentally producing a route at bare "/") tested directly — 8 cases. AST-extracted the updated root() out of api.py (still can't import the module locally) and exercised its actual branching with a mocked FileResponse/legal/request — confirmed the default case is byte-for- byte the old behavior and the custom-path case stops serving admin.html on PANEL_DOMAIN's root. Added a dedicated CI step that does what only a real FastAPI import can prove: with ADMIN_PATH set, /xyz123secret is a registered route, plain /admin is NOT (not just supplemented — actually gone), and /admin/api/login is untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
f6e4e52b65
commit
670579fccd
6 changed files with 48 additions and 3 deletions
|
|
@ -21,6 +21,15 @@ PANEL_DOMAIN=panel.example.com
|
|||
SUB_DOMAIN=sub.example.com
|
||||
SITE_DOMAIN=example.com
|
||||
|
||||
# Optional: move the admin login off the well-known /admin path (e.g. to a
|
||||
# random string) so it doesn't show up to anyone scanning for /admin,
|
||||
# /login etc. Leave unset for the default. This is on top of the existing
|
||||
# rate-limiting and 2FA, not instead of them. Requires `mbs restart` to
|
||||
# take effect (it's a route, not a setting the running process can pick up
|
||||
# live) — write it down somewhere before you restart, there's no UI for
|
||||
# this on purpose, only .env + SSH can get you back in if you forget it.
|
||||
ADMIN_PATH=admin
|
||||
|
||||
# Reality identity for the local node (this same box). Generate with:
|
||||
# /usr/local/bin/xray x25519
|
||||
# XRAY_PUBLIC_KEY is the "Password (PublicKey)" line; keep the matching
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue