aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/middleware/saml.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/middleware/saml.ts')
-rw-r--r--src/routes/middleware/saml.ts13
1 files changed, 13 insertions, 0 deletions
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;