Skip to content

Commit bd701f7

Browse files
committed
Switch oidc from Option<> to an Option<enum>
1 parent 151dcc6 commit bd701f7

File tree

1 file changed

+18
-5
lines changed
  • src/commons/authentication

1 file changed

+18
-5
lines changed

src/commons/authentication/mod.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,19 @@ pub struct ClientAuthenticationDetails<O = ()> {
9999
/// is flattened into the final CRD.
100100
///
101101
/// Use [`ClientAuthenticationDetails::oidc_or_error`] to get the value or report an error to the user.
102-
oidc: Option<oidc::ClientAuthenticationOptions<O>>,
102+
///
103+
/// We are aware that this prevents users from e.g. configuring oidc and ldap clientAuthenticationOptions
104+
/// simultaneously. This might be helpful in cases of a migration of the provider of an AuthenticationClass,
105+
/// but we consider a good validation for 90% of the use-cases more important.
106+
#[serde(flatten)]
107+
client_authentication_options: Option<ClientAuthenticationOptions<O>>,
108+
}
109+
110+
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
111+
#[serde(rename_all = "camelCase")]
112+
113+
pub enum ClientAuthenticationOptions<O> {
114+
Oidc(oidc::ClientAuthenticationOptions<O>),
103115
}
104116

105117
impl<O> ClientAuthenticationDetails<O> {
@@ -120,11 +132,12 @@ impl<O> ClientAuthenticationDetails<O> {
120132
&self,
121133
auth_class_name: &str,
122134
) -> OperatorResult<&oidc::ClientAuthenticationOptions<O>> {
123-
self.oidc
124-
.as_ref()
125-
.ok_or(Error::OidcAuthenticationDetailsNotSpecified {
135+
match &self.client_authentication_options {
136+
Some(ClientAuthenticationOptions::Oidc(oidc)) => Ok(oidc),
137+
None => Err(Error::OidcAuthenticationDetailsNotSpecified {
126138
auth_class_name: auth_class_name.to_string(),
127-
})
139+
}),
140+
}
128141
}
129142
}
130143

0 commit comments

Comments
 (0)