Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+16
-32
@@ -1,13 +1,10 @@
|
||||
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
|
||||
import { redirect } from "react-router";
|
||||
import {
|
||||
AdminSsoConfigError,
|
||||
getAdminSsoClient,
|
||||
readAdminSsoEnv,
|
||||
} from "~/modules/admin-sso";
|
||||
import { AdminSsoConfigError, getAdminSsoClient, readAdminSsoEnv } from "~/modules/admin-sso";
|
||||
import { clearIdTokenCookie, readIdTokenFromRequest } from "~/modules/admin-sso/logout.server";
|
||||
import { writeAdminSsoAuditEvent } from "~/modules/admin-sso/audit.server";
|
||||
import { commitSession, getUserInfo, getUserSession } from "~/utils/session.server";
|
||||
import { getUserInfo, getUserSession, storage, validateCSRFToken } from "~/utils/session.server";
|
||||
import { endServerSession } from "~/services/auth/sessionLifecycle.server";
|
||||
|
||||
/**
|
||||
* Phase 09 Task #82 — POST /auth/admin/logout
|
||||
@@ -19,31 +16,14 @@ import { commitSession, getUserInfo, getUserSession } from "~/utils/session.serv
|
||||
* IdP doesn't trap users inside the panel.
|
||||
*/
|
||||
|
||||
// React-Router session storage is owned by ~/utils/session.server.ts; pull
|
||||
// in destroySession via getUserSession round-trip.
|
||||
async function destroyAppSession(request: Request): Promise<string> {
|
||||
const session = await getUserSession(request);
|
||||
// session.destroy() is not exposed; we explicitly clear every known key
|
||||
// through the storage adapter via a fresh response with `Set-Cookie:
|
||||
// <name>=; Max-Age=0`. The simplest path that respects the existing
|
||||
// cookie config is to call `commitSession` on a session with no userId.
|
||||
for (const key of [
|
||||
"userId",
|
||||
"lightOrDarkMode",
|
||||
"lng",
|
||||
"csrf",
|
||||
"metrics",
|
||||
"cookies",
|
||||
"impersonatingFromUserId",
|
||||
"impersonatingStartedAt",
|
||||
"theme",
|
||||
]) {
|
||||
session.unset(key);
|
||||
const sessionToken = session.get("sessionToken");
|
||||
if (typeof sessionToken === "string" && sessionToken.length > 0) {
|
||||
// Logout must still clear the browser cookie if the store is unavailable.
|
||||
await endServerSession(sessionToken).catch(() => undefined);
|
||||
}
|
||||
// commitSession returns a Set-Cookie header serializing the (now empty)
|
||||
// session. With Max-Age preserved this effectively logs the user out for
|
||||
// any handler that looks up `userId`.
|
||||
return commitSession(session);
|
||||
return storage.destroySession(session);
|
||||
}
|
||||
|
||||
async function buildLogoutRedirect(request: Request): Promise<Response> {
|
||||
@@ -83,13 +63,17 @@ async function buildLogoutRedirect(request: Request): Promise<Response> {
|
||||
}
|
||||
|
||||
export async function action({ request }: ActionFunctionArgs): Promise<Response> {
|
||||
await validateCSRFToken(request);
|
||||
return buildLogoutRedirect(request);
|
||||
}
|
||||
|
||||
// GET also works (e.g. browser back-button). React Router allows logout-via-GET
|
||||
// when CSRF for logout isn't required; we keep both to maximise compatibility.
|
||||
export async function loader({ request }: LoaderFunctionArgs): Promise<Response> {
|
||||
return buildLogoutRedirect(request);
|
||||
export async function loader(_args: LoaderFunctionArgs): Promise<Response> {
|
||||
// Logout changes authentication state and must never be triggerable by a
|
||||
// cross-site image/link navigation.
|
||||
return new Response(null, {
|
||||
status: 405,
|
||||
headers: { Allow: "POST", "Cache-Control": "no-store" },
|
||||
});
|
||||
}
|
||||
|
||||
export default function AuthAdminLogout() {
|
||||
|
||||
Reference in new issue
Block a user