The other with the configuration settings of the IdP; in this case, Azure (Microsoft Entra ID).
Getting ready
Go to the service configuration (Sanity)
Go to Sanity Manage and select the organization you want to enable SSO for your organization.
To navigate to the service provider configuration inside Sanity Manage:
In the organization you intend to add SSO to, go to Settings → SAML SSO.
If no SAML SSO provider exists, click Open SAML SSO configuration and proceed to create and configure a SAML SSO provider.
Go to the service configuration (Azure/Entra ID)
To navigate to the identity provider configuration in Azure:
Log into Azure.
Go to Azure Active Directory.
On the sidebar, go to Enterprise applications.
In Azure, go to Services, and then select Azure Active Directory.
On the sidebar, select Enterprise applications.
In Enterprise applications:
Select an existing SAML application or create a new enterprise application. If you create a new application, you can also integrate any other applications not available in the gallery.
Go to Set up single sign on, and then choose the SAML sign-on method to use.
Set up single sign-on.
Choose the SAML single sign-on method to use.
If you're keeping two browser tabs or windows open side by side, now you should have one on the configuration screen inside Sanity Manage, and the other on the configuration screen in Azure.
Configuring the Azure IdP
Basic SAML Configuration
In Azure, edit the Basic SAML Configuration form.
Add an Identifier (Entity ID) to the basic SAML configuration.
Identifier (Entity ID) -> Sanity entity ID in Sanity Manage.
Add a Reply URL (Assertion Consumer Service URL).
Reply URL (Assertion Consumer Service URL) -> Sanity callback URL in Sanity Manage.
Click Save.
Edit the Basic SAML Configuration form.
The Entity ID in Azure corresponds to the Sanity entity ID inside Sanity Manage.
The Reply URL (Assertion Consumer Service URL) in Azure corresponds to the Sanity callback URL inside Sanity Manage.
Attributes & Claims
Required Claim
In Azure, edit the Attributes & Claims form.
Edit the Unique User Identifier (Name ID) claim, and change the Name identifier format to Persistent.
Click Save.
Edit the Unique User Identifier (Name ID) claim.
Change the Name identifier format to Persistent.
Additional Claims
Now, configure Azure to send the claims that Sanity requires in the expected form. The claims (attributes) that Sanity expects are listed inside Sanity Manage:
Inside Sanity Manage you can view the claims (attributes) that Sanity requires from Azure.
For each claim:
Ensure the claim Name matches the attribute name in the table above.
Ensure the Namespace is deleted.
Ensure the Name format is set to Unspecified.
Ensure the Source attribute is mapped correctly. This varies, and it depends on the specific Azure Active Directory configuration.
In the form, set the appropriate values for each claim.
Once all claims have been added:
The mapping of Azure claims and the corresponding Sanity attributes.
Sanity requires user.firstName and user.surname. The mapping in the example replaces both fields with user.displayname.
Group Claims
Enterprise customers can map user identity provider roles to service provider roles. For example, users with an Azure example-azure-user-role role are mapped to the Sanity viewer role when they log in.
To support the mapping functionality, you must configure the identity provider to send the groups of the user.
To do so, Sanity Manage expects a groups claim with the format set to unspecified.
Gotcha
Note: with Azure/Entra ID, you will be sending the Group ID and not the name of the group in your IdP. If you send the name, you may not see your role mappings correctly when logging into Sanity
Inside Sanity Manage, set Name to groups and Format to unspecified.
In Azure, add a new group claim:
In Azure, select + Add a group claim.
Select the groups that you want Azure to send to Sanity, and assign the group claim a descriptive name:
In Azure, select the groups used to populate SAML tokens issued to Sanity.
Once you're done, save the changes.
Configuring the Sanity Service Provider
Sign-On URL and Issuer
In Azure, browse to the Set up {application name} block:
In Azure, go to the application setup to get the Azure URLs for login and authentication.
Get the Azure URLs for login and authentication, and add them to the Your Identity Provider details configuration section inside Sanity Manage:
In Your Identity Provider details, set the Azure URLs for login, auth, and logout.
In this scenario:
Azure Login URL maps to Sanity Identity Provider Single Sign-On URL.
Azure Azure AD Identifier maps to Sanity Identity Provider issuer.
InResponseTo
In the SAML specification, InResponseTo is defined as
The ID of a SAML protocol message in response to which an attesting entity can present the assertion.
This setting is identity provider-specific. Azure doesn’t support it. Therefore, ensure that Enable InResponseTo is deselected/disabled.
Enable InresponseTo must be disabled/deselected.
Signed SAML Assertion
The Signed SAML Assertion option notifies the Sanity instance that the identity provider is configured to use the signing certificate found in the Sanity service provider details section.
Example certificate in the Signing certificate section.
This is an optional step configured in Verification certificates:
Verification certificate is an optional step to configure signing certificates with a signed assertion.
Unless you have already uploaded the certificate, leave the Want assertion signed deselected under Signed SAML Assertion.
If no certificate has been uploaded, leave Want assertion signed deselected under Signed SAML Assertion.
Download the certificate as PEM certificate download.
Open the downloaded certificate file with any text editor, and copy-paste the certificate content into Sanity Manage.
Click Edit in SAML Certificates.
Select PEM certificate download.
Paste the certificate body into Sanity Manage.
Save
Ensure you save all changes inside Sanity Manage and in Azure.
Common errors
Receiving a 422 error: {"statusCode":422,"error":"Unprocessable Entity","message":"child \"attributes\" fails because [\"value\" must contain at least one of ...
There is an issue with your claims. All claims are case sensitive and are required. Make sure the type is set to unspecified and that the namespace URI is empty and the name format is 'unspecified'
My users are being assigned the default role and not their group mapped role
Ensure your mappings in Sanity are going off the Group ID within Azure/Entra ID as the ID is sent, not the name.
When I access Sanity from my IdP dashboard, I receive: { "id": "3431pXO", "displayName": "Sanity Support", "email": "sanity@sanity.io", "familyName": "Sanity Support", "givenName": "Sanity", "middleName": null, "imageUrl": null, "provider": "saml-f6a94", "tosAcceptedAt": "2024-11-20T18:51:57.264Z", "createdAt": "2024-11-20T18:51:57.264Z", "updatedAt": "2024-11-20T18:51:57.535Z", "isCurrentUser": true, "providerId": "49jc94jf949930304jkojfciojlj934003490943" }
It does not appear you have set up your default relay state within your IdP, you will need to also configure within your Idp settings. You can follow our guide on setting the default relay state.
Sanity Composable Content Cloud is the headless CMS that gives you (and your team) a content backend to drive websites and applications with modern tooling. It offers a real-time editing environment for content creators that’s easy to configure but designed to be customized with JavaScript and React when needed. With the hosted document store, you query content freely and easily integrate with any framework or data source to distribute and enrich content.
Sanity scales from weekend projects to enterprise needs and is used by companies like Puma, AT&T, Burger King, Tata, and Figma.
Level up Your Edit Modal with Next/Previous Navigation Buttons for Array Items
Streamline your array edit workflow by enabling smooth navigation through array items within the default edit modal. This guide walks you through building a clean, user-friendly solution for your Sanity Studio.
Discover the power of Portable Text with this essential guide. From data structure, serialisation to validation strategies, you'll learn everything you need to harness its potential.