1
0
Fork 0

refactor(nextauth): change provider from Google to Keycloak

- using self-hosted keycloak as SSO `https://sso.mareshq.com`
This commit is contained in:
Vojtěch Mareš 2023-09-02 17:37:45 +02:00
parent 083fe4565d
commit 2a7b833b2e
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
7 changed files with 40 additions and 25 deletions

View file

@ -5,7 +5,7 @@ import {
type NextAuthOptions,
type DefaultSession,
} from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import KeycloakProvider from "next-auth/providers/keycloak";
import { env } from "~/env.mjs";
import { prisma } from "~/server/db";
@ -49,9 +49,14 @@ export const authOptions: NextAuthOptions = {
},
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
KeycloakProvider({
clientId: env.KEYCLOAK_CLIENT_ID,
clientSecret: env.KEYCLOAK_CLIENT_SECRET,
issuer: env.KEYCLOAK_ISSUER,
// authorizationUrl: env.KEYCLOAK_ISSUER + "/protocol/openid-connect/auth",
// accessTokenUrl: env.KEYCLOAK_ISSUER + "/protocol/openid-connect/token",
// profileUrl: env.KEYCLOAK_ISSUER + "/protocol/openid-connect/userinfo",
// wellKnown: env.KEYCLOAK_ISSUER + "/.well-known/openid-configuration",
}),
/**
* ...add more providers here.