Giao diện
Chi tiết luồng xác thực LDAP
Plugin LDAP không phải SSO theo nghĩa redirect — user nhập trực tiếp account và password vào form, server xác thực bằng cách bind đến LDAP server.
Tổng quan luồng
Luồng LDAP là form-based authentication: user gửi credentials qua POST, server thực hiện two-phase bind (service account → user account) để xác minh.
Sequence diagram chi tiết
Chi tiết từng phase
Phase 1: Service Account Bind
Plugin kết nối đến LDAP server và bind bằng service account (bindDN + bindPassword). Đây là bước xác minh kết nối và quyền truy cập directory.
- Nếu URL sử dụng
ldaps://, kết nối qua TLS - Service account chỉ cần quyền read trên directory
- Nếu bind thất bại, toàn bộ luồng dừng lại
Phase 2: Search User
Sau khi bind thành công, plugin tìm kiếm user trong directory:
- Thay thế placeholder
accounttrongfilterbằng giá trị user nhập vào - Thực hiện LDAP search từ
searchDNvớiscopevàsizeLimitđã cấu hình - Lấy entry đầu tiên từ kết quả — bao gồm DN và các attributes
Phase 3: User Bind
Plugin bind lại bằng DN vừa tìm được và password user nhập vào. Đây là bước xác thực thực sự — LDAP server kiểm tra password.
- Nếu bind thành công → password đúng
- Nếu bind thất bại → password sai, trả lỗi 401
Attribute mapping
Sau khi xác thực thành công, plugin map LDAP attributes sang local user fields theo attributeMap:
LDAP entry:
cn: "Nguyễn Văn A"
mail: "a.nguyen@company.com"
sAMAccountName: "anguyen"
attributeMap: { "cn": "nickname", "mail": "email", "sAMAccountName": "username" }
Local user:
nickname: "Nguyễn Văn A"
email: "a.nguyen@company.com"
username: "anguyen"So sánh với SSO plugins
| Tiêu chí | LDAP | OIDC / SAML / CAS |
|---|---|---|
| Phương thức | Form POST trực tiếp | Redirect đến IdP |
| Password xử lý bởi | Digiforce server (forward đến LDAP) | Identity Provider |
| Cần redirect URI | Không | Có |
| CSRF protection | Không cần (form POST) | State parameter / cookie |
| Phù hợp cho | Intranet, AD enterprise | Internet, cloud IdP |
Xử lý lỗi
| Lỗi | Nguyên nhân | Hành vi |
|---|---|---|
| LDAP connection refused | URL sai hoặc server down | 500 Internal error |
| Service bind failed | bindDN hoặc password sai | 500 LDAP connection failed |
| User not found | Filter không khớp hoặc user không tồn tại | 401 |
| User bind failed | Password sai | 401 Invalid credentials |
| Size limit exceeded | Quá nhiều kết quả | Trả kết quả đến sizeLimit |