diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-06 12:26:29 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-06 12:26:29 +0000 |
| commit | 083ea5bd19172381bb53e95aaf98eaabef839c54 (patch) | |
| tree | 4d1c041aab7cd8d15382330db08caeb9c5a12c63 /web/lib/auth.ts | |
| parent | b792121977ade8bdd3fb62704b65a9fcbd1436b9 (diff) | |
| download | karakeep-083ea5bd19172381bb53e95aaf98eaabef839c54.tar.zst | |
Move the web app into a subdir
Diffstat (limited to 'web/lib/auth.ts')
| -rw-r--r-- | web/lib/auth.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/web/lib/auth.ts b/web/lib/auth.ts new file mode 100644 index 00000000..9b21e605 --- /dev/null +++ b/web/lib/auth.ts @@ -0,0 +1,25 @@ +import NextAuth, { NextAuthOptions } from "next-auth" +import { PrismaAdapter } from "@next-auth/prisma-adapter" +import AuthentikProvider from "next-auth/providers/authentik"; +import serverConfig from "@/lib/config"; +import prisma from "@/lib/prisma"; + +let providers = []; + +if (serverConfig.auth.authentik) { + providers.push(AuthentikProvider(serverConfig.auth.authentik)); +} + +export const authOptions: NextAuthOptions = { + // Configure one or more authentication providers + adapter: PrismaAdapter(prisma), + providers: providers, + callbacks: { + session({ session, token, user }) { + session.user = { ...user }; + return session; + } + } +}; + +export const authHandler = NextAuth(authOptions); |
