Commit 6e0f388a authored by hholder's avatar hholder

redirection after login

parent 488a3f4c
......@@ -22,6 +22,8 @@ var response = {
if (req.user) {
responseError(res, '403', 'Forbidden', 'oh no.')
} else {
if (!req.session) req.session = {}
req.session.returnTo = req.originalUrl || config.serverUrl + '/';
req.flash('error', 'You are not allowed to access this page. Maybe try logging in?')
res.redirect(config.serverURL + '/')
}
......
'use strict'
const Router = require('express').Router
const passport = require('passport')
const SamlStrategy = require('passport-saml').Strategy
......@@ -8,7 +9,6 @@ const logger = require('../../../logger')
const { urlencodedParser } = require('../../utils')
const fs = require('fs')
const intersection = function (array1, array2) { return array1.filter((n) => array2.includes(n)) }
const { setReturnToFromReferer } = require('../utils')
let samlAuth = module.exports = Router()
......@@ -18,7 +18,7 @@ passport.use(new SamlStrategy({
issuer: config.saml.issuer || config.serverURL,
cert: fs.readFileSync(config.saml.idpCert, 'utf-8'),
identifierFormat: config.saml.identifierFormat,
disableRequestedAuthnContext: config.saml.disableRequestedAuthnContext,
disableRequestedAuthnContext: config.saml.disableRequestedAuthnContext
}, function (user, done) {
// check authorization if needed
if (config.saml.externalGroups && config.saml.groupAttribute) {
......@@ -76,20 +76,18 @@ passport.use(new SamlStrategy({
})
}))
samlAuth.get('/auth/saml',function(req,res,next) {
setReturnToFromReferer(req)
samlAuth.get('/auth/saml',
passport.authenticate('saml', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
})(req,res,next)
}
})
)
samlAuth.post('/auth/saml/callback', urlencodedParser,
passport.authenticate('saml', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
}),
})
)
samlAuth.get('/auth/saml/metadata', function (req, res) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment