Skip to content

Commit

Permalink
Merge pull request #592 from companieshouse/bug/IDVA5-1710-Start-Now-…
Browse files Browse the repository at this point in the history
…CSP-Issue

Adding Account URL and oauth2 callback url
  • Loading branch information
ttingle-ch authored Jan 21, 2025
2 parents bde65ab + 937525b commit 1caed71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/middleware/content_security_policy_middleware_config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { HelmetOptions } from "helmet";
import { CDN_HOST, PIWIK_URL, PIWIK_CHS_DOMAIN, CHS_URL } from "../utils/properties";
import { CDN_HOST, PIWIK_URL, PIWIK_CHS_DOMAIN, CHS_URL, ACCOUNT_URL } from "../utils/properties";

export const prepareCSPConfig = (nonce: string) : HelmetOptions => {
const SELF = `'self'`;
const NONCE = `'nonce-${nonce}'`;
const ONE_YEAR_SECONDS = 31536000;

const OAUTH_USER_CALL_BACK = `${CHS_URL}/user/callback`;

return {
contentSecurityPolicy: {
directives: {
Expand All @@ -15,7 +17,7 @@ export const prepareCSPConfig = (nonce: string) : HelmetOptions => {
imgSrc: [CDN_HOST],
styleSrc: [NONCE, CDN_HOST],
connectSrc: [SELF, PIWIK_URL],
formAction: [SELF, PIWIK_CHS_DOMAIN, "https:"],
formAction: [SELF, PIWIK_CHS_DOMAIN, CHS_URL, ACCOUNT_URL, OAUTH_USER_CALL_BACK],
scriptSrc: [NONCE, CDN_HOST, PIWIK_URL],
objectSrc: [`'none'`]
}
Expand Down

0 comments on commit 1caed71

Please sign in to comment.