diff --git a/env_example b/env_example index b91a27fcf..30486e736 100644 --- a/env_example +++ b/env_example @@ -7,3 +7,4 @@ export LOGGING_URL="http://localhost:4000/secret_datasets" export COOKIE_SECRET="blahblahblah" export COOKIE_DOMAIN="localhost" export REDIS_SESSION_URL="redis://localhost:6379" +export BLOCK_NON_OGP="true" \ No newline at end of file diff --git a/server/routes/index.js b/server/routes/index.js index c062dc8b2..a745eb0ce 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -137,6 +137,14 @@ module.exports = function(app) { const sessionIsValid = (req, res, next) => { if (req.session.email) { + // Check if blocker is enabled, if so redirect non-OGP users away from Send + if ( + process.env.BLOCK_NON_OGP === 'true' && + req.session.email.includes('@open.gov.sg') === false + ) { + return res.redirect(config.LOGIN_URL); + } + return next(); } else { // The Regex below removes '/download/' from the '/download/download_id/' URL