Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
feat: add check middleware to optionally block non-OGP user
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkhoo committed Jun 15, 2021
1 parent 95e1783 commit 46447cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions env_example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 8 additions & 0 deletions server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46447cf

Please sign in to comment.