Permalink
Browse files

closes #6553

  • Loading branch information...
julianlam committed Jun 5, 2018
1 parent f3c8074 commit ec91ef1c644044bba44198b031913655e784b4bb
Showing with 11 additions and 4 deletions.
  1. +11 −4 src/routes/authentication.js
@@ -60,13 +60,20 @@ Auth.reloadRoutes = function (callback) {
function (loginStrategies, next) {
loginStrategies.forEach(function (strategy) {
if (strategy.url) {
router.get(strategy.url, passport.authenticate(strategy.name, {
scope: strategy.scope,
prompt: strategy.prompt || undefined,
}));
router.get(strategy.url, Auth.middleware.applyCSRF, function (req, res, next) {
req.session.ssoState = req.csrfToken();
passport.authenticate(strategy.name, {
scope: strategy.scope,
prompt: strategy.prompt || undefined,
state: req.session.ssoState,
})(req, res, next);
});
}
router.get(strategy.callbackURL, function (req, res, next) {
// Ensure the passed-back state value is identical to the saved ssoState
next(req.query.state !== req.session.ssoState ? new Error('[[error:csrf-invalid]]') : null);
}, function (req, res, next) {
// Trigger registration interstitial checks
req.session.registration = req.session.registration || {};
next();

0 comments on commit ec91ef1

Please sign in to comment.