Add session management
This commit is contained in:
24
src/oauth.ts
Normal file
24
src/oauth.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user