diff options
author | Matt Strapp <matt@mattstrapp.net> | 2022-04-05 17:47:36 +0200 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2022-04-05 17:48:13 +0200 |
commit | e1b9b6f5b80530620b7df2a0bebfd8941eadad3b (patch) | |
tree | 1fd746f187a3cfb35f032f1bc47997add2e57b63 /src/routes/api.ts | |
parent | Bump prettier from 2.6.1 to 2.6.2 (#38) (diff) | |
download | ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar.gz ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar.bz2 ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar.lz ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar.xz ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.tar.zst ee4511w-web-e1b9b6f5b80530620b7df2a0bebfd8941eadad3b.zip |
Add Shibboleth login support
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r-- | src/routes/api.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/routes/api.ts b/src/routes/api.ts index 6cb804c..4b10121 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -5,6 +5,7 @@ import express, { Request, Response } from 'express'; import fileUpload, { UploadedFile } from 'express-fileupload'; import { access, stat } from 'fs/promises'; import { quote } from 'shell-quote'; +import { saml_api } from './middleware/saml.js'; /** * The endpoint for the API calls involving file uploads and running the files on the pendulum. @@ -17,6 +18,9 @@ api.use(express.json()); api.use(cookieParser()); const csrf = csurf({ cookie: true }); +// Require authentication for all API calls +api.use(saml_api); + // For file uploads api.use( fileUpload({ @@ -230,14 +234,12 @@ api */ async function verifyFile(file: string, res: Response): Promise<boolean> { // Make sure the file being requested to run exists - try { - await access(file); - } catch (err) { + await access(file).catch(() => { res .status(404) .json({ error: 'File is not accessible or does not exist.' }); return false; - } + }); // This is a try catch because otherwise type checking will fail and get all messed up // Handle your promise rejections, kids try { |