Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Helmet content security policy #235

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const compression = require('compression');
const config = require('config');
const cors = require('cors');
const express = require('express');
const helmet = require('helmet');

const { name: appName, version: appVersion } = require('./package.json');
const { AuthMode, DEFAULTCORS } = require('./src/components/constants');
Expand Down Expand Up @@ -33,6 +34,18 @@ const app = express();
app.use(compression());
app.use(cors(DEFAULTCORS));
app.use(express.urlencoded({ extended: true }));
app.use(
helmet({
contentSecurityPolicy: {
directives: {
'default-src': [
"'self'", // eslint-disable-line
new URL(config.get('keycloak.serverUrl')).origin
]
}
}
})
);

// Skip if running tests
if (process.env.NODE_ENV !== 'test') {
Expand Down
14 changes: 14 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"express-winston": "^4.2.0",
"helmet": "^7.1.0",
"joi": "^17.11.0",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^9.0.2",
Expand Down