SAML
Overview
Security Assertion Markup Language (SAML) 2.0 is an XML-based authentication protocol that enables single sign-on (SSO) between identity providers (IdPs) and service providers (SPs). It allows users to access multiple applications using a single set of credentials by securely exchanging authentication data between systems.
Profiles
Edupass supports key SAML 2.0 specifications, including the Web Browser SSO profile and the Single Logout (SLO) profile. The SSO profile enables users to log in once to access multiple related applications without re-entering credentials, making it the most common SAML flow for web applications. It defines how SAML assertions are exchanged between the IdP and SP to authenticate users. The SLO profile defines the corresponding process for terminating user sessions across the IdP and all related SPs. Both flows are mediated through the user’s web browser.
The following sequence diagrams provide a step-by-step breakdown of the SAML 2.0 Web Browser SSO and SLO flows using HTTP POST binding, where SAML assertions are transmitted via HTML forms. Key steps in these diagrams are elaborated below.
Single sign-on flow
Entra ID’s SAML requests do not strictly follow the standard SAML XML structure. For example, Entra ID places the default XML namespace as urn:oasis:names:tc:SAML:2.0:metadata instead of urn:oasis:names:tc:SAML:2.0:protocol. We will align with Entra ID’s XML format going forward so that integrations remain consistent and easier to maintain.
[1] Generate AuthnRequest
This is the first step of the SP-initiated flow. The Service Provider creates a SAML AuthnRequest message. This is an XML-based request that essentially asks the Identity Provider to authenticate the user and send back an assertion.
- AuthnRequest Signature (Optional): If enabled, Edupass will accept only signed requests. If not enabled, the requester is still verified because Edupass responds only to registered Assertion Consumer Service URLs.
Here is an example of AuthnRequest element generated by the Service Provider.
[2] Redirects to the IdP SAML 2.0 Endpoint
The SAML Web SSO flow begins with the Service Provider redirecting the user to Edupass's SAML 2.0 SSO endpoint to request authentication.
Here is an example of the Service Provider redirecting the user to the Identity Provider for SAML authentication.
[3] SAML Response POST to Service Provider’s ACS endpoint
The SAML Web SSO flow concludes with the Identity Provider posting the authentication response to the Service Provider's Assertion Consumer Service (ACS) endpoint.
Ensure the AssertionConsumerServiceURL matches the RP’s registered ACS endpoint.
Here is an example of a SAML Response POST from the IdP to the Service Provider's ACS endpoint.
SAML Response XML Schema
Here is an example of a SAMLResponse element generated by the Identity Provider after a successful sign-on.
Here is an example of a SAMLResponse element generated by the Identity Provider after an unsuccessful sign-on.
Not all attributes and elements shown in the example SAML messages are listed in the table below. Many of these additional elements and attributes are defined in the official SAML 2.0 specification but do not carry significance in the exchange between Edupass and the SP. They are included in examples for completeness and to remain standards-compliant, but Edupass does not require or process them for normal SSO or SLO flows.
We recommend that SPs enable assertion encryption
To support assertion encryption, SP must provide its SAML encryption certificate during onboarding. This allows Edupass to encrypt the SAML assertion, ensuring that sensitive user attributes (e.g., NRIC, names, email addresses) are protected through persistent, selective confidentiality as defined by XML Encryption. Without assertion encryption, these attributes would appear in plain text within the browser’s POST body and could be exposed to:
- Browser plugins
- Server or proxy logs
- Intermediaries
Encryption details:
- The SAML assertion in the response is encrypted using the SP’s encryption certificate provided during onboarding.
- The
<EncryptedAssertion>element replaces<Assertion>entirely with ciphertext. - The SP must use its private key to decrypt the assertion before validating the signature and processing user attributes.
Example element:
[4] Validate SAML Response
For the authentication response, applications should:
- Ensure the
<Issuer>matches the expected Entra ID entity ID i.e.https://sts.windows.net/{tenant-id}/ - Validate
InResponseTomatches theIDof theAuthnRequestthat was sent. - Validate that the
<Signature>is from Edupass (see Signature Validation). - Validate
<Audience>matches theIssuerin theAuthnRequest. - Validate
<Conditions>(NotBefore,NotOnOrAfter) are current. - Validate
Recipientin<SubjectConfirmationData>matches the ACS URL and is still valid. - Validate assertions are received over TLS.
Signature Validation
Edupass always signs the SAML Response. It is the Service Provider’s (SP’s) responsibility to validate this signature to ensure integrity and authenticity.
To validate the signature:
-
Obtain the public key for Edupass via the federation metadata document endpoint.
This endpoint returns the public keys (taken from the
X509Certificatebelow):Note- As the signing keys will rotate periodically, there could be more than 1 certificate provided during the rollover period. All provided certificates are valid and the SP should support all certificates in the document.
- The SP should refresh the federation metadata at least once every 24 hours to detect newly published or removed signing certificates. The SP should not hard-code or rely on a single signing certificate. During a certificate rollover, the SP should continue to accept the existing signing certificate while also accepting the newly published certificate. This allows the certificate rotation to take place without interrupting SAML authentication.
-
The
SAMLResponsecontains the key used to generate the signature, inAssertion→Signature→KeyInfo→X509Data→X509Certificate. Check that this key exists in the metadata document in (1). -
Verify the signature provided, with the key in (2). This can be found in
Assertion→Signature→SignatureValue.
Single Logout flow
For consistency and session integrity, the Service Provider must trigger Microsoft Entra ID’s Single Logout flow to properly terminate the user’s session across all federated applications. The Service Provider should not perform logout locally within the application without calling Edupass SLO endpoint.
[1] Generate Logout Request
The Service Provider creates a LogoutRequest message. This is an XML-based request that asks the Identity Provider to log the user out from all SPs in the session. Here is an example of LogoutRequest element generated by the Service Provider.
[2] Redirects to the SAML 2.0 Single Sign-out URL
The SAML Single Logout (SLO) flow begins with the Service Provider redirecting the user to the Identity Provider’s SAML 2.0 logout endpoint to terminate the user’s session.
Here is an example of the Service Provider redirecting the user to Microsoft Entra ID for SAML logout.
[3] Send LogoutResponse to the Logout URL
Microsoft Entra ID sends a LogoutResponse in reply to a LogoutRequest, and the browser forwards this response via an HTTP GET to the SP’s SAML logout endpoint. Here is an example of such a request.
The following shows a sample LogoutResponse XML message.
References
- https://wiki.oasis-open.org/security/FrontPage#SAML_V2.0_Standard
- https://learn.microsoft.com/en-us/entra/identity-platform/single-sign-on-saml-protocol
- https://learn.microsoft.com/en-us/entra/identity-platform/single-sign-out-saml-protocol
- https://learn.microsoft.com/en-us/entra/identity-platform/reference-saml-tokens