manager: add subcommand for managing AD realms
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> Reviewed-by: Lukas Wagner <l.wagner@proxmox.com> Tested-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
a8636bbb66
commit
1819989bd0
@ -100,3 +100,7 @@ pub fn complete_openid_realm_name(_arg: &str, _param: &HashMap<String, String>)
|
|||||||
pub fn complete_ldap_realm_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
|
pub fn complete_ldap_realm_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
|
||||||
complete_realm_of_type("ldap")
|
complete_realm_of_type("ldap")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn complete_ad_realm_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
|
||||||
|
complete_realm_of_type("ad")
|
||||||
|
}
|
||||||
|
@ -500,6 +500,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
.insert("disk", disk_commands())
|
.insert("disk", disk_commands())
|
||||||
.insert("dns", dns_commands())
|
.insert("dns", dns_commands())
|
||||||
.insert("ldap", ldap_commands())
|
.insert("ldap", ldap_commands())
|
||||||
|
.insert("ad", ad_commands())
|
||||||
.insert("network", network_commands())
|
.insert("network", network_commands())
|
||||||
.insert("node", node_commands())
|
.insert("node", node_commands())
|
||||||
.insert("notification", notification_commands())
|
.insert("notification", notification_commands())
|
||||||
|
105
src/bin/proxmox_backup_manager/ad.rs
Normal file
105
src/bin/proxmox_backup_manager/ad.rs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
use anyhow::Error;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||||
|
use proxmox_schema::api;
|
||||||
|
|
||||||
|
use pbs_api_types::REALM_ID_SCHEMA;
|
||||||
|
|
||||||
|
use crate::api2;
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
input: {
|
||||||
|
properties: {
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)]
|
||||||
|
/// List configured AD realms
|
||||||
|
fn list_ad_realms(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let info = &api2::config::access::ad::API_METHOD_LIST_AD_REALMS;
|
||||||
|
let mut data = match info.handler {
|
||||||
|
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let options = default_table_format_options()
|
||||||
|
.column(ColumnConfig::new("realm"))
|
||||||
|
.column(ColumnConfig::new("server1"))
|
||||||
|
.column(ColumnConfig::new("comment"));
|
||||||
|
|
||||||
|
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||||
|
|
||||||
|
Ok(Value::Null)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
input: {
|
||||||
|
properties: {
|
||||||
|
realm: {
|
||||||
|
schema: REALM_ID_SCHEMA,
|
||||||
|
},
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)]
|
||||||
|
/// Show AD realm configuration
|
||||||
|
pub fn show_ad_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let info = &api2::config::access::ad::API_METHOD_READ_AD_REALM;
|
||||||
|
let mut data = match info.handler {
|
||||||
|
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let options = default_table_format_options();
|
||||||
|
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||||
|
|
||||||
|
Ok(Value::Null)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ad_commands() -> CommandLineInterface {
|
||||||
|
let cmd_def = CliCommandMap::new()
|
||||||
|
.insert("list", CliCommand::new(&API_METHOD_LIST_AD_REALMS))
|
||||||
|
.insert(
|
||||||
|
"show",
|
||||||
|
CliCommand::new(&crate::API_METHOD_SHOW_AD_REALM)
|
||||||
|
.arg_param(&["realm"])
|
||||||
|
.completion_cb("realm", pbs_config::domains::complete_ad_realm_name),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"create",
|
||||||
|
CliCommand::new(&api2::config::access::ad::API_METHOD_CREATE_AD_REALM)
|
||||||
|
.arg_param(&["realm"])
|
||||||
|
.completion_cb("realm", pbs_config::domains::complete_ad_realm_name),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"update",
|
||||||
|
CliCommand::new(&api2::config::access::ad::API_METHOD_UPDATE_AD_REALM)
|
||||||
|
.arg_param(&["realm"])
|
||||||
|
.completion_cb("realm", pbs_config::domains::complete_ad_realm_name),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"delete",
|
||||||
|
CliCommand::new(&api2::config::access::ldap::API_METHOD_DELETE_LDAP_REALM)
|
||||||
|
.arg_param(&["realm"])
|
||||||
|
.completion_cb("realm", pbs_config::domains::complete_ad_realm_name),
|
||||||
|
)
|
||||||
|
.insert(
|
||||||
|
"sync",
|
||||||
|
CliCommand::new(&crate::API_METHOD_SYNC_LDAP_REALM)
|
||||||
|
.arg_param(&["realm"])
|
||||||
|
.completion_cb("realm", pbs_config::domains::complete_ad_realm_name),
|
||||||
|
);
|
||||||
|
|
||||||
|
cmd_def.into()
|
||||||
|
}
|
@ -98,7 +98,7 @@ fn show_ldap_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Sync a given LDAP realm
|
/// Sync a given LDAP realm
|
||||||
async fn sync_ldap_realm(param: Value) -> Result<Value, Error> {
|
pub async fn sync_ldap_realm(param: Value) -> Result<Value, Error> {
|
||||||
let realm = required_string_param(¶m, "realm")?;
|
let realm = required_string_param(¶m, "realm")?;
|
||||||
let client = connect_to_localhost()?;
|
let client = connect_to_localhost()?;
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ mod acl;
|
|||||||
pub use acl::*;
|
pub use acl::*;
|
||||||
mod acme;
|
mod acme;
|
||||||
pub use acme::*;
|
pub use acme::*;
|
||||||
|
mod ad;
|
||||||
|
pub use ad::*;
|
||||||
mod cert;
|
mod cert;
|
||||||
pub use cert::*;
|
pub use cert::*;
|
||||||
mod datastore;
|
mod datastore;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user