Skip to content

SSO generation

Producer rules for typed Web Browser SSO generation: service-provider start_sso, and identity-provider respond_sso and initiate_sso. SpValidationPolicy::recommended leaves AuthnRequest signing and identifier creation off. IdpValidationPolicy::recommended does not turn assertion encryption on. Default, new, try_new, and the config builders are Recommended. Raw generation keeps its existing validation defaults. The preset distinction is recorded in validation presets.

Normative text is SAML Core 2.0, Profiles 2.0, and Bindings 2.0, as corrected by Approved Errata 05. HTTP-POST-SimpleSign is the supported CD04 binding. Schema citations are the OASIS assertion and protocol schemas. A profile or binding rule is used when it narrows Core for this flow.

StartSso::apply_web_browser_sso_generation_rules and RespondSso::apply_web_browser_sso_generation_rules select the producer rules below. The constructors redirect, post, and simple_sign leave that selection off, which is the samlify-port generation kept for callers leaving the raw API.

A response delivered as an HTTP-Artifact is built by these same rules. Its delivery is in HTTP-Artifact response.

Service provider AuthnRequest

Rule Actor Direction Level
Issuer is present, is the service provider’s identifier, and omits Format or sets it to entity Service provider Generate AuthnRequest Mandatory. Profiles §4.1.4.1
ID, Version 2.0, and UTC IssueInstant are present Service provider Generate AuthnRequest Mandatory. Protocol schema RequestAbstractType; Core §1.3.3
Do not generate a leap-second time Service provider Generate any instant Mandatory. Core §1.3.3 MUST NOT generate leap seconds. Receivers are not required to reject them
If the AuthnRequest is signed, Destination is the URL where the user agent is sent Service provider Generate AuthnRequest Mandatory when the message is signed. Bindings §3.4.5.2 and §3.5.5.2
RelayState does not exceed 80 bytes Service provider Generate AuthnRequest Mandatory prohibition. Bindings §3.4.3, §3.5.3, and HTTP-POST-SimpleSign CD-04 §2.3. Integrity protection remains a recommendation
HTTP-Redirect removes a protocol ds:Signature, raw-DEFLATEs the rest, and signs SAMLRequest, RelayState when present, then SigAlg Service provider Generate AuthnRequest Mandatory. Bindings §3.4.4.1. An assertion signature stays. An unsigned redirect that still has a protocol signature is rejected. An absent RelayState is omitted
HTTP-POST-SimpleSign signs the raw XML octets, then RelayState when present, then SigAlg Service provider Generate AuthnRequest Mandatory when that binding is used. CD-04 §2.5 and §2.6. An XML signature inside the message stays
Do not emit AllowCreate when the requested name-identifier format is transient Service provider Generate AuthnRequest Mandatory prohibition. Core §3.4.1.1 as replaced by Errata 05 E14. Enforced only when producer rules are selected. Samlify-port generation still emits the attribute
Sign the AuthnRequest Service provider Generate AuthnRequest Optional for this profile. Profiles §4.1.4.1 says the request MAY be signed as directed by the binding. Bindings §3.4.5.2 and §3.5.5.2 say the encoded message MAY be signed. Core §3.4.1’s general SHOULD is not applied on top of that profile rule. Stays off unless AuthnRequestSigningPolicy::Sign, which also publishes AuthnRequestsSigned="true" in the service provider metadata. Metadata §2.4.4, as amended by Errata 05 E7, then obligates an identity provider to reject an unsigned request from this service provider; see acceptance rules. A signing service provider signs whatever the identity provider’s WantAuthnRequestsSigned. Metadata §2.4.3, as amended by Errata 05 E7, says that flag tells service providers whether to expect an unsigned request to be accepted, and that the service provider is not obligated to sign. Library policy: when WantAuthnRequestsSigned is true and the service provider does not sign, start_sso and create_login_request return SamlError::Invalid and build no request. E7 does not require that refusal, but says the service provider can reasonably expect an unsigned request to be rejected
ForceAuthn Service provider Generate AuthnRequest Optional. Core §3.4.1, default false when omitted. Stays omitted unless StartSso::force_authn
RequestedAuthnContext Service provider Generate AuthnRequest over HTTP-Redirect, HTTP-POST, or SimpleSign Optional, omitted unless StartSso::requested_authn_context. Core §§3.4.1 and 3.3.2.2.1, with Errata 05 E45. The protocol schema requires one or more class references or one or more declaration references. The constructor rejects empty and mixed lists. Generation checks absolute URIs, keeps reference order, writes the explicit comparison, and places the element after NameIDPolicy (and Conditions, if present), before Scoping. The selected request signature covers it. saml2int SDP-SP07 is a deployment-profile rule: use exact with the required class references, or omit the element when no specific class is required. It is not an OASIS requirement
IsPassive Service provider Generate AuthnRequest over HTTP-Redirect, HTTP-POST, or SimpleSign Optional. Core §3.4.1. Omitted unless StartSso::is_passive; omission means false. A true value requires the responding IdP and user agent to avoid visibly taking control of the requester’s interface; when ForceAuthn is also true, fresh authentication must meet that passive constraint
ProviderName Service provider Generate AuthnRequest over HTTP-Redirect, HTTP-POST, or SimpleSign Optional. Core §3.4.1 and protocol schema AuthnRequestType. StartSso::provider_name writes the requester’s human-readable name only when set, with XML escaping. These three options require the built-in AuthnRequest renderer; combining one with a custom template returns Invalid rather than silently omitting it
Identifier creation (AllowCreate="true") Service provider Generate AuthnRequest Optional capability. Errata 05 E14 says a requester that does not make specific use of the attribute SHOULD generally set it to true, and the schema default is false when the attribute is omitted. NameIdCreationPolicy is that specific use. The capability stays off (AllowCreate="false") unless NameIdCreationPolicy::AllowCreate. It is not emitted at all for a transient format when producer rules are selected. A service provider with no configured format omits Format, which leaves the identity provider free to return any kind of identifier (Core §3.4.1.1). Typed service providers with no configured format already advertise and request emailAddress
NameIDPolicy Format is omitted or an absolute URI reference Service provider Generate AuthnRequest Mandatory. Core §1.3.2, as read in identifiers. The first configured NameID format is checked with and without producer rules, also when a template receives it in {NameIDFormat}. A raw custom callback writes its own XML and is not checked

Identity provider Response

Rule Actor Direction Level
An error Response carries the caller-supplied status and no assertions Identity provider Generate Response Mandatory prohibition on assertions. Profiles §4.1.4.2, which E26 does not replace: if the identity provider returns an error, it MUST NOT include any assertions. Profiles §4.1.4.1 requires that response when the request cannot be satisfied, including when the requested subject is not recognized. Core §3.4.1.4 requires a Status describing the error when the presenter cannot be authenticated, the requested subject is not recognized, or local policy prevents an assertion. RespondSso::status writes the Status the caller passes. A top-level code other than Success omits assertions. Omitting status emits Success and the assertions. That omission is library policy for the successful path. The caller chooses any subordinate code, such as NoPassive or AuthnFailed. The library does not infer one. A login response template cannot carry this response
Error Response Issuer, InResponseTo, and Destination follow the successful response Identity provider Generate Response The successful-response rows below. Issuer is always present. A solicited InResponseTo matches the AuthnRequest ID (Core §3.2.2). An unsolicited InResponseTo is omitted (Core §3.2.2 and Profiles §4.1.5). Destination is the assertion consumer service URL
HTTP-POST signs an error Response Identity provider Generate Response Library policy. Profiles §4.1.4.5 as replaced by E26 protects each assertion by a signature on the assertion or the Response. An error Response has no assertion, so that requirement does not apply. Typed HTTP-POST still signs the Response, which is how a signed message carries Destination (Bindings §3.5.5.2). HTTP-POST-SimpleSign keeps its detached signature over the response octets
A successful response contains at least one bearer assertion with an AuthnStatement Identity provider Generate Response Mandatory. Profiles §4.1.4.2 as replaced by Errata 05 E26, including a response that is not tied to a request. Enforced when producer rules are selected. Samlify-port generation still omits the statement, and receivers are not given a new rejection for that omission
AuthnInstant and AuthnContext accompany that statement Identity provider Generate Response Mandatory schema children of AuthnStatement (Core §2.7.2) once the statement is emitted. Core §2.7.2 defines AuthnInstant as the time at which the authentication took place. RespondSso::authn_instant and RespondPaosSso::authn_instant write the time the caller passes, such as the start of a reused identity provider session. The library formats it in UTC to the second, rounded down, so it satisfies Core §1.3.3 and is never a leap second. A value later than the response IssueInstant returns Invalid, which is library policy: an assertion cannot report an authentication after it was issued. A time before year 1 returns Invalid, which is library policy: the formatter writes a four-digit non-negative year. Without the option, AuthnInstant is the assertion IssueInstant, which is library policy. RespondSso::authn_instant without producer rules returns Invalid, as RespondSso::authn_context does. The context is the class or declaration reference passed to RespondSso::authn_context or RespondPaosSso::authn_context. Without one, it is the class urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified, the Authentication Context class for unspecified means. RespondSso::authn_context without producer rules returns Invalid, because no statement is written
With exact comparison, the statement’s authentication context is one of the requested references Identity provider Generate solicited Response Mandatory. Core §3.3.2.2.1: when Comparison is exact or omitted, the resulting context MUST exactly match one of the requested contexts. Enforced when producer rules are selected and by respond_paos_sso. A success response whose context, or the unspecified class when none is set, is not a requested reference of the same kind returns Invalid. For minimum, better, and maximum, strength is “as deemed by the responder”, so the caller judges them and the library does not check. Samlify-port generation writes no AuthnStatement and is not checked
With a requested SPNameQualifier and a §8.3 Format other than unspecified, the assertion NameID carries that SPNameQualifier Identity provider Generate solicited Response Mandatory. Core §3.4.1.1 as amended by Errata 05 E15: when a §8.3 format other than unspecified or encrypted is used and the identity provider returns any assertions, the SPNameQualifier of the <NameID> in each assertion <Subject> MUST be identical to the one in <NameIDPolicy>. Enforced when producer rules are selected and by respond_paos_sso. A success response whose NameId has no SPNameQualifier, or a different one, returns Invalid. The value is an xs:string and is compared without whitespace normalization. The policy Format is compared after xs:anyURI whitespace collapsing. An error Response carries no assertion and is not checked. Whether the identity provider can serve the requested namespace, such as an affiliation the requester belongs to, is the caller’s decision, and an error Response may carry InvalidNameIDPolicy (Core §3.4.1.1). The E15 rule that the NameID Format equals the policy Format is not checked. Samlify-port generation is not checked
With a requested Subject that has an identifier, the assertion Subject strongly matches it Identity provider Generate solicited Response Mandatory. Core §3.4.1.4 as amended by Errata 05 E75: the resulting assertions’ <Subject> MUST strongly match the request <Subject> (Core §3.3.4), except that the identifier MAY be in a different format if specified by <NameIDPolicy>, and an identity provider that cannot or will not produce such assertions MUST return an error <Status>. Profiles §4.1.4.1 requires an error response with no assertions when the identity provider does not recognize the principal as the requested identity. Enforced when producer rules are selected and by respond_paos_sso. A success response returns Invalid unless the issued NameId has the requested <NameID> value, Format, NameQualifier, SPNameQualifier, and SPProvidedID. An omitted Format is unspecified (Core §2.2.2), and Format is compared after xs:anyURI whitespace collapsing. A NameId whose Format is the NameIDPolicy Format, when that differs from the requested one, is not compared: the caller decides that it names the same principal. A requested <BaseID> cannot be strongly matched by the <NameID> this library issues, so a success response returns Invalid. Library policy: a requested <EncryptedID> that was not decrypted also returns Invalid for a success response, because the identity provider cannot show the match, and the NameIDPolicy format exception is not applied to a requested <BaseID> or an undecrypted <EncryptedID>. A Subject with only <SubjectConfirmation> names the presenter and is not checked. Requested <SubjectConfirmation> elements are not compared; Profiles §4.1.4.1 forbids the service provider from sending them. An error Response carries no assertion and is not checked. Whether the authenticated presenter is the requested principal is the caller’s decision. Samlify-port generation is not checked
NameQualifier, SPNameQualifier, and SPProvidedID of the issued NameId are written on the assertion NameID Identity provider Generate Response Schema NameIDType declares them as optional attributes, of type string for the qualifiers. Each value is written as given, escaped as an attribute value, and omitted when unset, with and without producer rules. A login response template returns Invalid for a NameId that sets one, since the template has no place for it
When no requested context can be met, answer top-level Responder, optionally with NoAuthnContext Identity provider Generate Response Mandatory top-level code, optional subordinate code. Core §3.3.2.2.1 as replaced by Errata 05 E65. The caller decides that the request cannot be met and passes Status::responder() with SubordinateStatusCode::no_authn_context() to RespondSso::status or reject_paos_sso
SessionIndex on each authentication statement when this identity provider supports Single Logout Identity provider Generate Response Mandatory when Single Logout is supported. Profiles §4.1.4.2 / E26. Support here means the identity provider metadata advertises SingleLogoutService. The value is the assertion ID, one of the two approaches Core §2.7.2 lists as RECOMMENDED for privacy. No SessionIndex is emitted when logout is not advertised. Outbound<SsoResponse>::session_index and PaosHttpResponse<SsoResponse>::session_index return the value written, including for an encrypted assertion or an artifact
Bearer SubjectConfirmationData has Recipient and NotOnOrAfter, and no NotBefore Identity provider Generate Response Mandatory. Profiles §4.1.4.2 / E26
Additional SubjectConfirmation elements in a bearer assertion Identity provider Generate Response Optional, not supported. Profiles §4.1.4.2 / E26: bearer assertions MAY contain additional <SubjectConfirmation> elements, and their processing is outside the profile. The assertion carries only the bearer confirmation this library writes. respond_sso, initiate_sso, respond_sso_artifact, initiate_sso_artifact, and respond_paos_sso return SamlError::Unsupported for a Subject with confirmations. The holder-of-key Web Browser SSO profile is not claimed
Assertion NameID Format is omitted or an absolute URI reference Identity provider Generate Response Mandatory. Core §1.3.2 requires a URI reference value to have at least one non-whitespace character and to be absolute, as read in identifiers. A NameId format or configured format that is not one is SamlError::Invalid. Core §2.2.2 with Errata 05 E60 makes Format optional and puts unspecified in effect when it is omitted. A NameId without a format is written with the first configured NameID format. With none configured, Format is omitted. In a login response template, an attribute whose complete value is {NameIDFormat} is omitted the same way. Samlify-port generation follows the same rule. This is a producer rule: an inbound empty Format is not rejected
Bearer assertion Issuer is the responding identity provider, with Format omitted or entity Identity provider Generate Response Mandatory. Profiles §4.1.4.2 / E26
Bearer assertion includes AudienceRestriction for the service provider Identity provider Generate Response Mandatory. Profiles §4.1.4.2 / E26
Response Issuer is present when the response is signed or an assertion is encrypted Identity provider Generate Response Mandatory when that condition holds. Errata 05 E17. Typed responses always include it
Solicited response InResponseTo matches the AuthnRequest ID Identity provider Generate Response Mandatory. Core §3.2.2. The same match is required on bearer SubjectConfirmationData by Profiles §4.1.4.2 / E26
Unsolicited response omits InResponseTo Identity provider Generate Response Mandatory prohibition. Core §3.2.2 and Profiles §4.1.5. Bearer subject confirmation data omits it as well: Profiles §4.1.5 says it should not be present, and E26 requires the service provider to verify that it is absent. Samlify-port generation and login response templates omit it too
A request without an ACS URL, ACS index, or ProtocolBinding uses the metadata default AssertionConsumerService Identity provider Generate solicited Response Mandatory. Core §3.4.1; Profiles §4.1.4.1 and §4.1.6. Metadata §§2.2.3, 2.4.1 and E37 scope the default to the SP role advertising SAML 2.0 in protocolSupportEnumeration, before binding filtering. An unsupported default or incompatible response binding returns Invalid
Apply the indexed-default algorithm to ACS candidates Metadata consumer Endpoint selection Metadata §2.2.3. The default is the first isDefault true, otherwise the first not explicitly false, otherwise the first. The unqualified XML Schema boolean accepts true, 1, false, and 0 with surrounding XML whitespace. Foreign attributes do not set the flag
Read WantAuthnRequestsSigned, AuthnRequestsSigned, and WantAssertionsSigned as XML Schema booleans Metadata consumer Generate AuthnRequest or Response, receive AuthnRequest Mandatory. The metadata schema types each attribute boolean, and Metadata §§2.4.3 and 2.4.4 read an omitted one as false. true and 1 are true, and false and 0 are false, with surrounding XML whitespace. Another value is read as false
Deliver an unsolicited response to the metadata default AssertionConsumerService Identity provider Generate unsolicited Response Recommendation. Profiles §4.1.5. Typed initiate_sso and initiate_sso_artifact use the global default above. An unsupported default or incompatible response binding returns Invalid. There is no recommendation relaxation in this API
Select an ACS when generating an explicit ACS URL, or when the request specifies a response binding Service provider or identity provider Generate AuthnRequest or Response Library selection policy. The binding-specific helper applies the indexed-default algorithm to that binding’s candidates. start_sso emits the chosen URL and ProtocolBinding, so the request explicitly identifies its endpoint. Raw binding-specific metadata access remains a lower-level lookup
HTTP-POST protects each assertion by a signature on the assertion or on the response Identity provider Generate Response Mandatory for HTTP-POST. Profiles §4.1.4.5 as replaced by E26, and §4.1.3.5 as replaced by E93. Existing typed POST signing already does this
Sign a response that contains a CBC EncryptedAssertion Identity provider Generate Response Recommendation. Errata 05 E93. Starts enabled on RespondSso::post, RespondSso::simple_sign, and RespondSso::artifact. RespondSso::allow_unsigned_encrypted_cbc relaxes that recommendation alone. It is not the Compatibility preset. It does not add a receiver rejection; a relying party that already requires the signature still rejects the relaxed response
Assertion encryption Identity provider Generate Response Optional. Stays off unless XmlEncryptionPolicy::encrypt_assertions
<EncryptedID> in place of the assertion <NameID> Identity provider Generate Response Optional. Core §2.2.4. Stays off unless XmlEncryptionPolicy::encrypt_ids, which does not select attribute or assertion encryption. Each <NameID> of an assertion <Subject> is replaced in the same location (Core §6.1). A LogoutRequest <NameID> is encrypted only when StartSlo::identifier_encryption selects it, in Single Logout
<EncryptedAttribute> in place of each assertion <Attribute> Identity provider Generate Response Optional. Core §2.7.3.2. Stays off unless XmlEncryptionPolicy::encrypt_attributes, which does not select identifier or assertion encryption. Each <Attribute> of each <AttributeStatement> is replaced in the same location (Core §6.1)
EncryptedData carries Type, its value is http://www.w3.org/2001/04/xmlenc#Element, and its content is the element it replaces Identity provider Generate <EncryptedID> or <EncryptedAttribute> Core §§2.2.4, 2.7.3.2, and 6.1. A present Type is a recommendation, on, with no relaxation: Type is always written. Its value, and content of NameIDType or AttributeType, are mandatory. The plaintext is the inclusive canonical form of the <NameID> or <Attribute>, so it declares every namespace in scope. That serialization is library policy. The key is the service provider’s metadata encryption certificate, as for EncryptedAssertion
Encrypt the <NameID> or <Attribute> before the assertion or response is signed Identity provider Generate Response Library policy. Original Core §6.2 required this order, and Errata 05 E43 and E93 replace that section. The signature is calculated after encryption, so it covers the ciphertext. When encrypt_assertions is also selected, the signed assertion that carries the encrypted elements is then encrypted
<xenc:EncryptedKey> is in the ds:KeyInfo of EncryptedData Identity provider Generate <EncryptedID> or <EncryptedAttribute> Core §6.2 as replaced by Errata 05 E43 allows an encrypted key embedded in EncryptedData. No sibling EncryptedKey is written, so the Core §2.2.4 and §2.7.3.2 Recipient recommendation for those children does not apply. The key placement is the one EncryptedAssertion uses
Do not generate a leap-second time Identity provider Generate any instant Mandatory. Core §1.3.3
RelayState does not exceed 80 bytes Identity provider Generate Response Mandatory prohibition for a value the identity provider sets with RespondSso::relay_state, including on initiate_sso. Bindings §3.5.3 and HTTP-POST-SimpleSign CD-04 §2.3. A value received with the AuthnRequest is returned unchanged even when longer, because Bindings §3.4.3, §3.5.3, and HTTP-POST-SimpleSign CD-04 §2.3 require the responder to return the exact data it received
HTTP-POST-SimpleSign signs the raw XML octets, then RelayState when present, then SigAlg Identity provider Generate Response Mandatory when that binding is used. CD-04 §2.5 and §2.6. An assertion signature stays

Direct Assertion signatures and the RSA-SHA2 XML signature profile are library hardening on acceptance. They are not turned on by these producer rules.