Overview
SAML authentication provides:- Standards-based SSO using SAML 2.0 protocol
- Integration with enterprise identity providers
- Secure assertion-based authentication
- Automatic user provisioning via SAML attributes
Prerequisites
- Cal.com Enterprise license with SSO enabled
- Identity Provider supporting SAML 2.0
- Separate PostgreSQL database for SAML data
- Admin access to both Cal.com and your IdP
Setup Guide
1. Configure Environment
Add SAML configuration to your.env file:
.env
.env.example:46-55
2. Create SAML Database
Create and migrate the SAML database:3. Retrieve SAML Metadata
Cal.com provides SAML Service Provider metadata: SAML Configuration Values:- Entity ID / Audience:
https://saml.cal.com - Assertion Consumer Service (ACS) URL:
https://your-domain.com/api/auth/saml/callback - Single Logout URL:
https://your-domain.com/api/auth/saml/logout - Name ID Format:
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
packages/features/ee/sso/lib/saml.ts:10-13
4. Configure Identity Provider
Create a SAML application in your identity provider with the following settings:Okta Configuration
- Navigate to Applications → Create App Integration
- Select SAML 2.0
-
Configure:
- Single sign-on URL:
https://your-domain.com/api/auth/saml/callback - Audience URI:
https://saml.cal.com - Name ID format: EmailAddress
- Application username: Email
- Single sign-on URL:
-
Attribute Statements (optional):
- Download the IdP metadata XML
Azure AD Configuration
- Navigate to Enterprise Applications → New Application
- Create a non-gallery application
- Configure Single sign-on → SAML
-
Set:
- Identifier (Entity ID):
https://saml.cal.com - Reply URL (ACS):
https://your-domain.com/api/auth/saml/callback - Sign on URL:
https://your-domain.com
- Identifier (Entity ID):
-
User Attributes & Claims:
- Download Federation Metadata XML
Google Workspace Configuration
- Navigate to Apps → Web and mobile apps → Add custom SAML app
- Download IdP metadata
-
Configure Service Provider Details:
- ACS URL:
https://your-domain.com/api/auth/saml/callback - Entity ID:
https://saml.cal.com - Name ID format: EMAIL
- Name ID: Basic Information > Primary email
- ACS URL:
-
Attribute mapping:
5. Upload IdP Metadata to Cal.com
- Log in to Cal.com as a SAML admin
- Navigate to Settings → Security → Single Sign-On
- Select your organization/team
- Upload or paste your IdP metadata XML
- Or manually configure:
- IdP Entity ID: From IdP metadata
- SSO URL: From IdP metadata
- Certificate: X.509 certificate from IdP
SAML Constants
Cal.com uses the following SAML constants:packages/features/ee/sso/lib/saml.ts:10-15
Tenant Structure
SAML connections are scoped per team/organization: Tenant Format:team-{teamId}
packages/features/ee/sso/lib/saml.ts:18
This allows:
- Multiple teams to have different SAML configurations
- Isolated authentication per team
- Organization-level SAML that applies to all sub-teams
User Provisioning
SAML authentication can automatically provision users:First-Time Login
When a user logs in via SAML for the first time:packages/features/ee/sso/lib/sso.ts:34-49
Required Conditions
For automatic provisioning:ORGANIZATIONS_AUTOLINK=1must be set- Organization must have verified the email domain
- User email domain must match organization domain
- User must not already belong to another organization
Permission Management
Self-Hosted Deployments
Only users listed inSAML_ADMINS can configure SAML:
packages/features/ee/sso/lib/saml.ts:22-30
Hosted Deployments
SAML configuration requires organization-level permissions:packages/features/ee/sso/lib/saml.ts:51-64
Testing SAML Configuration
1. Verify SAML Connection
Test that SAML metadata is correctly configured:2. Initiate Test Login
- Open incognito browser window
- Navigate to
/auth/login - Enter email address that matches SAML domain
- Verify redirect to IdP
- Log in with IdP credentials
- Verify successful redirect back to Cal.com
- Confirm user session is created
3. Check SAML Response
Enable debug logging to inspect SAML assertions:.env
Troubleshooting
Invalid SAML Response
Symptoms: Login fails after IdP redirect Solutions:- Verify ACS URL exactly matches:
https://your-domain.com/api/auth/saml/callback - Check Entity ID matches:
https://saml.cal.com - Ensure certificate is not expired
- Verify clock sync between IdP and Cal.com servers
User Not Found
Error: “Could not find a SSO Identity Provider for your email” Solutions:- Verify SAML connection is configured for the user’s team
- Check user has membership in a team with SAML enabled
- Confirm email in SAML assertion matches user’s email
- Review SAML admin permissions
packages/features/ee/sso/lib/sso.ts:72-77
Auto-Provisioning Not Working
Solutions:- Set
ORGANIZATIONS_AUTOLINK=1in environment - Verify organization has verified the email domain
- Check user email domain matches organization’s domain
- Ensure user doesn’t already belong to another organization
packages/features/ee/sso/lib/sso.ts:32-54
Permission Denied
Error: “dont_have_permission” Solutions:- Self-hosted: Add email to
SAML_ADMINSenvironment variable - Hosted: Assign Owner or Admin role in organization
packages/features/ee/sso/lib/saml.ts:46-74
Database Connection Error
Error: Cannot connect to SAML database Solutions:- Verify
SAML_DATABASE_URLis correctly set - Ensure database exists and is accessible
- Run migrations:
DATABASE_URL=$SAML_DATABASE_URL yarn prisma migrate deploy - Check database credentials and network access
SAML Attributes
Cal.com supports the following SAML attributes:| Attribute | Description | Required |
|---|---|---|
email | User’s email address | Yes |
firstName | User’s first name | No |
lastName | User’s last name | No |
username | User’s username | No |
Security Best Practices
- Certificate Validation: Always validate SAML assertions with IdP certificate
- Encryption: Use
CALENDSO_ENCRYPTION_KEYto encrypt sensitive SAML data - HTTPS Only: Never use SAML over HTTP in production
- Short Session Lifetime: Configure IdP to issue short-lived assertions
- Audit Logging: Monitor SAML login attempts and failures
- Certificate Rotation: Rotate SAML certificates before expiration
- Restrict Admins: Limit
SAML_ADMINSto necessary personnel only
Advanced Configuration
Custom SAML Attributes
Map additional SAML attributes to user fields:- Custom routing logic
- Team assignment rules
- User metadata
Multiple SAML Connections
Organizations can configure multiple SAML connections:packages/features/ee/sso/lib/sso.ts:56-70
API Reference
SAML Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/api/auth/saml/callback | POST | SAML assertion consumer service |
/api/auth/saml/logout | POST | Single logout service |
/api/auth/saml/config | GET | Retrieve SAML configuration |
/api/auth/saml/metadata | GET | Service provider metadata XML |
Connection Types
packages/features/ee/sso/lib/saml.ts:83-88