blob: ebecb7336b3a286280c93f217dd0e20bf1668b66 [file] [log] [blame]
Samuel Shuert341d4a62024-02-04 14:51:12 -05001import NextAuth, { type AuthOptions } from "next-auth"
Samuel Shuertf4deb4e2024-02-04 13:56:30 -05002import KeycloakProvider from "next-auth/providers/keycloak";
Samuel Shuert341d4a62024-02-04 14:51:12 -05003import { DrizzleAdapter } from "@auth/drizzle-adapter";
4import { db } from "@/db"
Samuel Shuertf4deb4e2024-02-04 13:56:30 -05005
6let getSecrets = () => {
7 let clientId = process.env.CLIENT_ID;
8 let clientSecret = process.env.CLIENT_SECRET;
9
10 if (!clientId || !clientSecret) throw new Error("Missing Client Environment Vars");
11 return {clientId, clientSecret}
12}
13
Samuel Shuert341d4a62024-02-04 14:51:12 -050014export const authOptions: AuthOptions = {
15 adapter: DrizzleAdapter(db), // IDK how to get this to not TS error. Followed Docs word for word
Samuel Shuertf4deb4e2024-02-04 13:56:30 -050016 providers: [
17 KeycloakProvider(Object.assign(getSecrets(), {
18 issuer: "https://`login.clicks.codes/realms/master"
19 })),
20 ],
21}
22
23
24const handler = NextAuth(authOptions)
25
26export { handler as GET, handler as POST }