Skip to content

Commit 84fac41

Browse files
committed
fix: Add OIDC clientAuthenticationMethod support for Druid
1 parent a4577df commit 84fac41

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

crate-hashes.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/authentication/oidc.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ fn add_authenticator_config(
6363
"druid.auth.pac4j.oidc.scope".to_string(),
6464
Some(scopes.join(" ")),
6565
);
66+
67+
// Serialize the enum to get the snake_case string representation
68+
let method_string =
69+
serde_json::to_value(oidc.client_authentication_method).expect("serializing ClientAuthenticationMethod to string");
70+
let method_string = method_string
71+
.as_str()
72+
.expect("ClientAuthenticationMethod should serialize to a string");
73+
config.insert(
74+
"druid.auth.pac4j.oidc.clientAuthenticationMethod".to_string(),
75+
Some(method_string.to_string()),
76+
);
77+
6678
config.insert(
6779
"druid.auth.authenticatorChain".to_string(),
6880
Some(r#"["DruidSystemAuthenticator", "Oidc"]"#.to_string()),
@@ -184,11 +196,12 @@ mod tests {
184196
},
185197
"preferred_username".to_owned(),
186198
vec!["openid".to_owned()],
187-
None,
199+
Some(oidc::v1alpha1::IdentityProviderHint::Keycloak),
188200
);
189201
let oidc = oidc::v1alpha1::ClientAuthenticationOptions {
190202
client_credentials_secret_ref: "nifi-keycloak-client".to_owned(),
191203
extra_scopes: vec![],
204+
client_authentication_method: oidc::v1alpha1::ClientAuthenticationMethod::ClientSecretPost,
192205
product_specific_fields: (),
193206
};
194207

@@ -223,6 +236,10 @@ mod tests {
223236
))
224237
);
225238

239+
assert_eq!(
240+
properties.get("druid.auth.pac4j.oidc.clientAuthenticationMethod"),
241+
Some(&Some("client_secret_post".to_owned()))
242+
);
226243
assert!(properties.contains_key("druid.auth.pac4j.oidc.clientID"));
227244
assert!(properties.contains_key("druid.auth.pac4j.oidc.clientSecret"));
228245
assert!(properties.contains_key("druid.auth.pac4j.cookiePassphrase"));

rust/operator-binary/src/crd/authentication.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,12 @@ zookeeperConfigMapName: zk-config-map
701701
.cloned()
702702
.ok_or_else(|| stackable_operator::client::Error::ListResources {
703703
source: kube::Error::Api(Box::new(kube::core::Status {
704-
status: None,
705704
code: 404,
706-
message: "AuthenticationClass not found".to_owned(),
707-
metadata: None,
708-
reason: "NotFound".to_owned(),
705+
message: "AuthenticationClass not found".into(),
706+
reason: "NotFound".into(),
707+
status: Some(kube::core::response::StatusSummary::Failure),
709708
details: None,
709+
metadata: Default::default(),
710710
})),
711711
})
712712
})

rust/operator-binary/src/extensions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ mod tests {
119119
oidc: oidc::v1alpha1::ClientAuthenticationOptions {
120120
client_credentials_secret_ref: "".to_string(),
121121
extra_scopes: vec![],
122-
product_specific_fields: (),
122+
client_authentication_method: Default::default(),
123+
product_specific_fields: ()
123124
}
124125
}]
125126
})

0 commit comments

Comments
 (0)