Fix wrong maxAgeSeconds multiplication

It seems like the inital work on the hsts module expected milliseconds.
This has either changed or was never true. Either way, it caused that
the current defaults resulted in theory in a 1000 year HSTS policy.
Luckily helmet was smart enough to not go higher than 1 year.

Anyway, this patch fixes the multiplication of the configured size with
1000 by removing this multiplication.

Also to simplify the reading of the defaults, we split them into their
components, 60 times 60 seconds so we get one hour. 24 of those hours so
we get a day and finally 365 days to get our original wanted default of
one year.

Reference:
d69d65ea74
Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
Sheogorath 2018-11-19 22:01:43 +01:00
parent 271dff3808
commit 0aa3116805
No known key found for this signature in database
GPG Key ID: 1F05CC3635CDDFFD
2 changed files with 2 additions and 2 deletions

2
app.js
View File

@ -83,7 +83,7 @@ app.use(compression())
// use hsts to tell https users stick to this // use hsts to tell https users stick to this
if (config.hsts.enable) { if (config.hsts.enable) {
app.use(helmet.hsts({ app.use(helmet.hsts({
maxAge: config.hsts.maxAgeSeconds * 1000, maxAge: config.hsts.maxAgeSeconds,
includeSubdomains: config.hsts.includeSubdomains, includeSubdomains: config.hsts.includeSubdomains,
preload: config.hsts.preload preload: config.hsts.preload
})) }))

View File

@ -13,7 +13,7 @@ module.exports = {
useSSL: false, useSSL: false,
hsts: { hsts: {
enable: true, enable: true,
maxAgeSeconds: 31536000, maxAgeSeconds: 60 * 60 * 24 * 365,
includeSubdomains: true, includeSubdomains: true,
preload: true preload: true
}, },