Added script to generate password hashes.
This commit is contained in:
parent
62df108999
commit
bc304d9bfa
|
@ -122,7 +122,7 @@ Dann die `config.json` anpassen nach belieben. Es gibt die folgenden Konfigurati
|
||||||
* **`server.internal.active`** Gibt an, ob interne URLs, wie Admin-Panel und Logging-Interface, erreichbar sein sollen,
|
* **`server.internal.active`** Gibt an, ob interne URLs, wie Admin-Panel und Logging-Interface, erreichbar sein sollen,
|
||||||
z. B.: `true`
|
z. B.: `true`
|
||||||
* **`server.internal.users`** Liste an Nutzer*innen im folgenden Format. Der Passwort-Hash kann mit dem Befehl
|
* **`server.internal.users`** Liste an Nutzer*innen im folgenden Format. Der Passwort-Hash kann mit dem Befehl
|
||||||
`mkpasswd -m bcrypt` generiert werden.
|
`mkpasswd -m bcrypt -R 10` oder dem beiliegenden Skript `bin/mkpasswd.sh` generiert werden.
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
|
|
24
bin/bcrypt.js
Executable file
24
bin/bcrypt.js
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const bcrypt = require('bcrypt');
|
||||||
|
const saltRounds = 10;
|
||||||
|
|
||||||
|
const stdout = process.stdout
|
||||||
|
const stdin = process.stdin
|
||||||
|
|
||||||
|
let password = '';
|
||||||
|
|
||||||
|
stdin.on('readable', () => {
|
||||||
|
let chunk;
|
||||||
|
while ((chunk = stdin.read()) !== null) {
|
||||||
|
password += chunk;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stdin.on('end', () => {
|
||||||
|
if (password[password.length - 1] === '\n') {
|
||||||
|
password = password.substring(0, password.length - 1);
|
||||||
|
}
|
||||||
|
const hash = bcrypt.hashSync(password, saltRounds);
|
||||||
|
stdout.write(`${hash}\n`);
|
||||||
|
});
|
23
bin/mkpasswd.sh
Executable file
23
bin/mkpasswd.sh
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
read -sp "Password: " password
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -sp "Confirm: " confirmation
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [[ "$password" == "$confirmation" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Passwords do not match, try again."
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
||||||
|
exec node ./bcrypt.js <<<"$password"
|
Loading…
Reference in a new issue