Skip to content

Commit 242228c

Browse files
authored
LDAP case insensitive (#2195)
1 parent 4a5614b commit 242228c

24 files changed

Lines changed: 602 additions & 482 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ COPY Cargo.toml Cargo.lock ./
3737
COPY .git .git
3838
COPY .sqlx .sqlx
3939
COPY crates crates
40+
COPY tools tools
4041
COPY proto proto
4142
COPY migrations migrations
4243
RUN cargo install --locked --bin defguard --path ./crates/defguard --root /build

crates/defguard_common/src/db/models/user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub struct User<I = NoId> {
145145
}
146146

147147
// TODO: Refactor the user struct to use SecretStringWrapper instead of this
148-
impl<I: std::fmt::Debug> fmt::Debug for User<I> {
148+
impl<I: fmt::Debug> fmt::Debug for User<I> {
149149
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
150150
let Self {
151151
id,

crates/defguard_core/src/auth/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,19 +383,19 @@ mod tests {
383383

384384
// No requested scopes
385385
let all_scopes = vec!["email".to_string(), "profile".to_string()];
386-
let requested_scopes = vec![];
386+
let requested_scopes = Vec::new();
387387
let result = get_available_scopes(&all_scopes, &requested_scopes);
388388
assert_eq!(result, Vec::<&str>::new());
389389

390390
// No available scopes
391-
let all_scopes = vec![];
391+
let all_scopes = Vec::new();
392392
let requested_scopes = vec!["email".to_string(), "profile".to_string()];
393393
let result = get_available_scopes(&all_scopes, &requested_scopes);
394394
assert_eq!(result, Vec::<&str>::new());
395395

396396
// Both empty
397-
let all_scopes = vec![];
398-
let requested_scopes = vec![];
397+
let all_scopes = Vec::new();
398+
let requested_scopes = Vec::new();
399399
let result = get_available_scopes(&all_scopes, &requested_scopes);
400400
assert_eq!(result, Vec::<&str>::new());
401401

crates/defguard_core/src/enterprise/directory_sync/jumpcloud.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ mod tests {
731731
let group_empty_ldap = UserGroup {
732732
id: "group789".to_string(),
733733
compiled_attributes: CompiledAttributes {
734-
ldap_groups: vec![],
734+
ldap_groups: Vec::new(),
735735
},
736736
};
737737
let directory_group_empty_ldap: DirectoryGroup = group_empty_ldap.into();
@@ -743,7 +743,7 @@ mod tests {
743743
fn test_response_collection_conversions() {
744744
// Test empty UsersResponse conversion
745745
let empty_users_response = UsersResponse {
746-
results: vec![],
746+
results: Vec::new(),
747747
total_count: 0,
748748
};
749749
let empty_directory_users: Vec<DirectoryUser> = empty_users_response.into();

crates/defguard_core/src/enterprise/directory_sync/microsoft.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ mod tests {
581581
"client_id".to_string(),
582582
"client_secret".to_string(),
583583
"https://login.microsoftonline.com/tenant-id-123/v2.0".to_string(),
584-
vec![],
584+
Vec::new(),
585585
);
586586
let tenant = provider.extract_tenant().unwrap();
587587
assert_eq!(tenant, "tenant-id-123");
@@ -593,7 +593,7 @@ mod tests {
593593
"id".to_string(),
594594
"secret".to_string(),
595595
"https://login.microsoftonline.com/tenant-id-123/v2.0".to_string(),
596-
vec![],
596+
Vec::new(),
597597
);
598598

599599
// no token
@@ -644,12 +644,12 @@ mod tests {
644644
display_name: "User 1".to_string(),
645645
mail: Some("email@email.com".to_string()),
646646
account_enabled: true,
647-
other_mails: vec![],
647+
other_mails: Vec::new(),
648648
id: "user1-id".into(),
649649
given_name: Some("User".into()),
650650
surname: Some("One".into()),
651651
mobile_phone: Some("555555555".into()),
652-
business_phones: vec![],
652+
business_phones: Vec::new(),
653653
},
654654
User {
655655
display_name: "User 2".to_string(),
@@ -660,18 +660,18 @@ mod tests {
660660
given_name: Some("User".into()),
661661
surname: Some("Two".into()),
662662
mobile_phone: None,
663-
business_phones: vec![],
663+
business_phones: Vec::new(),
664664
},
665665
User {
666666
display_name: "User 3".to_string(),
667667
mail: None,
668668
account_enabled: true,
669-
other_mails: vec![],
669+
other_mails: Vec::new(),
670670
id: "user3-id".into(),
671671
given_name: Some("User".into()),
672672
surname: Some("Three".into()),
673673
mobile_phone: None,
674-
business_phones: vec![],
674+
business_phones: Vec::new(),
675675
},
676676
],
677677
};
@@ -691,12 +691,12 @@ mod tests {
691691
display_name: "User 1".to_string(),
692692
mail: Some("email@email.com".to_string()),
693693
account_enabled: true,
694-
other_mails: vec![],
694+
other_mails: Vec::new(),
695695
id: "user1-id".into(),
696696
given_name: Some("User".into()),
697697
surname: None,
698698
mobile_phone: None,
699-
business_phones: vec![],
699+
business_phones: Vec::new(),
700700
},
701701
User {
702702
display_name: "User 2".to_string(),
@@ -707,18 +707,18 @@ mod tests {
707707
given_name: None,
708708
surname: None,
709709
mobile_phone: Some("555555555".into()),
710-
business_phones: vec![],
710+
business_phones: Vec::new(),
711711
},
712712
User {
713713
display_name: "User 3".to_string(),
714714
mail: None,
715715
account_enabled: true,
716-
other_mails: vec![],
716+
other_mails: Vec::new(),
717717
id: "user3-id".into(),
718718
given_name: Some("User".into()),
719719
surname: Some("Three".into()),
720720
mobile_phone: Some("555555555".into()),
721-
business_phones: vec![],
721+
business_phones: Vec::new(),
722722
},
723723
],
724724
};

crates/defguard_core/src/enterprise/directory_sync/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ mod test {
8989
target,
9090
None,
9191
None,
92-
vec![],
92+
Vec::new(),
9393
None,
9494
prefetch_users,
9595
)

0 commit comments

Comments
 (0)