| import NextAuth, { type AuthOptions } from "next-auth" |
| import KeycloakProvider from "next-auth/providers/keycloak"; |
| import { DrizzleAdapter } from "@auth/drizzle-adapter"; |
| import { db } from "@/db" |
| |
| let getSecrets = () => { |
| let clientId = process.env.CLIENT_ID; |
| let clientSecret = process.env.CLIENT_SECRET; |
| |
| if (!clientId || !clientSecret) throw new Error("Missing Client Environment Vars"); |
| return {clientId, clientSecret} |
| } |
| |
| export const authOptions: AuthOptions = { |
| adapter: DrizzleAdapter(db), // IDK how to get this to not TS error. Followed Docs word for word |
| providers: [ |
| KeycloakProvider(Object.assign(getSecrets(), { |
| issuer: "https://`login.clicks.codes/realms/master" |
| })), |
| ], |
| } |
| |
| |
| const handler = NextAuth(authOptions) |
| |
| export { handler as GET, handler as POST } |