# SAML

Use these instructions to set up a SAML SSO provider for Tonic Structural.

## SAML provider configuration

You must configure the following assertions to be sent to Structural from your SAML provider:

* `Email`
* `GivenName`
* `FamilyName`
* `Groups`

For the Assertion Consumer Service (ACS) URL:

* On a self-hosted instance, the value is `https://your-tonic-url/api/sso/samllogin`.
* On Structural Cloud, the value is `https://app.tonic.ai/api/sso/samllogin/<your organization identifier>`. Your organization identifier is displayed on your [**User Settings** view](/app/managing-your-tonic-account.md#user-view-copy-org-id).

Set `Audience` to the value of the Structural environment setting `TONIC_SSO_SAML_ENTITY_ID`.

## Structural configuration - self-hosted

On a self-hosted instance of Structural, in the Structural web server container, set the following [Structural environment settings](/app/admin/environment-variables-setting.md):

* `TONIC_SSO_PROVIDER`: `SAML`
* `TONIC_SSO_SAML_IDP_METADATA_XML_URL`- Set to the URL of your IDP Metadata XML file.\
  \
  If your SSO solution does not offer a URL, you can set `TONIC_SSO_SAML_IDP_METADATA_XML_BASE64` to the Base 64 encoded contents of the IDP Metadata XML file.\
  \
  To encode the contents, run the following command:\
  \
  `cat /path/to/xml/file | base64 -w 0`
* `TONIC_SSO_SAML_ENTITY_ID`: The entity ID to use to send SAML requests from Structural. If this is not set, the entity ID is determined from the IDP metadata. You also use this as the value of **Audience** in the SAML provider configuration.
* `TONIC_SSO_GROUP_FILTER_REGEX`: Identifies the allowed SSO groups for Structural. For details, go to [Synchronizing SSO groups with Structural](/app/admin/tonic-user-access/single-sign-on/sso-limit-groups.md).

## Structural configuration - Structural Cloud

On Structural Cloud, after you [enable SSO](/app/admin/tonic-user-access/single-sign-on/sso-cloud.md#enabling-sso), to configure the connection to SAML:

<figure><img src="/files/iPIO0u5NUhjwCUSPM51C" alt=""><figcaption></figcaption></figure>

1. Click **SAML 2.0**.
2. In the **IDP Metadata** field, provide either:
   * The URL of your IDP Metadata XML file.
   * If your SSO solution does not offer a URL, the Base 64 encoded contents of the IDP Metadata XML file.
3. In the **Entity ID** field, provide the entity ID to use to send SAML requests from Structural. If this is not set, the entity ID is determined from the IDP metadata. This can also be the value of Audience in the SAML provider configuration.
4. Optionally, to enable cross-origin resource sharing (CORS), in the **IDP Origin** field, provide the origin URL of your identity provider.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/admin/tonic-user-access/single-sign-on/saml.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
