split hivectl main.rs into per-domain modules (#2509)
This commit is contained in:
parent
673aea4e50
commit
fc7720572b
16 changed files with 1922 additions and 1771 deletions
50
hivectl/src/gateway.rs
Normal file
50
hivectl/src/gateway.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//! `hivectl gateway` — htpasswd user management for the gateway's HTTP
|
||||
//! Basic auth. The daemon owns the bcrypt hash + htpasswd write (see the
|
||||
//! `Gateway*User` `HostRequest`s); hivectl resolves the password
|
||||
//! client-side and relays the request over the host admin socket.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::util::{daemon_request, resolve_password};
|
||||
|
||||
pub(crate) async fn gateway_create_user(
|
||||
socket: &Path,
|
||||
username: &str,
|
||||
password: Option<&str>,
|
||||
password_stdin: bool,
|
||||
) -> Result<()> {
|
||||
let pw = resolve_password(password, password_stdin)?.ok_or_else(|| {
|
||||
anyhow::anyhow!("a password is required — pass --password or --password-stdin")
|
||||
})?;
|
||||
daemon_request(
|
||||
socket,
|
||||
hive_host_sock::HostRequest::GatewayCreateUser {
|
||||
username: username.to_owned(),
|
||||
password: pw,
|
||||
},
|
||||
"gateway",
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn gateway_delete_user(socket: &Path, username: &str) -> Result<()> {
|
||||
daemon_request(
|
||||
socket,
|
||||
hive_host_sock::HostRequest::GatewayDeleteUser {
|
||||
username: username.to_owned(),
|
||||
},
|
||||
"gateway",
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn gateway_list_users(socket: &Path) -> Result<()> {
|
||||
daemon_request(
|
||||
socket,
|
||||
hive_host_sock::HostRequest::GatewayListUsers,
|
||||
"gateway",
|
||||
)
|
||||
.await
|
||||
}
|
||||
Loading…
Reference in a new issue