SAML Configuration
Added in 8.0 (prerelease)
This page documents the configuration options and models for the SAML 2.0 Identity Provider feature.
Call AddSaml() on the IdentityServer builder to enable SAML 2.0 support:
builder.Services.AddIdentityServer() .AddSaml();AddSaml() registers all SAML services and enables the five standard SAML endpoints. The
IdP-initiated SSO endpoint is not enabled by default and requires explicit opt-in (see
Enabling IdP-Initiated SSO below).
SamlOptions
Section titled “SamlOptions”SamlOptions controls the global behavior of the SAML 2.0 Identity Provider. Access it via
IdentityServerOptions.Saml:
builder.Services.AddIdentityServer(options =>{ options.Saml.DefaultSigningBehavior = SamlSigningBehavior.SignAssertion; options.Saml.DefaultClockSkew = TimeSpan.FromMinutes(5); options.Saml.WantAuthnRequestsSigned = false;});Available options:
-
MetadataValidityDurationIf set, the metadata document includes avalidUntilattribute. Defaults to 7 days. -
WantAuthnRequestsSignedWhentrue, the IdP requires all AuthnRequests to be signed. Defaults tofalse. -
DefaultAttributeNameFormatDefault SAML attribute name format URI for attributes in assertions. Defaults touri. -
DefaultPersistentNameIdentifierClaimTypeClaim type used to resolve a persistent NameID value. Defaults toClaimTypes.NameIdentifier. -
DefaultClaimMappingsMaps OIDC claim types to SAML attribute names. See below. -
SupportedNameIdFormatsSupported NameID formats for the IdP. Defaults to[ Email, Persistent, Transient, Unspecified ]. -
DefaultClockSkewClock skew tolerance for validating SAML message timestamps. Defaults to 5 minutes. -
DefaultRequestMaxAgeMaximum age for SAML AuthnRequests. Defaults to 5 minutes. -
DefaultSigningBehaviorDefault signing behavior for SAML responses. Defaults toSignAssertion. -
MaxRelayStateLengthMaximum length (in UTF-8 bytes) of the RelayState parameter. Defaults to 80. -
UserInteractionConfigures SAML endpoint paths. See below.
Default Claim Mappings
Section titled “Default Claim Mappings”The default DefaultClaimMappings dictionary maps common OIDC claim types to SAML 2.0 attribute
names:
| Claim type | SAML attribute name |
|---|---|
name | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name |
email | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress |
role | http://schemas.xmlsoap.org/ws/2005/05/identity/role |
Claims not present in this mapping are excluded from the SAML assertion. Override mappings globally
via SamlOptions.DefaultClaimMappings or per Service Provider via
SamlServiceProvider.ClaimMappings.
SamlUserInteractionOptions
Section titled “SamlUserInteractionOptions”SamlUserInteractionOptions configures the URL paths for all SAML endpoints. All paths are
relative to the application root.
-
RouteBase route prefix for all SAML endpoints. Defaults to/saml. -
MetadataPath suffix for the metadata endpoint. Defaults to/metadata. -
SignInPathPath suffix for the SP-initiated sign-in endpoint. Defaults to/signin. -
SignInCallbackPathPath suffix for the sign-in callback endpoint. Defaults to/signin_callback. -
IdpInitiatedPathPath suffix for the IdP-initiated SSO endpoint. Defaults to/idp-initiated. -
SingleLogoutPathPath suffix for the single logout endpoint. Defaults to/logout. -
SingleLogoutCallbackPathPath suffix for the logout callback endpoint. Defaults to/logout_callback.
The full URL for each endpoint is formed by combining the base URL of the IdentityServer host with
the Route prefix and the individual path suffix. For example, the metadata endpoint is available
at https://your-idp.example.com/saml/metadata by default.
SamlServiceProvider Model
Section titled “SamlServiceProvider Model”SamlServiceProvider represents a registered SAML 2.0 Service Provider configuration.
Available options:
-
EntityIdThe SP’s entity identifier URI, as declared in its SAML metadata. Required. -
DisplayNameHuman-readable name shown in logs and consent screens. Required. -
DescriptionOptional description. Defaults tonull. -
EnabledWhenfalse, all SAML requests from this SP are rejected. Defaults totrue. -
ClockSkewPer-SP clock skew override. UsesSamlOptions.DefaultClockSkewwhennull. Defaults tonull. -
RequestMaxAgePer-SP request maximum age. UsesSamlOptions.DefaultRequestMaxAgewhennull. Defaults tonull. -
AssertionConsumerServiceUrlsACS URLs where SAML responses will be delivered. At least one is required. -
AssertionConsumerServiceBindingSAML binding for the ACS (HttpPostorHttpRedirect). -
SingleLogoutServiceUrlSP’s Single Logout Service endpoint. Required for SLO support. Defaults tonull. -
RequireSignedAuthnRequestsWhentrue, unsigned AuthnRequests from this SP are rejected. Defaults tofalse. -
SigningCertificatesCertificates used to verify SP-signed messages. Defaults tonull. -
EncryptionCertificatesCertificates used to encrypt assertions for this SP. Defaults tonull. -
EncryptAssertionsWhentrue, assertions are encrypted usingEncryptionCertificates. Defaults tofalse. -
RequireConsentWhentrue, the user is always shown a consent screen. Defaults tofalse. -
AllowIdpInitiatedWhentrue, IdP-initiated SSO is allowed for this SP. Defaults tofalse. -
ClaimMappingsPer-SP claim-to-attribute mappings that overrideSamlOptions.DefaultClaimMappings. Defaults to{}. -
DefaultNameIdFormatDefault NameID format to use when the SP does not specify one. Defaults tourn:...unspecified. -
DefaultPersistentNameIdentifierClaimTypePer-SP override for the claim type used to resolve a persistent NameID. Defaults tonull. -
SigningBehaviorPer-SP signing behavior. UsesSamlOptions.DefaultSigningBehaviorwhennull. Defaults tonull.
SamlBinding
Section titled “SamlBinding”Defines the SAML protocol binding used for message transport:
| Value | Description |
|---|---|
HttpRedirect | HTTP-Redirect binding. The SAML message is URL-encoded and sent as a query parameter. |
HttpPost | HTTP-POST binding. The SAML message is Base64-encoded and sent in an HTML form. |
SamlSigningBehavior
Section titled “SamlSigningBehavior”Controls what elements are signed in SAML responses:
| Value | Description |
|---|---|
DoNotSign | No signing. For testing only — do not use in production. |
SignResponse | Signs the entire SAML <Response> element. |
SignAssertion | Signs the <Assertion> element inside the response. Recommended. |
SignBoth | Signs both the <Response> and the <Assertion>. Maximum security, larger messages. |
SamlEndpointType
Section titled “SamlEndpointType”SamlEndpointType is a class (not an enum) that represents a SAML endpoint with a location and
binding. Used for SamlServiceProvider.SingleLogoutServiceUrl:
new SamlServiceProvider{ // ... SingleLogoutServiceUrl = new SamlEndpointType { Location = new Uri("https://sp.example.com/saml/slo"), Binding = SamlBinding.HttpPost, }}Enabling IdP-Initiated SSO
Section titled “Enabling IdP-Initiated SSO”IdP-initiated SSO is disabled by default. To enable it, set the endpoint option and configure
AllowIdpInitiated = true on each SP that should permit IdP-initiated flows:
builder.Services.AddIdentityServer(options =>{ options.Endpoints.EnableSamlIdpInitiatedEndpoint = true;});new SamlServiceProvider{ EntityId = "https://sp.example.com", AllowIdpInitiated = true, // ...}Endpoint Enable/Disable Options
Section titled “Endpoint Enable/Disable Options”Individual SAML endpoints can be enabled or disabled via IdentityServerOptions.Endpoints:
builder.Services.AddIdentityServer(options =>{ options.Endpoints.EnableSamlMetadataEndpoint = true; options.Endpoints.EnableSamlSigninEndpoint = true; options.Endpoints.EnableSamlSigninCallbackEndpoint = true; options.Endpoints.EnableSamlIdpInitiatedEndpoint = false; // must opt in options.Endpoints.EnableSamlLogoutEndpoint = true; options.Endpoints.EnableSamlLogoutCallbackEndpoint = true;});AddSaml() sets all of the above to true except EnableSamlIdpInitiatedEndpoint.