refactor(gateway): fixed htpasswd path, drop htpasswdFile option
Remove the custom htpasswdFile option and bind-mount. The htpasswd file now lives at the fixed path /var/lib/hyperhive/gateway/gateway.htpasswd on the host, which is already exposed inside the container at /run/hive-state/gateway.htpasswd via the existing gateway state bind-mount — no extra bind-mount needed. A tmpfiles rule pre-creates the file so nginx can open it even before any users exist (empty file → all requests return 401, which is correct). hivectl gateway commands default --file to the standard path so `hivectl gateway create-user alice` just works without any flags.
This commit is contained in:
parent
ba1d096391
commit
167b4fa1f3
2 changed files with 39 additions and 64 deletions
|
|
@ -147,19 +147,20 @@ enum MatrixCmd {
|
|||
},
|
||||
}
|
||||
|
||||
/// Default htpasswd file path — the host-side location of the gateway's
|
||||
/// credential store, pre-created by a tmpfiles rule when
|
||||
/// `services.hyperhive.gateway.auth.enable = true`.
|
||||
const DEFAULT_HTPASSWD_FILE: &str = "/var/lib/hyperhive/gateway/gateway.htpasswd";
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum GatewayCmd {
|
||||
/// Add a new user or update the password of an existing user in an
|
||||
/// htpasswd file. The password is hashed with BCrypt (cost 12).
|
||||
/// Add a new user or update the password of an existing user in the
|
||||
/// gateway htpasswd file. The password is hashed with BCrypt (cost 12).
|
||||
///
|
||||
/// Pass `--password-stdin` when scripting or when you don't want the
|
||||
/// password visible in shell history. The file is created if it does
|
||||
/// not exist; its parent directory must already exist.
|
||||
CreateUser {
|
||||
/// Path to the htpasswd file (the value of
|
||||
/// `services.hyperhive.gateway.auth.htpasswdFile`).
|
||||
#[arg(long, short = 'f')]
|
||||
file: PathBuf,
|
||||
/// Username to add or update.
|
||||
username: String,
|
||||
/// Set the password inline. WARNING: visible in shell history and
|
||||
|
|
@ -171,20 +172,26 @@ enum GatewayCmd {
|
|||
/// stripped). Mutually exclusive with `--password`.
|
||||
#[arg(long)]
|
||||
password_stdin: bool,
|
||||
},
|
||||
/// Remove a user from an htpasswd file. Exits with an error when the
|
||||
/// user is not found so callers can detect the no-op case.
|
||||
DeleteUser {
|
||||
/// Path to the htpasswd file.
|
||||
#[arg(long, short = 'f')]
|
||||
/// Path to the htpasswd file. Defaults to the standard gateway
|
||||
/// credential store at `/var/lib/hyperhive/gateway/gateway.htpasswd`.
|
||||
#[arg(long, short = 'f', default_value = DEFAULT_HTPASSWD_FILE)]
|
||||
file: PathBuf,
|
||||
},
|
||||
/// Remove a user from the gateway htpasswd file. Exits with an error
|
||||
/// when the user is not found so callers can detect the no-op case.
|
||||
DeleteUser {
|
||||
/// Username to remove.
|
||||
username: String,
|
||||
/// Path to the htpasswd file. Defaults to the standard gateway
|
||||
/// credential store.
|
||||
#[arg(long, short = 'f', default_value = DEFAULT_HTPASSWD_FILE)]
|
||||
file: PathBuf,
|
||||
},
|
||||
/// List all usernames in an htpasswd file, one per line.
|
||||
/// List all usernames in the gateway htpasswd file, one per line.
|
||||
ListUsers {
|
||||
/// Path to the htpasswd file.
|
||||
#[arg(long, short = 'f')]
|
||||
/// Path to the htpasswd file. Defaults to the standard gateway
|
||||
/// credential store.
|
||||
#[arg(long, short = 'f', default_value = DEFAULT_HTPASSWD_FILE)]
|
||||
file: PathBuf,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue