Bỏ qua, đến nội dung

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:

  1. Thay thế placeholder account trong filter bằng giá trị user nhập vào
  2. Thực hiện LDAP search từ searchDN với scopesizeLimit đã cấu hình
  3. 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íLDAPOIDC / SAML / CAS
Phương thứcForm POST trực tiếpRedirect đến IdP
Password xử lý bởiDigiforce server (forward đến LDAP)Identity Provider
Cần redirect URIKhông
CSRF protectionKhông cần (form POST)State parameter / cookie
Phù hợp choIntranet, AD enterpriseInternet, cloud IdP

Xử lý lỗi

LỗiNguyên nhânHành vi
LDAP connection refusedURL sai hoặc server down500 Internal error
Service bind failedbindDN hoặc password sai500 LDAP connection failed
User not foundFilter không khớp hoặc user không tồn tại401
User bind failedPassword sai401 Invalid credentials
Size limit exceededQuá nhiều kết quảTrả kết quả đến sizeLimit