mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-22 21:28:12 +02:00
feat: implement runtime authentication handling
- Added a new proxy function to manage runtime authentication types and set cookies accordingly. - Introduced runtime authentication configuration to dynamically adjust UI based on the selected auth type. - Updated global styles to hide specific authentication buttons based on the current auth type. - Refactored sign-in button and hero section components to utilize the new runtime authentication logic. - Created a new utility file for runtime authentication configuration and initialization script.
This commit is contained in:
parent
03e57bdf7e
commit
b54eff648e
6 changed files with 130 additions and 40 deletions
24
surfsense_web/proxy.ts
Normal file
24
surfsense_web/proxy.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { NextResponse, type NextRequest } from "next/server";
|
||||
import { BUILD_TIME_AUTH_TYPE } from "@/lib/env-config";
|
||||
import {
|
||||
RUNTIME_AUTH_TYPE_COOKIE_NAME,
|
||||
resolveRuntimeAuthUiMode,
|
||||
} from "@/lib/runtime-auth-config";
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const response = NextResponse.next();
|
||||
const authType = resolveRuntimeAuthUiMode(process.env.AUTH_TYPE, BUILD_TIME_AUTH_TYPE);
|
||||
|
||||
response.cookies.set(RUNTIME_AUTH_TYPE_COOKIE_NAME, authType, {
|
||||
path: "/",
|
||||
maxAge: 60 * 60 * 24 * 365,
|
||||
sameSite: "lax",
|
||||
secure: request.nextUrl.protocol === "https:",
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/((?!api|auth|_next/static|_next/image|favicon.ico|.*\\..*).*)"],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue