const express = require('express');
const initTotp = require('./totp');
const initKeys = require('./keys');
const initSessionHandlers = require('./session-handlers');
const initSsoGate = require('./sso-gate');

module.exports = function(ctx) {
  const router = express.Router();

  const { getAppSession, appSessionCache } = initSessionHandlers(ctx);

  router.use(initTotp(ctx));
  router.use(initKeys(ctx));
  router.use(initSsoGate(ctx, getAppSession, appSessionCache));

  return router;
};
