From 5717af872df070a50b9c27ccb21e2753339ae8fe Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Fri, 1 Apr 2022 17:50:13 +0200 Subject: Attempt to add basic SAML Signed-off-by: Matt Strapp --- src/routes/middleware/saml.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/routes/middleware/saml.ts (limited to 'src/routes/middleware/saml.ts') diff --git a/src/routes/middleware/saml.ts b/src/routes/middleware/saml.ts new file mode 100644 index 0000000..ad9d50d --- /dev/null +++ b/src/routes/middleware/saml.ts @@ -0,0 +1,13 @@ +import BasicAuthenticator from 'umn-shib-nodejs'; +import { Request, Response, NextFunction } from 'express'; + +const saml = function (req: Request, res: Response, next: NextFunction): void { + const authenticator = new BasicAuthenticator(req, res); + if (!authenticator.hasSession()) { + authenticator.redirectToLogin(); + next(); + } + next(); +}; + +export default saml; -- cgit v1.2.3