www: add feature to enforce login on transcripts record/past/browse

This commit is contained in:
2023-10-18 17:18:16 +02:00
committed by Mathieu Virbel
parent 168e4d6fa4
commit ef2f579fc1
3 changed files with 77 additions and 61 deletions

View File

@@ -2,19 +2,21 @@ import type { NextRequest } from "next/server";
import { fiefAuth } from "./app/lib/fief";
const authMiddleware = fiefAuth.middleware([
{
matcher: "/private",
parameters: {},
},
{
matcher: "/castles/:path*",
parameters: {
permissions: ["castles:read"],
let protectedPath: any = [];
if (process.env.NEXT_PUBLIC_FEAT_LOGIN_REQUIRED === "1") {
protectedPath = [
{
matcher: "/transcripts/((?!new).*)",
parameters: {},
},
},
]);
{
matcher: "/browse",
parameters: {},
},
];
}
const authMiddleware = fiefAuth.middleware(protectedPath);
export async function middleware(request: NextRequest) {
return authMiddleware(request);
}