Skip to content

Commit 8a4b340

Browse files
author
Vladislav Supalov
committed
wip: throwaway code
1 parent cac2028 commit 8a4b340

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

deploy/crd/druidcluster.crd.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,14 @@ spec:
361361
description: Authentication class settings for Druid like TLS authentication or LDAP
362362
nullable: true
363363
properties:
364+
ldap:
365+
nullable: true
366+
properties:
367+
authenticationClass:
368+
type: string
369+
required:
370+
- authenticationClass
371+
type: object
364372
tls:
365373
description: TLS based client authentication (mutual TLS)
366374
nullable: true

rust/crd/src/authentication.rs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::DruidCluster;
22

3+
34
use serde::{Deserialize, Serialize};
45
use snafu::{ResultExt, Snafu};
56
use stackable_operator::{
@@ -11,6 +12,7 @@ use stackable_operator::{
1112
kube::runtime::reflector::ObjectRef,
1213
schemars::{self, JsonSchema},
1314
};
15+
1416
use strum::{EnumDiscriminants, IntoStaticStr};
1517

1618
#[derive(Snafu, Debug, EnumDiscriminants)]
@@ -87,6 +89,38 @@ impl DruidAuthentication {
8789
}
8890
}
8991

92+
if let Some(DruidAuthentication {
93+
tls: _,
94+
ldap: Some(druid_ldap),
95+
}) = &druid.spec.cluster_config.authentication
96+
{
97+
let authentication_class =
98+
AuthenticationClass::resolve(client, &druid_ldap.authentication_class)
99+
.await
100+
.context(AuthenticationClassRetrievalSnafu {
101+
authentication_class: ObjectRef::<AuthenticationClass>::new(
102+
&druid_ldap.authentication_class,
103+
),
104+
})?;
105+
106+
match authentication_class.spec.provider {
107+
AuthenticationClassProvider::Ldap(tls_provider) => {
108+
druid_authentication_config.push(DruidAuthenticationConfig::Ldap(tls_provider));
109+
}
110+
_ => {
111+
return Err(Error::AuthenticationClassProviderNotSupported {
112+
authentication_class_provider: authentication_class
113+
.spec
114+
.provider
115+
.to_string(),
116+
authentication_class: ObjectRef::<AuthenticationClass>::new(
117+
&druid_ldap.authentication_class,
118+
),
119+
})
120+
}
121+
}
122+
}
123+
90124
Ok(druid_authentication_config)
91125
}
92126
}
@@ -101,4 +135,35 @@ impl DruidAuthenticationConfig {
101135
pub fn is_tls_auth(&self) -> bool {
102136
matches!(self, DruidAuthenticationConfig::Tls(_))
103137
}
104-
}
138+
}
139+
140+
/*
141+
#[cfg(test)]
142+
mod tests {
143+
use super::*;
144+
145+
#[test]
146+
fn test_process_ldap_authentication() {
147+
let result = DruidAuthentication::resolve()
148+
// TODO: replace client with mockable interface
149+
// TODO: pass LDAPy config
150+
// TODO: expect no error (the current code provides this)
151+
152+
let cluster: DruidCluster = serde_yaml::from_reader(&cluster_cr).unwrap();
153+
154+
155+
156+
assert_eq!(cluster.metadata.name, Some("testcluster".to_string()));
157+
158+
assert_eq!(
159+
cluster.role_service_name(&DruidRole::Router),
160+
Some("testcluster-router".to_string())
161+
);
162+
163+
assert_eq!(
164+
cluster.role_service_fqdn(&DruidRole::Router),
165+
Some("testcluster-router.default.svc.cluster.local".to_string())
166+
)
167+
}
168+
}
169+
*/

0 commit comments

Comments
 (0)