User Authentication Flow Works
This commit is contained in:
+25
-13
@@ -1,34 +1,46 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { PrismaPg } from '@prisma/adapter-pg'
|
||||
import { PrismaClient } from '../generated/prisma/client'
|
||||
|
||||
const connectionString = `${process.env.DATABASE_URL}`
|
||||
const adapter = new PrismaPg({ connectionString })
|
||||
import { PrismaPg } from "@prisma/adapter-pg";
|
||||
import { Prisma, PrismaClient } from "../generated/prisma/client";
|
||||
import * as msal from "@azure/msal-node";
|
||||
|
||||
const connectionString = `${process.env.DATABASE_URL}`;
|
||||
const adapter = new PrismaPg({ connectionString });
|
||||
|
||||
interface EnvKey {
|
||||
PORT: number;
|
||||
};
|
||||
PORT: number;
|
||||
}
|
||||
|
||||
// ENV CONSTANTS
|
||||
|
||||
export const PORT = process.env.PORT;
|
||||
|
||||
export const prisma = new PrismaClient({ adapter })
|
||||
export const prisma = new PrismaClient({ adapter });
|
||||
|
||||
export const sessionDuration = 30 * 24 * 60 * 60000;
|
||||
export const accessTokenDuration = "10min";
|
||||
export const refreshTokenDuration = "30d";
|
||||
|
||||
export const accessTokenPrivateKey = readFileSync(
|
||||
`${import.meta.dir}/../.accessToken.key`
|
||||
`${import.meta.dir}/../.accessToken.key`,
|
||||
).toString();
|
||||
export const refreshTokenPrivateKey = readFileSync(
|
||||
`${import.meta.dir}/../.refreshToken.key`
|
||||
`${import.meta.dir}/../.refreshToken.key`,
|
||||
).toString();
|
||||
export const permissionsPrivateKey = readFileSync(
|
||||
`${import.meta.dir}/../.permissions.key`
|
||||
`${import.meta.dir}/../.permissions.key`,
|
||||
);
|
||||
export const apiKeyTokenPrivateKey = readFileSync(
|
||||
`${import.meta.dir}/../.apiKeyToken.key`
|
||||
);
|
||||
`${import.meta.dir}/../.apiKeyToken.key`,
|
||||
);
|
||||
|
||||
// Microsoft Auth Constants
|
||||
const msalConfig: msal.Configuration = {
|
||||
auth: {
|
||||
clientId: process.env.MICROSOFT_CLIENT_ID!,
|
||||
authority: `https://login.microsoftonline.com/${process.env.MICROSOFT_TENANT_ID!}`,
|
||||
clientSecret: process.env.MICROSOFT_CLIENT_SECRET!,
|
||||
},
|
||||
};
|
||||
|
||||
// MSAL Client Instance
|
||||
export const msalClient = new msal.ConfidentialClientApplication(msalConfig);
|
||||
|
||||
Reference in New Issue
Block a user