Skip to content

Commit e98154e

Browse files
authored
chore!: Put clientAuthenticationMethod field behind opt-in (#1194)
* fix!: Put clientAuthenticationMethod field behind opt-in * changelog * changelog * Shorten generic name to OidcProductSpecificOptions
1 parent 8904f2a commit e98154e

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@ All notable changes to this project will be documented in this file.
1414

1515
- BREAKING: Change signature of `ContainerBuilder::add_env_vars` from `Vec<EnvVar>` to `IntoIterator<Item = EnvVar>` ([#1163]).
1616
- BREAKING: Remove `EXPERIMENTAL_` prefix in `CONFIG_OVERRIDE_FILE_HEADER_KEY` and `CONFIG_OVERRIDE_FILE_FOOTER_KEY` ([#1191]).
17-
- BREAKING: Bump `kube` from a custom version (`fe69cc486ff8e62a7da61d64ec3ebbd9e64c43b5`, which is between `3.0.1` and `3.1.0` and was needed to pull in schema fixes) to `3.1.0`. This means that the CRD schema generation bugs [#1934](https://github.com/kube-rs/kube/pull/1934) and [#1942](https://github.com/kube-rs/kube/pull/1942) are fixed ([#1192]).
17+
- BREAKING: Bump `kube` from a custom version (`fe69cc486ff8e62a7da61d64ec3ebbd9e64c43b5`, which is between `3.0.1` and `3.1.0`
18+
and was needed to pull in schema fixes) to `3.1.0`. This means that the CRD schema generation bugs
19+
[#1934](https://github.com/kube-rs/kube/pull/1934) and [#1942](https://github.com/kube-rs/kube/pull/1942) are fixed ([#1192]).
1820
- BREAKING: Add `ConfigOverrides` type parameter to `CommonConfiguration`, `Role` and `RoleGroup`.
1921
The `config_overrides` field is now generic instead of `HashMap<String, HashMap<String, String>>` ([#1177]).
22+
- BREAKING: In [#1178] the `clientAuthenticationMethod` was added to the `ClientAuthenticationOptions` struct,
23+
resulting it to show up in all product CRDs. even those that don't support configuring the client authentication method.
24+
With this change, operators need to opt-in to the `clientAuthenticationMethod` field by using the new
25+
`ClientAuthenticationMethodOption` struct for the generic type `ProductSpecificClientAuthenticationOptions` on
26+
`ClientAuthenticationOptions`. That way the struct definitions (as well as docs etc.) remain in stackable-operator,
27+
but operators can decide if they want to offer support for this field or not ([#1194]).
2028

2129
[#1163]: https://github.com/stackabletech/operator-rs/pull/1163
2230
[#1177]: https://github.com/stackabletech/operator-rs/pull/1177
2331
[#1191]: https://github.com/stackabletech/operator-rs/pull/1191
2432
[#1192]: https://github.com/stackabletech/operator-rs/pull/1192
33+
[#1194]: https://github.com/stackabletech/operator-rs/pull/1194
2534

2635
## [0.109.0] - 2026-04-07
2736

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: 2 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<OidcProductSpecificOptions = ()> {
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,6 @@ 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<oidc::v1alpha1::ClientAuthenticationOptions<OidcProductSpecificOptions>>,
156156
}
157157
}

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

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

33-
impl<O> ClientAuthenticationDetails<O> {
33+
impl<OidcProductSpecificOptions> ClientAuthenticationDetails<OidcProductSpecificOptions> {
3434
/// Resolves this specific [`AuthenticationClass`]. Usually products support
3535
/// a list of authentication classes, which individually need to be resolved.crate::client
3636
pub async fn resolve_class(
@@ -50,7 +50,7 @@ impl<O> ClientAuthenticationDetails<O> {
5050
pub fn oidc_or_error(
5151
&self,
5252
auth_class_name: &str,
53-
) -> Result<&oidc_v1alpha1::ClientAuthenticationOptions<O>> {
53+
) -> Result<&oidc_v1alpha1::ClientAuthenticationOptions<OidcProductSpecificOptions>> {
5454
self.oidc
5555
.as_ref()
5656
.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
@@ -5,7 +5,7 @@ use stackable_operator::{
55
commons::resources::{JvmHeapLimits, Resources},
66
config::fragment::Fragment,
77
config_overrides::{JsonConfigOverrides, KeyValueConfigOverrides, KeyValueOverridesProvider},
8-
crd::git_sync::v1alpha2::GitSync,
8+
crd::{authentication, authentication::oidc, git_sync::v1alpha2::GitSync},
99
database_connections::{
1010
databases::{
1111
derby::DerbyConnection, mysql::MysqlConnection, postgresql::PostgresqlConnection,
@@ -107,8 +107,9 @@ pub mod versioned {
107107
pub object_overrides: ObjectOverrides,
108108

109109
// Already versioned
110-
client_authentication_details:
111-
stackable_operator::crd::authentication::core::v1alpha1::ClientAuthenticationDetails,
110+
client_authentication_details: authentication::core::v1alpha1::ClientAuthenticationDetails<
111+
oidc::v1alpha1::ClientAuthenticationMethodOption,
112+
>,
112113
}
113114

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

0 commit comments

Comments
 (0)