From b7fc3344e3f3c898388831dbfad084cebdd64bb3 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 5 Feb 2024 17:07:32 +0000 Subject: Init NextAuth --- app/api/auth/[...nextauth]/route.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/api/auth/[...nextauth]/route.tsx (limited to 'app/api') diff --git a/app/api/auth/[...nextauth]/route.tsx b/app/api/auth/[...nextauth]/route.tsx new file mode 100644 index 00000000..b9decb30 --- /dev/null +++ b/app/api/auth/[...nextauth]/route.tsx @@ -0,0 +1,21 @@ +import NextAuth from "next-auth" +import { PrismaAdapter } from "@next-auth/prisma-adapter" +import AuthentikProvider from "next-auth/providers/authentik"; +import { PrismaClient } from "@prisma/client" +import serverConfig from "@/lib/config"; + +const prisma = new PrismaClient() + +let providers = []; + +if (serverConfig.auth.authentik) { + providers.push(AuthentikProvider(serverConfig.auth.authentik)); +} + +const handler = NextAuth({ + // Configure one or more authentication providers + adapter: PrismaAdapter(prisma), + providers: providers, +}); + +export { handler as GET, handler as POST } -- cgit v1.2.3-70-g09d2