diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-05 17:07:32 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-05 17:07:32 +0000 |
| commit | b7fc3344e3f3c898388831dbfad084cebdd64bb3 (patch) | |
| tree | d3f5e282ad2edb001120665d3244cd623ec3e888 /app/api/auth | |
| parent | 61b08abf0083f7aeb646fe588d673c72cd8b5493 (diff) | |
| download | karakeep-b7fc3344e3f3c898388831dbfad084cebdd64bb3.tar.zst | |
Init NextAuth
Diffstat (limited to 'app/api/auth')
| -rw-r--r-- | app/api/auth/[...nextauth]/route.tsx | 21 |
1 files changed, 21 insertions, 0 deletions
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 } |
