Skip to content
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
3 changes: 2 additions & 1 deletion config-skel.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
},
"readonly": false,
"enable_metrics": true,
"generated_password_length": 15
"generated_password_length": 15,
"cache-control": ""
}
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ Copy `config-skel.json` to `config.json` and adjust the options (all options are
- `readonly`: true or false; if true, no write operation is allowed both for admins and non-admins (logging is still operational)
- `enable_metrics`: true or false, enables Prometheus-formatted metrics
- `generated_password_length`: default length of random generated password (default is 15)
- `cache-control`: Cache-Control header to be sent along GET/HEAD responses

## 5. Prepare the database

Expand Down
3 changes: 2 additions & 1 deletion lib/schemas/system_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
},
"readonly": { "type": "boolean" },
"enable_metrics": { "type": "boolean" },
"generated_password_length": { "type": "integer", "minimum": 10, "maximum": 50 }
"generated_password_length": { "type": "integer", "minimum": 10, "maximum": 50 },
"cache-control": { "type": "string" }
},
"required": ["jwt_duration", "listen", "log", "https", "redis", "onetimetokens", "readonly", "crypto"]
}
10 changes: 10 additions & 0 deletions passweaver-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ if (cfg?.https?.hsts) {
app.use(helmet.hsts())
}

// Set Cache-Control headers
const cacheControl = Config.get()['cache-control']
app.use((req, res, next) => {
if ((req.method === 'GET' || req.method === 'HEAD') && cacheControl) {
res.set('Cache-Control', cacheControl)
}
res.set('Vary', 'Authorization, Accept-Encoding, Accept-Language')
next()
})

if (!FS.existsSync(cfg.log.dir)) {
FS.mkdirSync(cfg.log.dir)
}
Expand Down