RemoteWithoutPassword: new API type
To make it explicit that we do not return the password. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
988d575dbb
commit
24cb5c7a81
|
@ -85,3 +85,22 @@ pub struct Remote {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub config: RemoteConfig,
|
pub config: RemoteConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
schema: REMOTE_ID_SCHEMA,
|
||||||
|
},
|
||||||
|
config: {
|
||||||
|
type: RemoteConfig,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)]
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
/// Remote properties.
|
||||||
|
pub struct RemoteWithoutPassword {
|
||||||
|
pub name: String,
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub config: RemoteConfig,
|
||||||
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ use proxmox_schema::{api, param_bail};
|
||||||
|
|
||||||
use pbs_api_types::{
|
use pbs_api_types::{
|
||||||
Authid, DataStoreListItem, GroupListItem, RateLimitConfig, Remote, RemoteConfig,
|
Authid, DataStoreListItem, GroupListItem, RateLimitConfig, Remote, RemoteConfig,
|
||||||
RemoteConfigUpdater, SyncJobConfig, DATASTORE_SCHEMA, PRIV_REMOTE_AUDIT, PRIV_REMOTE_MODIFY,
|
RemoteConfigUpdater, RemoteWithoutPassword, SyncJobConfig, DATASTORE_SCHEMA, PRIV_REMOTE_AUDIT,
|
||||||
PROXMOX_CONFIG_DIGEST_SCHEMA, REMOTE_ID_SCHEMA, REMOTE_PASSWORD_SCHEMA,
|
PRIV_REMOTE_MODIFY, PROXMOX_CONFIG_DIGEST_SCHEMA, REMOTE_ID_SCHEMA, REMOTE_PASSWORD_SCHEMA,
|
||||||
};
|
};
|
||||||
use pbs_client::{HttpClient, HttpClientOptions};
|
use pbs_client::{HttpClient, HttpClientOptions};
|
||||||
use pbs_config::sync;
|
use pbs_config::sync;
|
||||||
|
@ -26,7 +26,7 @@ use pbs_config::CachedUserInfo;
|
||||||
returns: {
|
returns: {
|
||||||
description: "The list of configured remotes (with config digest).",
|
description: "The list of configured remotes (with config digest).",
|
||||||
type: Array,
|
type: Array,
|
||||||
items: { type: Remote },
|
items: { type: RemoteWithoutPassword },
|
||||||
},
|
},
|
||||||
access: {
|
access: {
|
||||||
description: "List configured remotes filtered by Remote.Audit privileges",
|
description: "List configured remotes filtered by Remote.Audit privileges",
|
||||||
|
@ -38,17 +38,14 @@ pub fn list_remotes(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
mut rpcenv: &mut dyn RpcEnvironment,
|
mut rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Vec<Remote>, Error> {
|
) -> Result<Vec<RemoteWithoutPassword>, Error> {
|
||||||
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
|
||||||
let user_info = CachedUserInfo::new()?;
|
let user_info = CachedUserInfo::new()?;
|
||||||
|
|
||||||
let (config, digest) = pbs_config::remote::config()?;
|
let (config, digest) = pbs_config::remote::config()?;
|
||||||
|
|
||||||
let mut list: Vec<Remote> = config.convert_to_typed_array("remote")?;
|
// Note: This removes the password (we do not want to return the password).
|
||||||
// don't return password in api
|
let list: Vec<RemoteWithoutPassword> = config.convert_to_typed_array("remote")?;
|
||||||
for remote in &mut list {
|
|
||||||
remote.password = "".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
let list = list
|
let list = list
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
Loading…
Reference in New Issue