aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/middleware/saml.ts
blob: cce29a2e604f91c9775066ecd6312ea323d13c18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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()) {
    res.redirect(authenticator.buildLoginURL());
    return;
  }
  next();
};

export default saml;