Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -11,6 +11,7 @@
* invoke `assertAdminFallbackLoginAllowed` before validating credentials
* and audit-log every fallback attempt via the admin-sso audit helper.
*/
import { assertLocalCredentialsEnvironment } from "~/utils/db/seed/localCredentialsEnvironment.server";
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
@@ -21,7 +22,14 @@ export type AdminFallbackPolicy = {
export function readAdminFallbackPolicy(env: Record<string, string | undefined> = process.env): AdminFallbackPolicy {
const rawEnabled = (env.ADMIN_FALLBACK_LOGIN_ENABLED ?? "").trim().toLowerCase();
const enabled = TRUE_VALUES.has(rawEnabled);
let localEnvironmentAllowed = false;
try {
assertLocalCredentialsEnvironment(env);
localEnvironmentAllowed = true;
} catch {
localEnvironmentAllowed = false;
}
const enabled = TRUE_VALUES.has(rawEnabled) && localEnvironmentAllowed;
const rawList = env.ADMIN_FALLBACK_LOGIN_EMAILS ?? "";
const allowlist = rawList
.split(",")
@@ -34,10 +42,7 @@ export type FallbackEvaluation =
| { readonly ok: true; readonly policy: AdminFallbackPolicy }
| { readonly ok: false; readonly reason: "disabled" | "email-not-allowlisted" };
export function evaluateAdminFallbackLogin(
email: string,
policy: AdminFallbackPolicy = readAdminFallbackPolicy()
): FallbackEvaluation {
export function evaluateAdminFallbackLogin(email: string, policy: AdminFallbackPolicy = readAdminFallbackPolicy()): FallbackEvaluation {
if (!policy.enabled) {
return { ok: false, reason: "disabled" };
}
@@ -68,6 +73,20 @@ export function assertAdminFallbackLoginAllowed(email: string, policy?: AdminFal
}
}
/**
* Enforce the emergency fallback policy only when the resolved identity is an
* admin. Keeping this identity-aware guard in one place prevents app-host
* login paths from accidentally bypassing the explicit emergency policy.
*/
export function assertAdminFallbackLoginAllowedForIdentity(
identity: { readonly email: string; readonly admin?: unknown | null },
policy?: AdminFallbackPolicy
): void {
if (identity.admin) {
assertAdminFallbackLoginAllowed(identity.email, policy);
}
}
/**
* UI-side helper: true iff the admin login page should reveal the
* fallback toggle at all. The actual email-allowlist check happens
@@ -76,3 +95,11 @@ export function assertAdminFallbackLoginAllowed(email: string, policy?: AdminFal
export function isAdminFallbackUiVisible(env: Record<string, string | undefined> = process.env): boolean {
return readAdminFallbackPolicy(env).enabled;
}
export function isCompletedAdminFallbackLoginResponse(response: Response): boolean {
if (response.status < 300 || response.status >= 400) {
return false;
}
const setCookie = response.headers.get("set-cookie") ?? "";
return ["__Host-hivegrid_admin_session=", "hivegrid_admin_session="].some((name) => setCookie.includes(name));
}