Set up SSO authentication with SAML and Ping Identity
Implement single sign-on for Sanity with Ping Identity SAML
This developer guide was contributed by Tim Naughton (Sanity Support Engineer).
Use this guide alongside the general SAML setup guide to configure single sign-on (SSO) for your Sanity organization using the SAML protocol, with Ping Identity (Cloud) as the identity provider (IdP).
During the setup and configuration process, it's a good idea to keep two windows side by side:
- One with Sanity Manage.
- The other with the configuration settings of your IdP, Ping Identity (Cloud).
Prerequisites
- An organization with a project on the Enterprise plan.
- The Administrator role on your Sanity organization.
- Access to Ping Identity (Cloud) with permission to add and configure applications.
Open the configuration screens
Go to the service configuration (Sanity)
Go to Sanity Manage and select the organization where you want to enable SSO.
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 Configure and proceed to create and configure a SAML SSO provider.
- Optional: Click Download as XML to download Sanity's service provider details. You can import this file into Ping Identity instead of entering each value by hand.
- In Your Identity Provider details, clear Enable InResponseTo. Identity-provider-initiated logins, such as opening Sanity from Ping Identity, never return
InResponseTo. - Optional: In General, select Enable auto update roles on login to re-apply your role mapping rules each time a user logs in with SAML SSO.
Go to the service configuration in Ping Identity
- In Ping Identity, add an app.
- Select SAML, and then click Configure.
- Select import metadata and upload the XML file you downloaded from Sanity Manage, or enter Sanity's service provider details manually. Here are the mappings:
- ACS URLs -> Sanity callback URL
- Entity ID -> Sanity entity ID
Configure Ping Identity
Configure attribute mapping
Configure the attributes that Ping Identity sends to Sanity. Sanity requires email, firstName, and lastName. The id, displayName, and picture attributes are optional. Sanity Manage lists them under Attributes in Sanity's service provider details.
Attribute names are case-sensitive. Each required attribute accepts camelCase or PascalCase (for example, email or Email), but not both and no other casing. If a required attribute is missing or misspelled, the login fails with a 422 error.
Configure groups
Enterprise customers can map user identity provider roles to service provider roles. For example, users with a Ping Identity example-admin-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.
Configure role mapping in Sanity for each project whose roles should follow your Ping Identity groups.
Next, in Ping Identity, go to the Access tab and click the edit (pencil) button.
In the Edit Access panel that opens, select the groups you want to send to Sanity, and click Save.
Finally, on the Attribute Mappings tab, add an attribute named groups (lowercase) and map it to Group Names.
Update the configuration in Sanity
Now that you have set up everything in Ping Identity, upload your certificate and update the configuration in Sanity.
- Download the metadata from Ping Identity and upload it with Upload metadata in Your Identity Provider details, or enter the values manually using these mappings:
- Identity Provider Single Sign-On URL -> Single Signon Service
- Identity Provider issuer -> Issuer ID
- X.509 Certificate -> the signing certificate from your Ping Identity application
Save
Ensure you save all changes inside Sanity Manage and Ping Identity.
Add Ping Identity to your studio code
Add a SAML SSO login option to your studio so that users can log in with Ping Identity. Without it, the studio's login screen doesn't offer Ping Identity. In your Sanity SAML SSO settings, expand SAML SSO login for Sanity Studio, copy the code snippet, and add it to your studio configuration file (sanity.config.ts).
After you add the snippet and deploy your studio, test the login with a Ping Identity user.
Common errors
These errors are specific to Ping Identity. For SSO problems that aren't provider-specific, such as SSO not appearing as a login option in the studio, see the troubleshooting section of Set up single sign-on with SAML.
- Receiving a 422 error:
{"statusCode":422,"error":"Unprocessable Entity","message":"child \"attributes\" fails because [\"value\" must contain at least one of ...- The assertion is missing a required attribute, or sends it with an unsupported casing. Confirm that
email,firstName, andlastNameare all mapped in camelCase or PascalCase, that only one casing of each is sent, and that the assertion includes either anameIDor anidattribute.
- The assertion is missing a required attribute, or sends it with an unsupported casing. Confirm that
- Groups are not being role mapped properly
- Make sure Ping Identity sends the user's groups in an attribute named
groups, mapped to Group Names in your Ping Identity configuration. The attribute name must be lowercase:Groupsisn't recognized.
- Make sure Ping Identity sends the user's groups in an attribute named
- Opening Sanity from your IdP dashboard shows a JSON user object instead of Sanity Manage or your studio:
{ "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" }- Ping Identity has no default relay state, so the identity-provider-initiated login stops at an API response. Set the default relay state in your Ping Identity settings to the login URL from Sanity Manage. For the steps, see the guide on setting the default relay state.
Next steps
With Ping Identity SSO working, these guides cover common follow-up tasks:
- To offer SAML SSO as a login option in your studio, see Configure your studio to use the new SSO provider.
- To refine which Ping Identity groups map to which Sanity roles, see Enable SSO and configure role mapping.
- Removing a user from Ping Identity doesn't remove them from your Sanity organization or projects. To find and remove former users, see Reconcile users against internal systems.



