Why use SAML?
SAML remains relevant for specific use cases: Legacy systems compatibility SAML has been in use since 2002 and is deeply integrated into many legacy systems and enterprise environments. Organizations with existing SAML infrastructure may prefer to continue using it to avoid costly and complex migrations. Enterprise use cases SAML is often favored in enterprise settings where detailed user attributes and complex authorization requirements are necessary. Its support for rich metadata and customizable assertions makes it suitable for intricate access control scenarios. Mature ecosystem The SAML ecosystem is mature, with extensive support from a wide range of enterprise applications and identity providers. This broad compatibility ensures that SAML can be used seamlessly across various platforms and services.SAML Terminology
Understanding SAML requires familiarity with these key terms:| Term | Description |
|---|---|
| Service Provider (SP) | The application the user is trying to sign into |
| Identity Provider (IdP) | The centralized authentication service (ZITADEL) |
| SAML Request | XML message from SP to IdP requesting authentication |
| SAML Response | XML message from IdP to SP containing authentication assertions |
| Assertion | Signed statement about the user within the SAML response |
| Assertion Consumer Service (ACS) | SP endpoint that processes SAML responses |
| Attributes | User profile information included in the SAML response |
| Relay State | Parameter to maintain application state across authentication |
| SAML Trust | Configuration establishing trust between IdP and SP |
| Metadata | XML file containing configuration for IdP or SP |
| Entity ID | Unique identifier for the IdP or SP (also called Issuer) |
SAML Authentication Flows
ZITADEL supports SP-initiated SAML flows:SP-Initiated Flow
The user starts at the service provider, which sends a SAML request to ZITADEL. Flow steps:- User attempts to access protected resource at SP
- SP generates SAML AuthnRequest
- SP redirects user to ZITADEL SSO endpoint with SAML request
- User authenticates at ZITADEL (if not already authenticated)
- ZITADEL generates SAML Response with assertions
- ZITADEL redirects user back to SP’s ACS with SAML response
- SP validates SAML response and assertions
- SP grants access to user
IdP-Initiated Flow
ZITADEL currently does not support IdP-initiated flows. All SAML authentications must be initiated from the service provider.ZITADEL as SAML Identity Provider
SAML Metadata
ZITADEL provides SAML metadata at:- Entity ID (Issuer)
- SSO endpoint URL
- Signing certificate
- Supported bindings
- Supported NameID formats
Certificate Endpoint
Download ZITADEL’s SAML signing certificate:SSO Endpoint
The Single Sign-On endpoint handles SAML authentication requests:urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirecturn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
SAML Request Format
A SAML AuthnRequest contains:| Element | Description |
|---|---|
ID | Unique identifier for this request |
IssueInstant | Timestamp when request was created |
Destination | ZITADEL’s SSO endpoint |
AssertionConsumerServiceURL | Where ZITADEL should send the response |
Issuer | Service provider’s entity ID |
Signature | Digital signature of the request (optional) |
HTTP-Redirect Binding
With HTTP-Redirect binding, the SAML request is base64-encoded and sent as a URL parameter:HTTP-POST Binding
With HTTP-POST binding, the SAML request is sent in the request body:SAML Response Format
ZITADEL returns a SAML Response containing user assertions:| Element | Description |
|---|---|
InResponseTo | ID of the SAML request being responded to |
Status | Success or error status |
Assertion | Signed statement about the authenticated user |
Subject | User identifier (NameID) |
Conditions | Time window and audience restrictions |
AuthnStatement | Authentication method and time |
AttributeStatement | User attributes (profile data) |
Standard Attributes
ZITADEL includes these standard attributes in SAML responses:| Attribute Name | Description | Example |
|---|---|---|
UserID | ZITADEL user ID | 260242264868201995 |
UserName | Username | [email protected] |
Email | Email address | [email protected] |
FirstName | Given name | John |
SurName | Family name | Doe |
FullName | Complete name | John Doe |
Custom Attributes
You can add custom attributes to SAML responses using ZITADEL Actions:Configuring a SAML Application
SAML Identity Brokering
ZITADEL can act as both an identity provider and integrate with external SAML identity providers for identity brokering: How it works:- User attempts to access a service (SP) protected by ZITADEL
- ZITADEL redirects user to external SAML IdP for authentication
- User authenticates with external SAML IdP
- External IdP returns SAML assertion to ZITADEL
- ZITADEL processes the assertion and creates its own SAML assertion
- ZITADEL sends final SAML assertion to the service provider
- User gains access to the service
Validating SAML Responses
Service providers must validate SAML responses to ensure security:Signature Validation
- Extract the signature from the SAML response or assertion
- Obtain ZITADEL’s public key from the metadata or certificate endpoint
- Verify the XML signature using the public key
- Ensure the signature covers the entire assertion
Assertion Validation
Validate these elements in the SAML assertion:| Element | Validation |
|---|---|
Issuer | Must match ZITADEL’s entity ID |
InResponseTo | Must match the original request ID |
Recipient | Must match your ACS URL |
Audience | Must match your entity ID |
NotBefore | Current time must be after this timestamp |
NotOnOrAfter | Current time must be before this timestamp |
SubjectConfirmation | Must be bearer method |
Status Code Validation
Check the status code in the SAML response:Success.
Security Best Practices
- Always validate signatures: Verify XML signatures on SAML responses and assertions
- Use canonicalized XML: Normalize XML before signature verification to prevent manipulation
- Validate XML schema: Ensure only expected XML formats are accepted
- Enforce time windows: Respect
NotBeforeandNotOnOrAfterconditions - Validate all parties: Check Issuer, Recipient, and Audience values
- Prevent replay attacks: Track processed assertion IDs and reject duplicates
- Use HTTPS exclusively: Never exchange SAML messages over unencrypted connections
- Limit XML parser features: Disable external entity resolution to prevent XXE attacks
- Validate metadata: Verify metadata sources before importing
- Monitor for anomalies: Track authentication patterns and alert on suspicious activity
Troubleshooting
Common Issues
Signature validation fails- Ensure you’re using ZITADEL’s current signing certificate
- Verify the certificate hasn’t expired
- Check that XML canonicalization is correct
- Verify your SP’s entity ID matches the Audience value
- Check for case sensitivity and trailing slashes
- Check server time synchronization (NTP)
- Verify time zone settings
- Consider clock skew tolerance in your SP configuration
- Ensure the ACS URL in the request matches your registered ACS URL
- Check for HTTP vs HTTPS mismatches
- Validate XML syntax
- Ensure metadata conforms to SAML 2.0 specification
- Check that required elements are present
Testing SAML Integration
Using ZITADEL as IdP
- Create a SAML application in ZITADEL
- Configure your service provider with ZITADEL’s metadata
- Create test users in ZITADEL
- Initiate authentication from the service provider
- Verify successful authentication and attribute mapping
Example Service Provider Setup
See the ZITADEL Python SAML SP example for a reference implementation.Browser Tools
Use browser extensions to inspect SAML messages:- SAML-tracer (Firefox/Chrome)
- SAML Chrome Panel
When to Use SAML vs OIDC
Use SAML when:- Integrating with enterprise applications that require SAML
- Working with legacy systems built before OIDC adoption
- Organization policy mandates SAML
- Need for complex attribute statements and authorization decisions
- Building new applications
- Developing mobile or single-page applications
- Prefer JSON over XML
- Want simpler implementation and debugging
- Need modern features like PKCE and dynamic client registration