libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit f5ec91390745e04845cd37c426cc10ed28bb8bea
parent 0a3ca564522f63b6686335cdded1f6df0c89dbfe
Author: MS <ms@taler.net>
Date:   Sat, 23 Sep 2023 08:59:25 +0200

Admin registration.

Even the first and unused password goes hashed in the
database, in order to avoid 500-like errors in case admin
tries to authenticate before having reset its password.

Diffstat:
Mbank/src/main/kotlin/tech/libeufin/bank/helpers.kt | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt b/bank/src/main/kotlin/tech/libeufin/bank/helpers.kt @@ -469,7 +469,11 @@ fun maybeCreateAdminAccount(db: Database, ctx: BankApplicationContext): Boolean Random().nextBytes(pwBuf) val adminCustomer = Customer( login = "admin", - passwordHash = Base32Crockford.encode(pwBuf), + /** + * Hashing the password helps to avoid the "password not hashed" + * error, in case the admin tries to authenticate. + */ + passwordHash = CryptoUtil.hashpw(String(pwBuf, Charsets.UTF_8)), name = "Bank administrator" ) val rowId = db.customerCreate(adminCustomer)