Skip to content

Commit

Permalink
feat!: validate referer to /reauth is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
billchurch committed May 20, 2022
1 parent e0742db commit 0dcaa6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/server/routes.js
Expand Up @@ -10,11 +10,15 @@ const { parseBool } = require('./util');
const config = require('./config');

exports.reauth = function reauth(req, res) {
const r = req.headers.referer || '/';
let { referer } = req.headers;
console.log(`referer: ${referer}`);
if (!validator.isURL(referer, { host_whitelist: ['localhost'] })) referer = '/';
console.log(`referer: ${referer}`);

res
.status(401)
.send(
`<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${r}"></head><body bgcolor="#000"></body></html>`
`<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${referer}"></head><body bgcolor="#000"></body></html>`
);
};

Expand Down

0 comments on commit 0dcaa6e

Please sign in to comment.