fix #5379: pbs-api-types: add default field for all realm types

The field indicates whether the realm should be the default realm to
select in the login dialog.

Per definition, the field should only ever be set to `true` on exactly
one realm - up to the consumer/storage to ensure that.

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>
 [TL: adapt doc-comment for new default field like Shannon pointed out
  but with a slightly different text than she proposed and change
  regular comment to doc-comment.]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Christoph Heiss 2025-03-21 14:45:31 +01:00 committed by Thomas Lamprecht
parent 8468dd18d2
commit b143160c12
4 changed files with 28 additions and 0 deletions

View File

@ -16,6 +16,10 @@ use super::{
optional: true, optional: true,
schema: SINGLE_LINE_COMMENT_SCHEMA, schema: SINGLE_LINE_COMMENT_SCHEMA,
}, },
"default": {
optional: true,
default: false,
},
"verify": { "verify": {
optional: true, optional: true,
default: false, default: false,
@ -64,6 +68,9 @@ pub struct AdRealmConfig {
/// Comment /// Comment
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>, pub comment: Option<String>,
/// True if you want this to be the default realm selected on login.
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<bool>,
/// Connection security /// Connection security
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mode: Option<LdapMode>, pub mode: Option<LdapMode>,

View File

@ -29,6 +29,10 @@ pub enum LdapMode {
optional: true, optional: true,
schema: SINGLE_LINE_COMMENT_SCHEMA, schema: SINGLE_LINE_COMMENT_SCHEMA,
}, },
"default": {
optional: true,
default: false,
},
"verify": { "verify": {
optional: true, optional: true,
default: false, default: false,
@ -75,6 +79,9 @@ pub struct LdapRealmConfig {
/// Comment /// Comment
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>, pub comment: Option<String>,
/// True if you want this to be the default realm selected on login.
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<bool>,
/// Connection security /// Connection security
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mode: Option<LdapMode>, pub mode: Option<LdapMode>,

View File

@ -356,18 +356,25 @@ serde_plain::derive_fromstr_from_deserialize!(RealmType);
optional: true, optional: true,
schema: SINGLE_LINE_COMMENT_SCHEMA, schema: SINGLE_LINE_COMMENT_SCHEMA,
}, },
"default": {
optional: true,
default: false,
},
}, },
)] )]
#[derive(Deserialize, Serialize, Clone, PartialEq)] #[derive(Deserialize, Serialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Basic Information about a realm /// Basic Information about a realm
pub struct BasicRealmInfo { pub struct BasicRealmInfo {
/// Realm name
pub realm: String, pub realm: String,
/// Realm type
#[serde(rename = "type")] #[serde(rename = "type")]
pub ty: RealmType, pub ty: RealmType,
/// True if it is the default realm /// True if it is the default realm
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<bool>, pub default: Option<bool>,
/// Optional comment for this realm
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>, pub comment: Option<String>,
} }

View File

@ -80,6 +80,10 @@ pub const OPENID_USERNAME_CLAIM_SCHEMA: Schema = StringSchema::new(
optional: true, optional: true,
schema: SINGLE_LINE_COMMENT_SCHEMA, schema: SINGLE_LINE_COMMENT_SCHEMA,
}, },
"default": {
optional: true,
default: false,
},
autocreate: { autocreate: {
optional: true, optional: true,
default: false, default: false,
@ -111,6 +115,9 @@ pub struct OpenIdRealmConfig {
pub client_key: Option<String>, pub client_key: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>, pub comment: Option<String>,
/// True if you want this to be the default realm selected on login.
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<bool>,
/// Automatically create users if they do not exist. /// Automatically create users if they do not exist.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub autocreate: Option<bool>, pub autocreate: Option<bool>,