Add OpenShell Control auth and installer

This commit is contained in:
Codex
2026-04-24 20:52:44 +00:00
parent 8e3b5332d4
commit ad8e25c056
27 changed files with 2057 additions and 298 deletions
+24
View File
@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from "next/server"
import { createSessionCookieValue, getAuthSettings, sessionCookieOptions, verifyPassword } from "@/app/lib/controlAuth"
export async function POST(request: NextRequest) {
const settings = getAuthSettings()
if (!settings.configured) {
return NextResponse.json({
ok: false,
error: "Dashboard auth is not configured. Set OPENSHELL_CONTROL_PASSWORD and restart the dashboard.",
}, { status: 503 })
}
const body = await request.json().catch(() => ({}))
const password = typeof body?.password === "string" ? body.password : ""
const nextPath = typeof body?.next === "string" && body.next.startsWith("/") ? body.next : "/"
if (!await verifyPassword(password)) {
return NextResponse.json({ ok: false, error: "Invalid password" }, { status: 401 })
}
const response = NextResponse.json({ ok: true, next: nextPath })
response.cookies.set(settings.cookieName, await createSessionCookieValue(), sessionCookieOptions)
return response
}