Skip to content

Commit 32af10b

Browse files
committed
Rename customGroupAttributeFilters to additionalGroupAttributeFilters
1 parent 3a4cc64 commit 32af10b

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

deploy/helm/opa-operator/crds/crds.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ spec:
6868
experimentalActiveDirectory:
6969
description: Backend that fetches user information from Active Directory
7070
properties:
71+
additionalGroupAttributeFilters:
72+
additionalProperties:
73+
type: string
74+
default: {}
75+
description: |-
76+
Attributes that groups must have to be returned.
77+
78+
These fields will be spliced into an LDAP Search Query, so wildcards can be used, but characters with a special meaning in LDAP will need to be escaped.
79+
type: object
7180
baseDistinguishedName:
7281
description: The root Distinguished Name (DN) where users and groups are located.
7382
type: string
@@ -77,15 +86,6 @@ spec:
7786
default: {}
7887
description: Custom attributes, and their LDAP attribute names.
7988
type: object
80-
customGroupAttributeFilters:
81-
additionalProperties:
82-
type: string
83-
default: {}
84-
description: |-
85-
Attributes that groups must have to be returned.
86-
87-
These fields will be spliced into an LDAP Search Query, so wildcards can be used, but characters with a special meaning in LDAP will need to be escaped.
88-
type: object
8989
kerberosSecretClassName:
9090
description: The name of the Kerberos SecretClass.
9191
type: string

rust/crd/src/user_info_fetcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub struct ActiveDirectoryBackend {
118118
/// These fields will be spliced into an LDAP Search Query, so wildcards can be used,
119119
/// but characters with a special meaning in LDAP will need to be escaped.
120120
#[serde(default)]
121-
pub custom_group_attribute_filters: BTreeMap<String, String>,
121+
pub additional_group_attribute_filters: BTreeMap<String, String>,
122122
}
123123

124124
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]

rust/user-info-fetcher/src/backend/active_directory.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ const LDAP_FIELD_GROUP_MEMBER: &str = "member";
9494
tls,
9595
base_distinguished_name,
9696
custom_attribute_mappings,
97-
group_attribute_filters,
97+
additional_group_attribute_filters,
9898
))]
9999
pub(crate) async fn get_user_info(
100100
request: &UserInfoRequest,
101101
ldap_server: &str,
102102
tls: &TlsClientDetails,
103103
base_distinguished_name: &str,
104104
custom_attribute_mappings: &BTreeMap<String, String>,
105-
group_attribute_filters: &BTreeMap<String, String>,
105+
additional_group_attribute_filters: &BTreeMap<String, String>,
106106
) -> Result<UserInfo, Error> {
107107
let ldap_tls = utils::tls::configure_native_tls(tls)
108108
.await
@@ -174,7 +174,7 @@ pub(crate) async fn get_user_info(
174174
base_distinguished_name,
175175
&user,
176176
custom_attribute_mappings,
177-
group_attribute_filters,
177+
additional_group_attribute_filters,
178178
)
179179
.await
180180
}
@@ -185,7 +185,7 @@ pub(crate) async fn get_user_info(
185185
base_dn,
186186
user,
187187
custom_attribute_mappings,
188-
group_attribute_filters,
188+
additional_group_attribute_filters,
189189
),
190190
fields(user.dn),
191191
)]
@@ -194,7 +194,7 @@ async fn user_attributes(
194194
base_dn: &str,
195195
user: &SearchEntry,
196196
custom_attribute_mappings: &BTreeMap<String, String>,
197-
group_attribute_filters: &BTreeMap<String, String>,
197+
additional_group_attribute_filters: &BTreeMap<String, String>,
198198
) -> Result<UserInfo, Error> {
199199
let user_sid = user
200200
.bin_attrs
@@ -259,8 +259,14 @@ async fn user_attributes(
259259
})
260260
.collect::<HashMap<_, _>>();
261261
let groups = if let Some(user_sid) = &user_sid {
262-
user_group_distinguished_names(ldap, base_dn, user, user_sid, group_attribute_filters)
263-
.await?
262+
user_group_distinguished_names(
263+
ldap,
264+
base_dn,
265+
user,
266+
user_sid,
267+
additional_group_attribute_filters,
268+
)
269+
.await?
264270
} else {
265271
tracing::debug!(user.dn, "user has no SID, cannot fetch groups...");
266272
Vec::new()
@@ -275,13 +281,13 @@ async fn user_attributes(
275281
}
276282

277283
/// Gets the distinguished names of all of `user`'s groups, both primary and secondary.
278-
#[tracing::instrument(skip(ldap, base_dn, user, user_sid, group_attribute_filters))]
284+
#[tracing::instrument(skip(ldap, base_dn, user, user_sid, additional_group_attribute_filters))]
279285
async fn user_group_distinguished_names(
280286
ldap: &mut Ldap,
281287
base_dn: &str,
282288
user: &SearchEntry,
283289
user_sid: &SecurityId,
284-
group_attribute_filters: &BTreeMap<String, String>,
290+
additional_group_attribute_filters: &BTreeMap<String, String>,
285291
) -> Result<Vec<String>, Error> {
286292
// User group memberships are tricky, because users have exactly one *primary* and any number of *secondary* groups.
287293
// Additionally groups can be members of other groups.
@@ -330,7 +336,7 @@ async fn user_group_distinguished_names(
330336

331337
// Users can also specify custom filters via `group_attribute_filters`
332338
let custom_group_filter =
333-
group_attribute_filters
339+
additional_group_attribute_filters
334340
.iter()
335341
.fold(String::new(), |mut out, (k, v)| {
336342
// NOTE: This is technically an LDAP injection vuln, but these are provided statically by the OPA administrator,

rust/user-info-fetcher/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ async fn get_user_info(
298298
&ad.tls,
299299
&ad.base_distinguished_name,
300300
&ad.custom_attribute_mappings,
301-
&ad.custom_group_attribute_filters,
301+
&ad.additional_group_attribute_filters,
302302
)
303303
.await
304304
.context(get_user_info_error::ActiveDirectorySnafu),

0 commit comments

Comments
 (0)