Skip to content

Commit

Permalink
app-backend: disallow all iframe embedding of the app
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Dec 29, 2021
1 parent 0fdac13 commit 9d9cfc1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-chefs-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-app-backend': patch
---

Set `X-Frame-Options: deny` rather than the default `sameorigin` for all content served by the `app-backend`.`
1 change: 1 addition & 0 deletions plugins/app-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
"fs-extra": "9.1.0",
"helmet": "^4.0.0",
"winston": "^3.2.1",
"yn": "^4.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions plugins/app-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { notFoundHandler, resolvePackagePath } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import helmet from 'helmet';
import express from 'express';
import Router from 'express-promise-router';
import fs from 'fs-extra';
Expand Down Expand Up @@ -89,6 +90,8 @@ export async function createRouter(

const router = Router();

router.use(helmet.frameguard({ action: 'deny' }));

// Use a separate router for static content so that a fallback can be provided by backend
const staticRouter = Router();
staticRouter.use(express.static(resolvePath(appDistDir, 'static')));
Expand Down

0 comments on commit 9d9cfc1

Please sign in to comment.