# 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](https://docs.tonic.ai/app/managing-your-tonic-account#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](https://docs.tonic.ai/app/admin/environment-variables-setting):

* `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 [sso-limit-groups](https://docs.tonic.ai/app/admin/tonic-user-access/single-sign-on/sso-limit-groups "mention").

## Structural configuration - Structural Cloud

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

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FmgpXxA4JV97vZZlQ2bR1%2FCloudSSOEnabledSAML.png?alt=media&#x26;token=5468f4c1-ad90-44a3-b629-c785888f7a40" 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.
