Skip to content

Commit 944d47e

Browse files
authored
Merge pull request #1704 from companieshouse/asm-472-stop-healthcheck-session
ASM-472 Exclude specific paths from session and CSRF middleware calls
2 parents ee187d0 + 90ea2bd commit 944d47e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ const cookieConfig = {
9393
cookieTimeToLiveInSeconds: parseInt(config.DEFAULT_SESSION_EXPIRATION, 10)
9494
};
9595
const sessionStore = new SessionStore(new Redis(`redis://${config.CACHE_SERVER}`));
96-
app.use(SessionMiddleware(cookieConfig, sessionStore));
96+
97+
app.use(config.EXCLUDED_PATHS, SessionMiddleware(cookieConfig, sessionStore));
9798

9899
const csrfProtectionMiddleware = CsrfProtectionMiddleware({
99100
sessionStore,
100101
enabled: true,
101102
sessionCookieName: config.COOKIE_NAME
102103
});
103-
app.use(csrfProtectionMiddleware);
104+
app.use(config.EXCLUDED_PATHS, csrfProtectionMiddleware);
104105

105106
app.set("views", path.join(__dirname, "views"));
106107
app.set("view engine", "html");

src/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export const CLOSED_PENDING_PAYMENT = "closed pending payment";
4444
export const PAYMENTS = "/payments";
4545
export const YOUR_FILINGS_PATH = "/user/transactions";
4646

47+
export const EXCLUDED_PATHS = /\/register-an-overseas-entity\/((?!healthcheck).)*/;
48+
4749
// FEATURE FLAGS
4850
export const SHOW_SERVICE_OFFLINE_PAGE = getEnvironmentValue("SHOW_SERVICE_OFFLINE_PAGE");
4951
export const FEATURE_FLAG_ENABLE_TRUSTS_WEB = getEnvironmentValue('FEATURE_FLAG_ENABLE_TRUSTS_WEB_07112022', 'false');

0 commit comments

Comments
 (0)