Skip to content

Commit c1a444f

Browse files
committed
fix!: Put clientAuthenticationMethod field behind opt-in
1 parent 9f06eb8 commit c1a444f

6 files changed

Lines changed: 42 additions & 14 deletions

File tree

crates/stackable-operator/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ All notable changes to this project will be documented in this file.
1313
- BREAKING: Change signature of `ContainerBuilder::add_env_vars` from `Vec<EnvVar>` to `IntoIterator<Item = EnvVar>` ([#1163]).
1414
- BREAKING: Remove `EXPERIMENTAL_` prefix in `CONFIG_OVERRIDE_FILE_HEADER_KEY` and `CONFIG_OVERRIDE_FILE_FOOTER_KEY` ([#1191]).
1515

16+
### Fixed
17+
18+
- BREAKING: In [#1178] the `clientAuthenticationMethod` was added to the `ClientAuthenticationOptions` struct,
19+
resulting it to show up in all product CRDs. even those that don't support configuring the client authentication method.
20+
With this change, operators need to opt-in to the `clientAuthenticationMethod` field by using the new
21+
`ClientAuthenticationMethodOption` struct for the generic type `ProductSpecificClientAuthenticationOptions` on
22+
`ClientAuthenticationOptions`. That way the struct definitions (as well as docs etc.) remain in stackable-operator,
23+
but operators can decide if they want to offer support for this field or not ([#XXXX]).
24+
1625
[#1163]: https://github.com/stackabletech/operator-rs/pull/1163
1726
[#1191]: https://github.com/stackabletech/operator-rs/pull/1191
27+
[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX
1828

1929
## [0.109.0] - 2026-04-07
2030

crates/stackable-operator/src/commons/random_secret_creation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum Error {
3434
///
3535
/// However, there is one special handling needed:
3636
///
37-
/// We can't mark Secrets as immutable, as this caused problems, see https://github.com/stackabletech/issues/issues/843.
37+
/// We can't mark Secrets as immutable, as this caused problems, see <https://github.com/stackabletech/issues/issues/843>.
3838
/// As Secrets have been created as immutable up to SDP release 26.3.0, we need to delete the, to be
3939
/// able to re-create them as mutable. This function detects old (immutable) Secrets and re-creates
4040
/// them as mutable. The contents of the Secret will be kept to prevent unnecessary Secret content

crates/stackable-operator/src/crd/authentication/core/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub mod versioned {
128128
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
129129
#[serde(rename_all = "camelCase")]
130130
#[schemars(description = "")]
131-
pub struct ClientAuthenticationDetails<O = ()> {
131+
pub struct ClientAuthenticationDetails<OidcProductSpecificClientAuthenticationOptions = ()> {
132132
/// Name of the [`AuthenticationClass`] used to authenticate users.
133133
///
134134
/// To get the concrete [`AuthenticationClass`], we must resolve it. This resolution can be
@@ -152,6 +152,10 @@ pub mod versioned {
152152
#[schemars(
153153
description = "This field contains OIDC-specific configuration. It is only required in case OIDC is used."
154154
)]
155-
oidc: Option<oidc::v1alpha1::ClientAuthenticationOptions<O>>,
155+
oidc: Option<
156+
oidc::v1alpha1::ClientAuthenticationOptions<
157+
OidcProductSpecificClientAuthenticationOptions,
158+
>,
159+
>,
156160
}
157161
}

crates/stackable-operator/src/crd/authentication/core/v1alpha1_impl.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ impl AuthenticationClass {
3030
}
3131
}
3232

33-
impl<O> ClientAuthenticationDetails<O> {
33+
impl<OidcProductSpecificClientAuthenticationOptions>
34+
ClientAuthenticationDetails<OidcProductSpecificClientAuthenticationOptions>
35+
{
3436
/// Resolves this specific [`AuthenticationClass`]. Usually products support
3537
/// a list of authentication classes, which individually need to be resolved.crate::client
3638
pub async fn resolve_class(
@@ -50,7 +52,9 @@ impl<O> ClientAuthenticationDetails<O> {
5052
pub fn oidc_or_error(
5153
&self,
5254
auth_class_name: &str,
53-
) -> Result<&oidc_v1alpha1::ClientAuthenticationOptions<O>> {
55+
) -> Result<
56+
&oidc_v1alpha1::ClientAuthenticationOptions<OidcProductSpecificClientAuthenticationOptions>,
57+
> {
5458
self.oidc
5559
.as_ref()
5660
.with_context(|| OidcAuthenticationDetailsNotSpecifiedSnafu {

crates/stackable-operator/src/crd/authentication/oidc/mod.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub mod versioned {
135135
Clone, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
136136
)]
137137
#[serde(rename_all = "camelCase")]
138-
pub struct ClientAuthenticationOptions<T = ()> {
138+
pub struct ClientAuthenticationOptions<ProductSpecificClientAuthenticationOptions = ()> {
139139
/// A reference to the OIDC client credentials secret. The secret contains
140140
/// the client id and secret.
141141
#[serde(rename = "clientCredentialsSecret")]
@@ -151,6 +151,20 @@ pub mod versioned {
151151
#[serde(default)]
152152
pub extra_scopes: Vec<String>,
153153

154+
/// If desired, operators can add custom fields that are only needed for this specific product.
155+
/// They need to create a struct holding them and pass that as `ProductSpecific`.
156+
///
157+
/// In case you only need the `clientAuthenticationMethod` field, you can use
158+
/// [`ClientAuthenticationMethodOption`] directly.
159+
#[serde(flatten)]
160+
pub product_specific_fields: ProductSpecificClientAuthenticationOptions,
161+
}
162+
163+
#[derive(
164+
Clone, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
165+
)]
166+
#[serde(rename_all = "camelCase")]
167+
pub struct ClientAuthenticationMethodOption {
154168
/// The OAuth2 client authentication method to use for token endpoint requests.
155169
/// Defaults to [`ClientAuthenticationMethod::ClientSecretBasic`].
156170
///
@@ -169,10 +183,5 @@ pub mod versioned {
169183
)]
170184
#[serde(default)]
171185
pub client_authentication_method: ClientAuthenticationMethod,
172-
173-
// If desired, operators can add custom fields that are only needed for this specific product.
174-
// They need to create a struct holding them and pass that as `T`.
175-
#[serde(flatten)]
176-
pub product_specific_fields: T,
177186
}
178187
}

crates/xtask/src/crd/dummy.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
22
use stackable_operator::{
33
commons::resources::{JvmHeapLimits, Resources},
44
config::fragment::Fragment,
5-
crd::git_sync::v1alpha2::GitSync,
5+
crd::{authentication, authentication::oidc, git_sync::v1alpha2::GitSync},
66
database_connections::{
77
databases::{
88
derby::DerbyConnection, mysql::MysqlConnection, postgresql::PostgresqlConnection,
@@ -66,8 +66,9 @@ pub mod versioned {
6666
pub object_overrides: ObjectOverrides,
6767

6868
// Already versioned
69-
client_authentication_details:
70-
stackable_operator::crd::authentication::core::v1alpha1::ClientAuthenticationDetails,
69+
client_authentication_details: authentication::core::v1alpha1::ClientAuthenticationDetails<
70+
oidc::v1alpha1::ClientAuthenticationMethodOption,
71+
>,
7172
}
7273

7374
#[derive(Debug, Default, PartialEq, Fragment, JsonSchema)]

0 commit comments

Comments
 (0)