From 480f8a23751b700c4208e1927e56a913c9079edd Mon Sep 17 00:00:00 2001 From: Grant Date: Wed, 13 Mar 2024 13:21:29 -0600 Subject: [PATCH] move auth to env --- packages/server/src/api.ts | 4 +--- packages/server/src/index.ts | 15 +++++++++++++++ packages/server/src/types.ts | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api.ts b/packages/server/src/api.ts index 25a795f..2aae3ac 100644 --- a/packages/server/src/api.ts +++ b/packages/server/src/api.ts @@ -3,9 +3,7 @@ import { prisma } from "./lib/prisma"; const app = Router(); -const AUTH_ENDPOINT = "https://auth.fediverse.events"; -const AUTH_CLIENT = "canvas"; -const AUTH_SECRET = "secret"; +const { AUTH_ENDPOINT, AUTH_CLIENT, AUTH_SECRET } = process.env; app.get("/me", (req, res) => { res.json(req.session); diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 3b75050..b3efaf8 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -36,6 +36,21 @@ if (!process.env.REDIS_SESSION_PREFIX) { ); } +if (!process.env.AUTH_ENDPOINT) { + Logger.error("AUTH_ENDPOINT is not defined"); + process.exit(1); +} + +if (!process.env.AUTH_CLIENT) { + Logger.error("AUTH_CLIENT is not defined"); + process.exit(1); +} + +if (!process.env.AUTH_SECRET) { + Logger.error("AUTH_SECRET is not defined"); + process.exit(1); +} + Redis.connect(); const express = new ExpressServer(); diff --git a/packages/server/src/types.ts b/packages/server/src/types.ts index 5911e63..de76328 100644 --- a/packages/server/src/types.ts +++ b/packages/server/src/types.ts @@ -40,6 +40,10 @@ declare global { * If set, use this relative path to serve the admin UI at /admin */ SERVE_ADMIN?: string; + + AUTH_ENDPOINT: string; + AUTH_CLIENT: string; + AUTH_SECRET: string; } } }