From 8894d185647ddae9032c295cd74c4b9facf3e1a5 Mon Sep 17 00:00:00 2001 From: Karming Date: Wed, 18 Sep 2024 09:08:24 -0400 Subject: [PATCH] feat: make default credentials for auth customizable The current implementation defaults to username: `admin` and password: `zwave` when enabling auth. However, it can also be beneficial to make this customizable so that it can avoid some additional steps in updating these values.This is completely backwards compatible as well. --- api/config/app.ts | 4 ++-- docs/guide/env-vars.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/config/app.ts b/api/config/app.ts index 30727220c3a..fd2951542ee 100644 --- a/api/config/app.ts +++ b/api/config/app.ts @@ -16,8 +16,8 @@ export const backupsDir: string = export const nvmBackupsDir: string = joinPath(backupsDir, 'nvm') export const storeBackupsDir: string = joinPath(backupsDir, 'store') -export const defaultUser: string = 'admin' -export const defaultPsw: string = 'zwave' +export const defaultUser: string = process.env.DEFAULT_USERNAME || 'admin' +export const defaultPsw: string = process.env.DEFAULT_PASSWORD || 'zwave' // lgtm [js/hardcoded-credentials] export const sessionSecret: string = process.env.SESSION_SECRET || 'DEFAULT_SESSION_SECRET_CHANGE_ME' diff --git a/docs/guide/env-vars.md b/docs/guide/env-vars.md index c0ff9a9fedc..e484daff16b 100644 --- a/docs/guide/env-vars.md +++ b/docs/guide/env-vars.md @@ -2,6 +2,8 @@ This is the list of the supported environment variables: +- `DEFAULT_USERNAME`: The default username when auth is enabled. +- `DEFAULT_PASSWORD`: The default password when auth is enabled. - `NETWORK_KEY`: Z-Wave S0 Network key. **Deprecated** - Network keys: - `KEY_S0_Legacy`