LDAP/AD sync aborts entirely when two directory users share the same e-mail address
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- postgresql, rust
- Lĩnh vực
- authentication, backend, databases
Hướng nghiên cứu
Start with crates/defguard_core/src/enterprise/ldap/sync.rs at the import path around lines 1133-1169 and apply_user_modifications around line 629; compare the conflict handling in directory_sync/mod.rs:867-897. Reproduce the duplicate-mail case, then verify that the conflicting user is skipped, both users are named in the error, and the remaining sync operations continue instead of rolling back.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Component: defguard core – enterprise/ldap/sync.rs
Version: 2.1.0 (also present on current main)
Description
user.email has a case-insensitive unique index (email_unique_idx, migration 20241204113104_case_insensitive_email). The LDAP sync only checks for username collisions before importing a user, never for e-mail collisions. If two AD accounts carry the same mail attribute (e.g. personal account + admin account, or a shared-mailbox account), User::save() hits the unique violation, the error propagates via ?, the whole transaction is rolled back and the entire sync run fails. All other pending adds/updates/deletes of that run are lost as well.
Affected code paths
- Import: crates/defguard_core/src/enterprise/ldap/sync.rs:1133-1169 – only find_by_username is checked; user.save() at line 1169 fails on duplicate e-mail.
- Update: apply_user_modifications, sync.rs:629 – changing a user's e-mail in AD to an address already used by another Defguard user fails the same way.
- User::save() is a plain INSERT without ON CONFLICT (crates/defguard_common/src/db/models/user.rs:1138).
Steps to reproduce
- Create two AD users alice and alice-admin, both with mail = [email protected].
- Enable LDAP sync (AD, LDAP as authority).
- Trigger sync.
Actual behaviour
Sync fails with a Postgres unique-constraint error on email_unique_idx. No users from that run are imported or updated.
Expected behaviour
Same as the OIDC directory sync (directory_sync/mod.rs:867-897): detect the conflict via User::find_by_email, log an error naming both users, skip that single user and continue the sync. Ideally also surface the conflict in the sync-preview/dry-run.
Workaround
Ensure unique mail attributes in AD or exclude the conflicting account via the LDAP user search filter / sync group.
- Ngôn ngữ chính
- Rust
- Star
- 2.9k
- Fork
- 121
- Merge trung bình
- 17 giờ 58 phút
- Pull request đã merge (30 ngày)
- 103
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DefGuard/defguard
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Unclear toggle titlesĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
DefGuard/defguard#3530 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của DefGuard/defguard
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
mozilla-services/syncstorage-rs#2715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
physicsdolphin/nv-uefi-unlocker#53 · 4 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/desktop-shell
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
yantrikos/yantrik-os#1012 ·
Maintainer thường phản hồi trong vòng 1 ngày