26 lines
743 B
TypeScript
26 lines
743 B
TypeScript
import oauthPlugin, { FastifyOAuth2Options } from "@fastify/oauth2";
|
|
import { FastifyInstance } from "fastify";
|
|
|
|
export async function oauth(fastify: FastifyInstance) {
|
|
fastify.register(oauthPlugin, {
|
|
name: "microsoftOauth",
|
|
scope: ["openid", "email", "profile"],
|
|
credentials: {
|
|
client: {
|
|
id: process.env.MICROSOFT_CLIENT_ID,
|
|
secret: process.env.MICROSOFT_CLIENT_SECRET,
|
|
},
|
|
},
|
|
startRedirectPath: "/auth/microsoft",
|
|
callbackUri: process.env.MICROSOFT_REDIRECT_URI,
|
|
discovery: {
|
|
issuer:
|
|
"https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration",
|
|
},
|
|
cookie: {
|
|
secure: true,
|
|
sameSite: "none",
|
|
},
|
|
} as FastifyOAuth2Options);
|
|
}
|