Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6501eac38a | |||
| 7f9206ae77 | |||
| 6229f8e886 |
@@ -19,7 +19,11 @@ export async function GET(req: NextRequest) {
|
|||||||
req.headers.get("x-forwarded-host") || req.headers.get("host") || "";
|
req.headers.get("x-forwarded-host") || req.headers.get("host") || "";
|
||||||
const proto = req.headers.get("x-forwarded-proto") || "https";
|
const proto = req.headers.get("x-forwarded-proto") || "https";
|
||||||
|
|
||||||
const loginUrl = `${proto}://${host}/gatekeeper/login?redirect=${encodeURIComponent(originalUrl)}`;
|
const gatekeeperUrl =
|
||||||
|
process.env.NEXT_PUBLIC_BASE_URL || `${proto}://gatekeeper.${host}`;
|
||||||
|
const absoluteOriginalUrl = `${proto}://${host}${originalUrl}`;
|
||||||
|
|
||||||
|
const loginUrl = `${gatekeeperUrl}/login?redirect=${encodeURIComponent(absoluteOriginalUrl)}`;
|
||||||
|
|
||||||
return NextResponse.redirect(loginUrl);
|
return NextResponse.redirect(loginUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export default async function LoginPage({ searchParams }: LoginPageProps) {
|
|||||||
const authCookieName =
|
const authCookieName =
|
||||||
process.env.AUTH_COOKIE_NAME || "mintel_gatekeeper_session";
|
process.env.AUTH_COOKIE_NAME || "mintel_gatekeeper_session";
|
||||||
const targetRedirect = formData.get("redirect") as string;
|
const targetRedirect = formData.get("redirect") as string;
|
||||||
|
const cookieDomain = process.env.COOKIE_DOMAIN;
|
||||||
|
|
||||||
if (password === expectedPassword) {
|
if (password === expectedPassword) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
@@ -31,12 +32,11 @@ export default async function LoginPage({ searchParams }: LoginPageProps) {
|
|||||||
path: "/",
|
path: "/",
|
||||||
maxAge: 30 * 24 * 60 * 60, // 30 days
|
maxAge: 30 * 24 * 60 * 60, // 30 days
|
||||||
sameSite: "lax",
|
sameSite: "lax",
|
||||||
|
...(cookieDomain ? { domain: cookieDomain } : {}),
|
||||||
});
|
});
|
||||||
redirect(targetRedirect);
|
redirect(targetRedirect);
|
||||||
} else {
|
} else {
|
||||||
redirect(
|
redirect(`/login?error=1&redirect=${encodeURIComponent(targetRedirect)}`);
|
||||||
`/gatekeeper/login?error=1&redirect=${encodeURIComponent(targetRedirect)}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default function RootPage() {
|
export default function RootPage() {
|
||||||
redirect("/gatekeeper/login");
|
redirect("/login");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,12 @@ ENV NODE_ENV=production
|
|||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
COPY --from=builder /app/packages/gatekeeper/public ./packages/gatekeeper/public
|
# Set the correct permission for prerender cache
|
||||||
COPY --from=builder /app/packages/gatekeeper/.next/standalone ./
|
RUN mkdir -p packages/gatekeeper/.next && chown nextjs:nodejs packages/gatekeeper/.next
|
||||||
COPY --from=builder /app/packages/gatekeeper/.next/static ./packages/gatekeeper/.next/static
|
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/packages/gatekeeper/public ./packages/gatekeeper/public
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/packages/gatekeeper/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/packages/gatekeeper/.next/static ./packages/gatekeeper/.next/static
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
Reference in New Issue
Block a user