> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# 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

![SAML 2.0 single sign-on sequence](/static/svg/saml-single-sign-on.drawio.e1ac4ed125.svg)

:::info

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.

:::info

- 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.

```xml
<samlp:AuthnRequest
  xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
  ID="_b93fbda9e4c749eeb3c7e9adbe2c8884"
  Version="2.0"
  IssueInstant="2013-03-18T03:28:54.1839884Z"
  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">your-app-entity-id</Issuer>
  <NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" />
</samlp:AuthnRequest>
```

| **Name**                      | **Type**  | **Required?**   | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ----------------------------- | --------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ID`                          | Attribute | Required        | Edupass uses this attribute to populate the `InResponseTo` attribute of the returned response. ID must not begin with a number, so a common strategy is to prepend a string like "ID" to the string representation of a GUID.                                                                                                                                                                                                                   |
| `Version`                     | Attribute | Required        | This attribute should be set to `2.0`.                                                                                                                                                                                                                                                                                                                                                                                                          |
| `IssueInstant`                | Attribute | Required        | This is a DateTime string with a UTC value and [round-trip format ("o")](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).                                                                                                                                                                                                                                                                   |
| `Issuer`                      | Element   | Required        | This element uniquely identifies your SP (the “Entity ID”), it must match the SP entity ID declared in the submitted onboarding form.                                                                                                                                                                                                                                                                                                           |
| `NameIDPolicy`                | Element   | Required        | The `Format` attribute of this element should be explicitly set to `urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified`. This ensures that the `<NameID>` value in the `<Subject>` element corresponds to the user’s Edupass Identifier.<br>If the `Format` attribute is set to any other value, the correctness of the `<NameID>` value cannot be relied on, as Edupass does not guarantee its immutability or consistency across sessions. |
| `AssertionConsumerServiceURL` | Attribute | Optional        | The SP endpoint where Edupass should POST the SAML Response.                                                                                                                                                                                                                                                                                                                                                                                    |
| `IsPassive`                   | Attribute | Optional        | This is a boolean value that specifies whether Edupass should authenticate the user silently, without user interaction, using the session cookie if one exists. If this is true, Edupass attempts to authenticate the user using the session cookie.                                                                                                                                                                                            |
| `ForceAuthn`                  | Attribute | Not Recommended | This is a boolean value, if true, forces the user to re-authenticate even with a valid Edupass session, preventing single sign-on login to the SP.                                                                                                                                                                                                                                                                                              |

#### \[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.

```
HTTP/1.1 302 Found
Location: https://login.microsoftonline.com/{tenant}/saml2?SAMLRequest={saml-request}&RelayState={relay-state}
```

| **Parameter** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tenant`      | The ID of the Edupass Entra ID tenant.<br>- Preprod: `97f42547-72fd-4d98-b89a-e39375923893`<br>- Prod: `342e7f12-abca-4f63-9a52-ce093487bbc1`                                                                                                                                                                                                                                                                                                                                                           |
| `SAMLRequest` | Base64-encoded deflated `AuthnRequest` XML message.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `RelayState`  | A `RelayState` parameter should be included in the SAML authentication request. Edupass returns this value unchanged in the HTTP POST containing the SAML Response. The specific `RelayState` value is up to the SP but must not exceed 80 bytes in length. This value should be used to encode the CSRF token, a secret and unpredictable value. The SP should validate that the CSRF token returned in the `RelayState` is the same as the value set in the original request to prevent CSRF attacks. |

#### \[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.

:::info

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.

```
POST /saml/acs HTTP/1.1
Host: my-app.example.com
Content-Type: application/x-www-form-urlencoded

SAMLResponse=<saml-response>&RelayState={relay-state}
```

| **Parameter**  | **Description**                                                                                                                        |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `SAMLResponse` | Base64-encoded deflated `Response` XML message.                                                                                        |
| `RelayState`   | Ensure this is the same as the value sent in [\[2\] Redirects to the IdP SAML 2.0 Endpoint](#2-redirects-to-the-idp-saml-20-endpoint). |

##### SAML `Response` XML Schema

Here is an example of a `SAMLResponse` element generated by the Identity Provider after a successful sign-on.

```xml
<samlp:Response
    ID="_response123456"
    Version="2.0"
    IssueInstant="2026-03-02T06:00:00Z"
    Destination="https://my-app.example.com/saml/acs"
    InResponseTo="_b93fbda9e4c749eeb3c7e9adbe2c8884"
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">

    <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
      https://sts.windows.net/2aef017b-0afb-47d9-a1ab-23148b712d37/
    </Issuer>

    <samlp:Status>
        <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
    </samlp:Status>

    <Assertion
        ID="_assertion789"
        IssueInstant="2026-03-02T06:00:00Z"
        Version="2.0"
        xmlns="urn:oasis:names:tc:SAML:2.0:assertion">

        <Issuer>https://sts.windows.net/2aef017b-0afb-47d9-a1ab-23148b712d37/</Issuer>

        <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
            <SignedInfo>
                <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                <Reference URI="#_assertion789">
                    <Transforms>
                        <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                        <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    </Transforms>
                    <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                    <DigestValue>VZe2PbhLThUOUO6ab7DEzUN7b/8cGCUhYUtlpkcYE6I=</DigestValue>
                </Reference>
            </SignedInfo>
            <SignatureValue>
                eERraF/LqY0F7pk/wuuaFYY7B9ufFNt1Cedu51TbjbBW1w2ex0TAfGPi...
            </SignatureValue>
            <KeyInfo>
                <X509Data>
                    <X509Certificate>
                        MIIC8DCCAdigAwIBAgIQQRJvakygo6BEm7tqQX7y6TANBgkqhkiG9w0B...
                    </X509Certificate>
                </X509Data>
            </KeyInfo>
        </Signature>

        <Subject>
            <NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">
                000012345678
            </NameID>
            <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                <SubjectConfirmationData
                    InResponseTo="_b93fbda9e4c749eeb3c7e9adbe2c8884"
                    NotOnOrAfter="2026-03-02T06:10:00Z"
                    Recipient="https://my-app.example.com/saml/acs"/>
            </SubjectConfirmation>
        </Subject>

        <Conditions NotBefore="2026-03-02T06:00:00Z"
                    NotOnOrAfter="2026-03-02T07:00:00Z">
            <AudienceRestriction>
                <Audience>https://my-app.example.com/saml/metadata</Audience>
            </AudienceRestriction>
        </Conditions>

        <AttributeStatement>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/id">
                <AttributeValue>000012345678</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/identitytype">
                <AttributeValue>Staff</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/name">
                <AttributeValue>John Tan</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/uinfin">
                <AttributeValue>S0000001I</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/schoolorhq">
                <AttributeValue>School</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/title">
                <AttributeValue>Teacher</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/notificationemail">
                <AttributeValue>john_tan@schools.gov.sg</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/wogemail">
                <AttributeValue>john_tan@moe.gov.sg</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/cesemail">
                <AttributeValue>john_tan@schools.gov.sg</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/iconemail">
                <AttributeValue>john_tan@moe.edu.sg</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.edupass.moe.gov.sg/identity/claims/identitysource">
                <AttributeValue>HRPS</AttributeValue>
            </Attribute>

            <Attribute Name="http://schemas.microsoft.com/ws/2008/06/identity/claims/groups">
                <AttributeValue>1730_AE_admin</AttributeValue>
                <AttributeValue>1731_AE_user</AttributeValue>
            </Attribute>

        </AttributeStatement>

        <AuthnStatement AuthnInstant="2026-03-02T06:00:00Z"
                        SessionIndex="00220eda-823e-0889-c17e-3c68acc55b82">
            <AuthnContext>
                <AuthnContextClassRef>
                    urn:oasis:names:tc:SAML:2.0:ac:classes:Unspecified
                </AuthnContextClassRef>
            </AuthnContext>
        </AuthnStatement>

    </Assertion>
</samlp:Response>
```

Here is an example of a `SAMLResponse` element generated by the Identity Provider after an unsuccessful sign-on.

```xml
<samlp:Response

    ID="_response123456"
    Version="2.0"
    IssueInstant="2025-11-11T12:30:00Z"
    Destination="https://my-app.example.com/saml/acs"
    InResponseTo="_b93fbda9e4c749eeb3c7e9adbe2c8884"
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">

    <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
      https://sts.windows.net/{TenantGUID}/
    </Issuer>

    <samlp:Status>
        <samlp:StatusCode
            Value="urn:oasis:names:tc:SAML:2.0:status:Responder">
            <samlp:StatusCode
                Value="urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"/>
        </samlp:StatusCode>
        <samlp:StatusMessage>
            Authentication failed: invalid username or password.
        </samlp:StatusMessage>
    </samlp:Status>
</samlp:Response>
```

:::note

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.

:::

| **Name**                                                                             | **Type**  | **Description**                                                                                                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Destination`                                                                        | Attribute | When sign on completes successfully, this is set to the `RedirectUri` of the service provider (cloud service).                                                                                                                                                                                                                   |
| `InResponseTo`                                                                       | Attribute | This is set to the `ID` attribute of the `<AuthnRequest>` element that initiated the response.                                                                                                                                                                                                                                   |
| `Issuer`<br>_(Same applies to the element under_ `<Response>` _and_ `<Assertion>`_)_ | Element   | This is set to `https://sts.windows.net/{TenantIDGUID}/` or `https://login.microsoftonline.com/<TenantIdGUID>/` where `{TenantIDGUID}` is the tenant ID of the Edupass Entra ID tenant. The tenant IDs are respectively:<br>- Pre-prod: `97f42547-72fd-4d98-b89a-e39375923893`<br>- Prod: `342e7f12-abca-4f63-9a52-ce093487bbc1` |
| `StatusCode`                                                                         | Element   | It contains a code or a set of nested codes that represents the status of the request.                                                                                                                                                                                                                                           |
| `StatusMessage`                                                                      | Element   | It contains custom error messages that are generated during the sign-on process.                                                                                                                                                                                                                                                 |
| `Signature`                                                                          | Element   | Contains a digital signature that the cloud service can use to authenticate the source to verify the integrity of the assertion. See [below](#signature-validation) for more info.                                                                                                                                               |
| `Subject`                                                                            | Element   | It contains a `<NameID>` element, the value of which corresponds to the `NameIDPolicy` that was set in the [AuthnRequest](#1-generate-authnrequest).                                                                                                                                                                             |
| `Conditions`                                                                         | Element   | The `NotBefore` and `NotOnOrAfter` attributes specify the interval during which the assertion is valid.                                                                                                                                                                                                                          |
| `Audience`                                                                           | Element   | This is set to the value of `<Issuer>` element of the `AuthnRequest` that initiated the sign-on.                                                                                                                                                                                                                                 |
| `AttributeStatement`                                                                 | Element   | This contains claims about the subject or user, see [User Schema section](/specs/index.md#user-schema) for reference.<br>The attribute names will follow the format of `http://schemas.edupass.moe.gov.sg/identity/claims/<claimname>`                                                                                           |
| `AuthnStatement`                                                                     | Element   | This asserts that the assertion subject was authenticated by a particular means at a particular time.<br>- The `AuthnInstant` attribute specifies the time at which the user authenticated with Microsoft Entra ID.<br>- The `<AuthnContext>` element specifies the authentication context used to authenticate the user.        |

:::info

**We recommend that SPs enable <u>assertion encryption</u>**

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:**

```xml
<EncryptedAssertion>
    <xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element">
        ...
    </xenc:EncryptedData>
</EncryptedAssertion>
```

:::

#### \[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 `InResponseTo` matches the `ID` of the `AuthnRequest` that was sent.
- Validate that the `<Signature>` is from Edupass (see [Signature Validation](#signature-validation)).
- Validate `<Audience>` matches the `Issuer` in the `AuthnRequest`.
- Validate `<Conditions>` (`NotBefore`, `NotOnOrAfter`) are current.
- Validate `Recipient` in `<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:

1. Obtain the public key for Edupass via the federation metadata document [endpoint](https://learn.microsoft.com/en-us/entra/identity-platform/federation-metadata).

   ```
   https://login.microsoftonline.com/<TENANT-ID>/federationmetadata/2007-06/federationmetadata.xml
   ```

   This endpoint returns the public keys (taken from the `X509Certificate` below):

   ```
   <KeyDescriptor use="signing">
     <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
       <X509Data>
         <X509Certificate>
           MIIC8DCCAdigAwIBAgIQQRJvakygo6BEm7tqQX7y6TANBgkqhkiG9w0B...
         </X509Certificate>
       </X509Data>
     </KeyInfo>
   </KeyDescriptor>
   ```

   :::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.

   :::

2. The `SAMLResponse` [contains](#saml-response-xml-schema) the key used to generate the signature, in `Assertion` → `Signature` → `KeyInfo` → `X509Data` → `X509Certificate`. Check that this key exists in the metadata document in (1).

   ```
   <KeyInfo>
       <X509Data>
           <X509Certificate>
               MIIC8DCCAdigAwIBAgIQQRJvakygo6BEm7tqQX7y6TANBgkqhkiG9w0B...
           </X509Certificate>
       </X509Data>
   </KeyInfo>
   ```

3. Verify the signature provided, with the key in (2). This can be found in `Assertion` → `Signature` → `SignatureValue`.

   ```xml
   <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
       ...
       <SignatureValue>
           eERraF/LqY0F7pk/wuuaFYY7B9ufFNt1Cedu51TbjbBW1w2ex0TAfGPi...
       </SignatureValue>
   ```

### Single Logout flow

![SAML 2.0 single logout sequence](/static/svg/saml-single-logout.drawio.f0027473db.svg)

:::note

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.

```xml
<samlp:LogoutRequest xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
  ID="idaa6ebe6839094fe4abc4ebd5281ec780"
  Version="2.0"
  IssueInstant="2013-03-28T07:10:49.6004822Z"
  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">your-app-entity-id</Issuer>
  <NameID xmlns="urn:oasis:names:tc:SAML:2.0:assertion">000012345678</NameID>
</samlp:LogoutRequest>
```

| **Name**       | **Type**  | **Required?** | **Description**                                                                                                                                                                                                                          |
| -------------- | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ID`           | Attribute | Required      | Microsoft Entra ID uses this attribute to populate the `InResponseTo` attribute of the returned response. ID must not begin with a number, so a common strategy is to prepend a string like "ID" to the string representation of a GUID. |
| `Version`      | Attribute | Required      | This parameter should be set to `2.0`.                                                                                                                                                                                                   |
| `IssueInstant` | Attribute | Required      | This is a DateTime string with a UTC value and [round-trip format ("o")](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).                                                            |
| `Issuer`       | Element   | Required      | Uniquely identifies your SP (the “Entity ID”), it must match the SP entity ID declared in the onboarding metadata submitted.                                                                                                             |
| `NameID`       | Element   | Required      | This should exactly match the `NameID` of the user that is being signed out.                                                                                                                                                             |

#### \[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.

```
HTTP/1.1 302 Found
Location: https://login.microsoftonline.com/{tenant}/saml2?SAMLRequest={saml-logout-request}&RelayState={relay-state}
```

| **Parameter** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tenant`      | The ID of the Edupass Entra ID tenant.<br>- [Preprod](https://login.microsoftonline.com/97f42547-72fd-4d98-b89a-e39375923893/FederationMetadata/2007-06/FederationMetadata.xml): `97f42547-72fd-4d98-b89a-e39375923893`<br>- [Prod](https://login.microsoftonline.com/342e7f12-abca-4f63-9a52-ce093487bbc1/FederationMetadata/2007-06/FederationMetadata.xml): `342e7f12-abca-4f63-9a52-ce093487bbc1`                                                                                          |
| `SAMLRequest` | Base64-encoded deflated `LogoutRequest` XML message.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `RelayState`  | A `RelayState` parameter should be included in the SAML logout request. Edupass returns this value unchanged in the HTTP GET containing the SAML Response. The specific `RelayState` value is up to the SP but must not exceed 80 bytes in length. This value should be used to encode the CSRF token, a secret and unpredictable value. The SP should validate that the CSRF token returned in the `RelayState` is the same as the value set in the original request to prevent CSRF attacks. |

#### \[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.

```
GET /saml/logout?SAMLResponse=<saml-logout-response>&RelayState={relay-state} HTTP/1.1
Host: my-app.example.com
```

| **Parameter**  | **Description**                                                                                                                                      |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SAMLResponse` | Base64-encoded deflated `LogoutResponse` XML message.                                                                                                |
| `RelayState`   | Ensure this is the same as the value sent in [\[2\] Redirects to the SAML 2.0 Single Sign-out URL](#2-redirects-to-the-saml-20-single-sign-out-url). |

The following shows a sample `LogoutResponse` XML message.

```xml
<samlp:LogoutResponse ID="_f0961a83-d071-4be5-a18c-9ae7b22987a4"
  Version="2.0"
  IssueInstant="2013-03-18T08:49:24.405Z"
  InResponseTo="idaa6ebe6839094fe4abc4ebd5281ec780"
  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://sts.windows.net/{TenantIDGUID}/</Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
</samlp:LogoutResponse>
```

| **Name**       | **Type**  | **Description**                                                                                                                                                                                                                                                                               |
| -------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Version`      | Attribute | This parameter should be set to `2.0`.                                                                                                                                                                                                                                                        |
| `IssueInstant` | Attribute | This is a DateTime string with a UTC value and [round-trip format ("o")](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).                                                                                                                 |
| `InResponseTo` | Attribute | This is set to the `ID` attribute of the `<LogoutRequest>` element that initiated the response.                                                                                                                                                                                               |
| `Issuer`       | Element   | This is set to `https://sts.windows.net/{TenantIDGUID}/` or `https://login.microsoftonline.com/<TenantIdGUID>/` where `{TenantIDGUID}` is the tenant ID of the Microsoft Entra tenant.<br>- Preprod: `97f42547-72fd-4d98-b89a-e39375923893`<br>- Prod: `342e7f12-abca-4f63-9a52-ce093487bbc1` |
| `StatusCode`   | Element   | It contains a code or a set of nested codes that represents the status of the request.                                                                                                                                                                                                        |

## References

- [https://wiki.oasis-open.org/security/FrontPage#SAML_V2.0_Standard](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-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/single-sign-out-saml-protocol)
- [https://learn.microsoft.com/en-us/entra/identity-platform/reference-saml-tokens](https://learn.microsoft.com/en-us/entra/identity-platform/reference-saml-tokens)
