Add session management

This commit is contained in:
2025-01-03 12:32:43 +05:30
parent 83786e2994
commit 14c9b0210c
12 changed files with 341 additions and 16 deletions

24
src/oauth.ts Normal file
View File

@@ -0,0 +1,24 @@
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: {
sameSite: "none",
},
} as FastifyOAuth2Options);
}