- Improved dashboard access control by blocking tunnel/Tailscale access when disabled.
This commit is contained in:
@@ -8,11 +8,23 @@ const SECRET = new TextEncoder().encode(
|
||||
process.env.JWT_SECRET || "9router-default-secret-change-me"
|
||||
);
|
||||
|
||||
function isTunnelRequest(request, settings) {
|
||||
const host = (request.headers.get("host") || "").split(":")[0].toLowerCase();
|
||||
const tunnelHost = settings.tunnelUrl ? new URL(settings.tunnelUrl).hostname.toLowerCase() : "";
|
||||
const tailscaleHost = settings.tailscaleUrl ? new URL(settings.tailscaleUrl).hostname.toLowerCase() : "";
|
||||
return (tunnelHost && host === tunnelHost) || (tailscaleHost && host === tailscaleHost);
|
||||
}
|
||||
|
||||
export async function POST(request) {
|
||||
try {
|
||||
const { password } = await request.json();
|
||||
const settings = await getSettings();
|
||||
|
||||
// Block login via tunnel/tailscale if dashboard access is disabled
|
||||
if (isTunnelRequest(request, settings) && settings.tunnelDashboardAccess !== true) {
|
||||
return NextResponse.json({ error: "Dashboard access via tunnel is disabled" }, { status: 403 });
|
||||
}
|
||||
|
||||
// Default password is '123456' if not set
|
||||
const storedHash = settings.password;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user