Add clickjacking prevention middleware (#68)

Fix https://github.com/matrix-org/matrix-public-archive/issues/67
This commit is contained in:
Eric Eastwood 2022-09-08 19:30:20 -05:00 committed by GitHub
parent 32c77ecffe
commit b7597b2749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -6,9 +6,11 @@ const asyncHandler = require('../lib/express-async-handler');
const { handleTracingMiddleware } = require('../tracing/tracing-middleware');
const getVersionTags = require('../lib/get-version-tags');
const preventClickjackingMiddleware = require('./prevent-clickjacking-middleware');
function installRoutes(app) {
app.use(handleTracingMiddleware);
app.use(preventClickjackingMiddleware);
let healthCheckResponse;
app.get(

View File

@ -0,0 +1,10 @@
'use strict';
// Don't allow others to iframe embed which can lead to clickjacking
function preventClickjackingMiddleware(req, res, next) {
res.set('X-Frame-Options', 'DENY');
next();
}
module.exports = preventClickjackingMiddleware;