Bỏ qua, đến nội dung

@digiforce-nc/plugin-auth-saml

Plugin xác thực qua SAML 2.0 — hỗ trợ SSO với Okta, OneLogin, Azure AD, ADFS và bất kỳ Identity Provider nào tuân chuẩn SAML. Sử dụng thư viện @node-saml/node-saml để xử lý SAML assertion.

Plugin này làm gì?

SAMLAuth kế thừa BaseAuth, triển khai vai trò Service Provider (SP) trong luồng SAML 2.0 Web Browser SSO Profile. Plugin tạo AuthnRequest gửi đến IdP, nhận SAMLResponse qua HTTP POST binding, validate assertion và trích xuất user profile.

Các khái niệm SAML

Thuật ngữVai trò trong plugin
Service Provider (SP)Digiforce — nơi user muốn truy cập
Identity Provider (IdP)Okta, Azure AD... — nơi user đăng nhập
SP Entity IDTên định danh SP = tên authenticator trong Digiforce
AssertionXML chứa thông tin user, được IdP ký số
ACS URLCallback URL nhận SAMLResponse (POST binding)

Luồng xác thực

Callback URL (ACS) cần đăng ký tại IdP:

{http|https}://{host}{API_BASE_PATH}saml:redirect?authenticator={name}&__appName={app}

Ví dụ: https://app.example.com/api/saml:redirect?authenticator=okta-sso&__appName=main

Cấu hình

Tham sốKiểuMô tả
ssoUrlstringIdP SSO URL — nơi gửi AuthnRequest
certificatestringCertificate (PEM) của IdP để verify assertion signature
idpIssuerstringEntity ID của IdP (phải khớp Issuer trong SAMLResponse)
signResponsebooleanYêu cầu toàn bộ Response phải được ký
signAssertionbooleanYêu cầu Assertion bên trong phải được ký
signatureAlgorithmstringThuật toán ký: sha1, sha256, sha512
httpbooleanDùng HTTP thay HTTPS cho callback URL
userBindFieldstringField dùng để liên kết user (ví dụ: email)
autoRedirectbooleanTự động redirect đến IdP khi chưa đăng nhập
public.autoSignupbooleanTự tạo tài khoản nếu user chưa tồn tại

API endpoints

EndpointQuyềnMô tả
saml:getAuthUrlPublicTrả về URL redirect đến IdP (chứa SAMLRequest)
saml:redirectPublicACS endpoint — nhận SAMLResponse POST từ IdP
saml:checkRedirectPublicKiểm tra trạng thái redirect (cho auto-redirect)

Thành phần client

Thành phầnMô tả
SAMLButtonNút "Đăng nhập bằng SAML" trên trang login
OptionsForm cấu hình SAML trong Settings → Authentication
SAMLAutoRedirectProviderProvider tự động redirect đến IdP nếu bật autoRedirect

Dependencies

PackageVai trò
@node-saml/node-samlThư viện xử lý SAML request/response, validate assertion
@digiforce-nc/authBase auth framework (peer)
@digiforce-nc/serverServer framework (peer)
@digiforce-nc/clientClient framework (peer)

Mục lục chi tiết