SAML
An XML-based open standard for exchanging authentication and authorization data between an identity provider and a service provider, widely used in enterprise SSO.
Description
Security Assertion Markup Language (SAML) 2.0 is an XML-based framework for exchanging authentication and authorization information between parties, primarily between an identity provider (IdP) and a service provider (SP). SAML uses XML assertions -- signed documents that contain statements about a user's identity, attributes, and authentication status. It is the dominant SSO protocol in enterprise environments, supported by identity providers like Okta, Azure AD, OneLogin, and ADFS.
The SAML Web Browser SSO profile defines the most common flow: the user accesses the SP, which generates an AuthnRequest and redirects the user's browser to the IdP. The IdP authenticates the user (or recognizes an existing session), constructs a SAML Response containing one or more Assertions with identity claims, signs it with the IdP's private key, and POSTs it back to the SP's Assertion Consumer Service (ACS) URL. The SP validates the signature, checks conditions (audience, time validity, recipient), extracts the NameID and attributes, and establishes a local session.
SAML security is paramount -- XML signature wrapping attacks, assertion replay, and improper validation are common vulnerabilities. Always validate the entire XML signature chain (not just check for presence), verify that the signed element is the one you process (prevent wrapping attacks), check InResponseTo matches the original request ID, enforce time constraints with clock skew tolerance, and validate the Destination and Audience restriction. Use well-maintained libraries rather than implementing SAML parsing from scratch. SAML's verbosity and complexity compared to OIDC mean it is gradually being replaced for new applications, but remains essential for enterprise integration.
Prompt Snippet
Implement SAML 2.0 SP using passport-saml (Node.js) or python3-saml. Configure the SP with the IdP's metadata (SSO URL, X.509 certificate, entity ID). Expose the ACS endpoint at /auth/saml/callback and metadata at /auth/saml/metadata. Validate SAML responses by checking XML signature validity against the IdP certificate, verifying InResponseTo matches the stored AuthnRequest ID, checking Audience matches your SP entity ID, and enforcing NotBefore/NotOnOrAfter with 60-second clock skew tolerance. Extract NameID and custom attributes (email, groups, department) for JIT user provisioning. Store AuthnRequest IDs in Redis with TTL to prevent replay.
Tags
Related Terms
SSO (Single Sign-On)
An authentication scheme that allows users to authenticate once and gain access to multiple independent applications without re-entering credentials.
OpenID Connect (OIDC)
An identity layer built on top of OAuth 2.0 that enables clients to verify the identity of the end-user and obtain basic profile information.
Identity Provider (IdP)
A trusted service that authenticates users, manages their identities, and issues security tokens or assertions to relying applications.
LDAP Integration
Integration with LDAP directory services to authenticate users and retrieve organizational attributes like groups, departments, and roles from a centralized directory.
Claims-Based Identity
An identity model where user attributes and permissions are expressed as claims -- name-value pairs -- embedded in tokens or assertions, enabling decoupled and portable identity.