Developer guides

Set up SSO authentication with SAML and Ping Identity

Implement single sign-on for Sanity with Ping Identity SAML

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.
Loading...
Download XML

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.

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.

Loading...
Go to the access tab and edit

In the Edit Access panel that opens, select the groups you want to send to Sanity, and click Save.

Loading...
Select your groups

Finally, on the Attribute Mappings tab, add an attribute named groups (lowercase) and map it to Group Names.

Loading...
Ensure your groups are being sent

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, and lastName are all mapped in camelCase or PascalCase, that only one casing of each is sent, and that the assertion includes either a nameID or an id attribute.
  • 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: Groups isn't recognized.
  • 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:

Was this page helpful?