[pbs-devel] [PATCH proxmox-backup 1/3] fix #3939: add default-realm field to node config
Matthias Heiserer
m.heiserer at proxmox.com
Wed Mar 23 14:01:09 CET 2022
This is probably not ideal, but I like it better than storing the
default value in the domains config, especially as pam and pbs
auth are hardcoded in the domains endpoint.
Signed-off-by: Matthias Heiserer <m.heiserer at proxmox.com>
---
pbs-api-types/src/lib.rs | 2 +-
src/api2/node/config.rs | 4 ++++
src/config/node.rs | 12 ++++++++++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index 421566f7..e1544d76 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -59,7 +59,7 @@ pub use userid::Userid;
pub use userid::{Realm, RealmRef};
pub use userid::{Tokenname, TokennameRef};
pub use userid::{Username, UsernameRef};
-pub use userid::{PROXMOX_GROUP_ID_SCHEMA, PROXMOX_TOKEN_ID_SCHEMA, PROXMOX_TOKEN_NAME_SCHEMA};
+pub use userid::{PROXMOX_GROUP_ID_SCHEMA, PROXMOX_TOKEN_ID_SCHEMA, PROXMOX_TOKEN_NAME_SCHEMA, PROXMOX_AUTH_REALM_SCHEMA};
#[macro_use]
mod user;
diff --git a/src/api2/node/config.rs b/src/api2/node/config.rs
index 3b267adc..068d54ca 100644
--- a/src/api2/node/config.rs
+++ b/src/api2/node/config.rs
@@ -66,6 +66,8 @@ pub enum DeletableProperty {
default_lang,
/// Delete any description
description,
+ /// Delete the default-realm property.
+ default_realm,
}
#[api(
@@ -127,6 +129,7 @@ pub fn update_node_config(
DeletableProperty::ciphers_tls_1_2 => { config.ciphers_tls_1_2 = None; },
DeletableProperty::default_lang => { config.default_lang = None; },
DeletableProperty::description => { config.description = None; },
+ DeletableProperty::default_realm => { config.default_realm = None; },
}
}
}
@@ -143,6 +146,7 @@ pub fn update_node_config(
if update.ciphers_tls_1_2.is_some() { config.ciphers_tls_1_2 = update.ciphers_tls_1_2; }
if update.default_lang.is_some() { config.default_lang = update.default_lang; }
if update.description.is_some() { config.description = update.description; }
+ if update.default_realm.is_some() { config.default_realm = update.default_realm; }
crate::config::node::save_config(&config)?;
diff --git a/src/config/node.rs b/src/config/node.rs
index ac6774e3..c6f2e50d 100644
--- a/src/config/node.rs
+++ b/src/config/node.rs
@@ -10,7 +10,7 @@ use proxmox_http::ProxyConfig;
use pbs_api_types::{
EMAIL_SCHEMA, MULTI_LINE_COMMENT_SCHEMA, OPENSSL_CIPHERS_TLS_1_2_SCHEMA,
- OPENSSL_CIPHERS_TLS_1_3_SCHEMA,
+ OPENSSL_CIPHERS_TLS_1_3_SCHEMA, PROXMOX_AUTH_REALM_SCHEMA
};
use pbs_buildcfg::configdir;
@@ -175,7 +175,11 @@ pub enum Translation {
"description" : {
optional: true,
schema: MULTI_LINE_COMMENT_SCHEMA,
- }
+ },
+ "default-realm": {
+ schema: PROXMOX_AUTH_REALM_SCHEMA,
+ optional: true,
+ },
},
)]
#[derive(Deserialize, Serialize, Updater)]
@@ -222,6 +226,10 @@ pub struct NodeConfig {
/// Node description
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
+
+ /// Default realm for authenticating
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub default_realm: Option<String>,
}
impl NodeConfig {
--
2.30.2
More information about the pbs-devel
mailing list