Add caddy file and update docker compose. Added IMS_TOKEN validation.

This commit is contained in:
Patrick Fic
2022-05-11 16:28:47 -07:00
parent 2928b614aa
commit 789fe501db
10 changed files with 1806 additions and 1740 deletions

28
util/validateToken.ts Normal file
View File

@@ -0,0 +1,28 @@
import { Request, Response, NextFunction } from "express";
import dotenv from "dotenv";
import { resolve } from "path";
import { logger } from "../server";
dotenv.config({
path: resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`),
});
export default function ValidateImsToken(
req: Request,
res: Response,
next: NextFunction
) {
const jobid: string = (req.body.jobid || "").trim();
const IMS_TOKEN: string = (process.env.IMS_TOKEN || "").trim();
if (IMS_TOKEN === "") {
next();
} else {
if (req.headers.ims_token !== IMS_TOKEN) {
res.sendStatus(401);
} else {
next();
}
}
}