Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

SAML (Security Assertion Markup Language) - Ngôn ngữ đánh dấu xác nhận an ninh trong mạng

SAML là gì?

SAML (Security Assertion Markup Language) là chuẩn mở dựa trên XML để trao đổi dữ liệu xác thực (authentication) và ủy quyền (authorization) giữa Identity Provider (IdP) và Service Provider (SP). Phiên bản hiện tại: SAML 2.0 (2005).

3 Vai trò chính trong SAML

Luồng hoạt động SAML 2.0 (SP-Initiated SSO)

  1. User truy cập SP (ví dụ: salesforce.com)
  2. SP redirect user đến IdP với SAML AuthnRequest
  3. User đăng nhập tại IdP (MFA, password, certificate...)
  4. IdP tạo SAML Assertion (chữ ký số, encrypted) → POST về SP qua browser (HTTP POST Binding)
  5. SP xác thực chữ ký IdP, kiểm tra điều kiện (NotBefore/NotOnOrAfter, Audience, Recipient)
  6. SP tạo session cho user → Cho phép truy cập

Cấu trúc SAML Assertion (3 loại Statement)

Vai tròMô tảVí dụ
Principal (User)Người dùng cuối cần truy cập dịch vụNhân viên đăng nhập
Identity Provider (IdP)Xác thực người dùng, phát hành SAML AssertionMicrosoft Entra ID, Okta, Ping Identity, Keycloak, AD FS
Service Provider (SP)Nhận Assertion, cho phép truy cập tài nguyênSalesforce, Google Workspace, Box, Zoom, AWS Console, GitHub

4 Thành phần cốt lõi SAML

  1. Assertions: Gói tin chứa thông tin xác thực/thuộc tính (XML đã ký/mã hóa)
  2. Protocol: Các message request/response (AuthnRequest, Response, LogoutRequest...)
  3. Bindings: Cách truyền tải protocol qua transport (HTTP Redirect, HTTP POST, Artifact, SOAP)
  4. Profiles: Kết hợp assertions + protocols + bindings cho use case cụ thể (SSO, SLO, IdP Discovery)

SAML vs OIDC/OAuth 2.0

Loại StatementMục đíchNội dung chính
Authentication StatementXác thực danh tínhAuthnInstant, AuthnContextClassRef (Password, MFA, Kerberos...), Subject
Attribute StatementTruyền thuộc tính người dùngEmail, Name, Department, Roles, Groups, EmployeeID
Authorization Decision StatementQuyết định ủy quyềnPermit/Deny action trên resource (ít dùng, thường dùng RBAC/ABAC riêng)

Ứng dụng thực tế

  • Enterprise SSO: Một lần đăng nhập (IdP) → Truy cập Salesforce, Office 365, Slack, Zoom, Workday, ServiceNow...
  • Federation B2B: Partner IdP → SP của công ty bạn (Cross-domain trust)
  • Government/Healthcare: Yêu cầu SAML cho compliance (FIPS, HIPAA)
  • AWS Console Federation: Corporate IdP → AWS IAM Role via SAML

Lưu ý bảo mật SAML

  • Luôn ký số (Sign) Assertion - IdP ký bằng private key, SP verify bằng public key (certificate)
  • Mã hóa Assertion (EncryptedAssertion) cho dữ liệu nhạy cảm (Attribute Statement)
  • Kiểm tra Audience Restriction (SP Entity ID) và Recipient (ACS URL)
  • Validate NotBefore / NotOnOrAfter (thời gian hiệu lực)
  • Bảo vệ IdP: MFA bắt buộc, Hardened OS, Monitoring
  • Chống Replay Attack: SP lưu Assertion ID (InResponseTo) đã dùng
Đặc điểmSAML 2.0OIDC/OAuth 2.0
Định dạngXMLJSON (JWT)
Use case chínhEnterprise SSO, FederationAPI Authorization, Mobile/SPA, Modern Apps
TokenSAML Assertion (XML)ID Token (JWT) + Access Token
Kích thướcLớn (XML verbose)Nhỏ, gọn (JWT compact)
Mobile-friendlyKhó (XML parsing)Rất tốt (JSON native)
Session ManagementSAML Session Index, SLORefresh Token, Revocation