Skip to content

Commit f687344

Browse files
authored
Add configuration for generated password length (#328)
Fixes #323
1 parent 726ff39 commit f687344

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

api/v1/controllers/util.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import DB from '../../../lib/db.mjs'
2525
*/
2626
export async function generatePassword (req, res, next) {
2727
const pwd = generator.generate({
28-
length: 15,
28+
length: Config.get().generated_password_length || 20,
2929
numbers: true,
3030
symbols: req?.query?.symbols !== 'false',
3131
lowercase: true,

config-skel.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
"max_hours": 168
3636
},
3737
"readonly": false,
38-
"enable_metrics": true
38+
"enable_metrics": true,
39+
"generated_password_length": 20
3940
}

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ Copy `config-skel.json` to `config.json` and adjust the options:
411411
- `max_hours`: Max one-time secrets duration
412412
- `readonly`: true or false; if true, no write operation is allowed both for admins and regolar users
413413
- `enable_metrics`: true or false, enables Prometheus formatted metrics
414+
- `generated_password_length`: length of random generated password, default is 20
414415

415416
## Environment variables
416417

lib/schemas/system_config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"required": [ "max_hours" ]
6969
},
7070
"readonly": { "type": "boolean" },
71-
"enable_metrics": { "type": "boolean" }
71+
"enable_metrics": { "type": "boolean" },
72+
"generated_password_length": { "type": "integer", "minimum": 10, "maximum": 50 }
7273
},
7374
"required": ["jwt_duration", "listen", "log", "https", "redis", "onetimetokens", "readonly"]
7475
}

0 commit comments

Comments
 (0)