TrustBuilder Safe-T

Salesforce

This page explains how to use connect Salesforce to TrustBuilder.

SAML integration

This guide explains how to configure Single Sign-On (SSO) between Salesforce, acting as the Service Provider (SP), and TrustBuilder, acting as the Identity Provider (IdP), using SAML 2.0.

Prerequisites

  • A TrustBuilder tenant with users who have an email address and a valid authentication method.

  • Administrator access to the TrustBuilder administration console.

  • A Salesforce tenant with My Domain deployed, and System Administrator access to Salesforce Setup. For testing, you can use a developer Salesforce tenant: https://www.salesforce.com/form/developer-signup/

  • The Salesforce username of each user must match the user's email address in TrustBuilder.

Configuring an application in TrustBuilder

  1. Log in to TrustBuilder administration portal.

  2. Go to Integrations > Applications > + Set up app integration.

  3. Select SAML.

  4. Configure the application:

    • Name: enter a meaningful name, for example Salesforce.

    • Subject Management: select email.

    • Policies: select the authorization policy that applies to this application.

  5. For SP metadata configuration, select Provide SP metadata later. Salesforce metadata will be imported later in this procedure.

  6. Click Create.

  7. Go to the IdP Metadata tab:

    capture_261125_163104.png
    1. copy the IdP Metadata URL. You will need it in Salesforce.

    2. download the TrustBuilder signing certificate (.pem file). You will need to upload it in Salesforce.

Configuring Single Sign-On in Salesforce

  1. Log in to your Salesforce organization and go to Setup.

  2. In the Quick Find box, search for Single Sign-On Settings (Identity > Single Sign-On Settings).

  3. Click New from Metadata URL, paste the TrustBuilder IdP Metadata URL, then click Create.
    Most fields are pre-filled with the values of the TrustBuilder metadata.

  4. Review and update the following fields:

Field

Value

Name

Enter a meaningful name, for example TrustBuilder Safe-T.
This name is displayed on the Salesforce login page (Log in with TrustBuilder Safe-T).

Identity Provider Certificate

Click Choose File and upload the TrustBuilder signing certificate (.pem) downloaded previously.

Request Signing Certificate

Select your Salesforce self-signed certificate.

Request Signature Method

RSA-SHA256

Assertion Decryption Certificate

Assertion not encrypted

SAML Identity Type

Assertion contains the User's Salesforce username

SAML Identity Location

Identity is in the NameIdentifier element of the Subject statement

Service Provider Initiated Request Binding

HTTP POST

Identity Provider Login URL

TrustBuilder SSO URL, ending with /sso
Example: https://api.trustbuilder.io/api/v1/sso/saml2/{application_id}/sso

Single Logout Enabled

Checked

Use Selected Request Signature Method for Single Logout

Checked

Identity Provider Single Logout URL

TrustBuilder SLO URL, ending with /slo
Example: https://api.trustbuilder.io/api/v1/sso/saml2/{application_id}/slo

Single Logout Request Binding

HTTP POST

The warnings The metadata file specifies multiple bindings can be ignored as long as HTTP POST is selected.

  1. Click Save.

  2. Click the name of the Single Sign-On configuration you just created, then click Download Metadata. Keep the Salesforce metadata XML file for the next step.

Finalizing the application in TrustBuilder

  1. In TrustBuilder administration portal, open the SAML application created previously.

  2. Go to the SP Metadata tab

  3. Click Import XML.

  4. Upload the Salesforce metadata file.
    The Entity ID, ACS URL and Single Logout URL are filled in automatically.

  5. Click Save.

  6. Go to the SAML Response tab, in the Advanced settings section:

    1. AuthnContextClassRef: enter urn:oasis:names:tc:SAML:2.0:ac:classes:phr

    2. NameID format: choose Override with specific format and select Email address.

  7. Click Save.

Phishing-resistant MFA

Salesforce requires phishing-resistant authentication for privileged users (administrators and users with high privileges). Salesforce relies on the AuthnContextClassRef value sent in the SAML assertion to determine whether the authentication is phishing-resistant.

For more information, see https://help.salesforce.com/s/articleView?id=005321563&language=en_US&type=1

Enabling SAML authentication in Salesforce

  1. In Salesforce Setup, go back to Single Sign-On Settings.

  2. Click Edit, check SAML Enabled, then click Save.

  3. In the Quick Find box, search for My Domain (Company Settings > My Domain).

  4. In the Authentication Configuration section, click Edit.

  5. In Authentication Service, check the Single Sign-On configuration you created (for example Safe-T).

  6. Click Save.

We recommend keeping Login Form checked until the SAML integration has been tested, so that administrators can still log in with their Salesforce credentials.

salesforce-my-domain-authentication-20261125-150932.png


Testing

  1. Open your Salesforce My Domain login URL in a private browser window.

  2. Click Log in with Safe-T (or the name you set for the Single Sign-On configuration).

    salesforce-login-safe-t-20261125-150428.png
  3. Authenticate with TrustBuilder Safe-T.

  4. You are redirected to Salesforce and successfully logged in.

Troubleshooting

  • User not found in Salesforce: check that the Salesforce username of the user matches the email address sent by TrustBuilder as NameID.

  • Signature or certificate errors: check that the certificate uploaded in the Identity Provider Certificate field is the current TrustBuilder signing certificate.

  • To analyze a failed login, go to Single Sign-On Settings in Salesforce and use the SAML Assertion Validator.

OIDC integration

Prerequisites

  • A TrustBuilder tenant with users containing at least the following attributes: firstname, lastname, and email and a valid authentication method.

  • A Salesforce tenant. For testing, you can use a developer Salesforce tenant: https://www.salesforce.com/form/developer-signup/

  • The following Salesforce APEX Script : OIDCTrustBuilder.cls (see Configuring APEX Script below)

Configuring an application in TrustBuilder

  1. Log in to TrustBuilder administration portal.

  2. Go to Integrations > Applications > + Set up app integration.

  3. Select OIDC.

    image-20250925-075555.png

  4. Enter a name for the application and select Regular Web App for the application type.
    Click on Next.

    image-20250925-075404.png
  5. Configure the application:

    1. In the Subject Management section, select Email as Subject.
      ⚠️ The subject is used by the APEX script provided. If you wish to use another value, you must adapt the provided APEX script (see Configuring APEX Script below).

    2. In the API & Scopes section, check Internal API.

    3. In the Authentication method section, leave Client secret POST.

    4. In the Redirect URLs section, enter https://localhost (we will modify this later).

    5. Click Submit.

      image-20250925-104305.png
  6. Copy and save the Client ID and Client Secret.
    ⚠️ Be sure to note down the Client secret as it will not be displayed again.

    image-20250925-082909.png
  7. Click Save.

  8. Keep the window open as you will have to copy endpoints from the Endpoints tab later.

Configuring an Auth Provider in Salesforce

  1. Log in to your Salesforce organization setup console.

  2. Go to Settings > Identity > Auth. Providers.

  3. Click on New.

    image-20250925-091015.png
  4. Configure the Auth Provider:

    1. Select OpenID Connect as the provider type.

    2. Enter a Name and URL Suffix (used by Salesforce to identify this “auth provider”).

    3. Paste the saved Client ID (copied from Trustbuilder) as Consumer Key.

    4. Paste the Client Secret (copied from Trustbuilder) as Consumer Secret.

      image-20250925-094645.png
  5. Copy the following URLs from Trustbuilder (in your Salesforce application, in the Endpoints tab) and paste them into Salesforce:

    • copy the OAuth Authorization endpoint and paste it in Authorize Endpoint URL in Salesforce.

    • copy the OAuth Token endpoint and paste it in Token Endpoint URL in Salesforce.

    • copy the OIDC User info endpoint and paste it in User Info Endpoint URL in Salesforce.

      image-20250925-095159.png
      image-20250925-103531.png
  6. Continue the Auth Provider configuration:

    1. In Token Issuer, enter the Authorize Endpoint URL without /authorize.

    2. In Default Scopes, enter: openid email profile.

    3. In Custom Logout URL, replace /authorize with /logout from the Authorize URL.

    4. Leave other fields as default.

      image-20250925-113402.png
  7. For Registration Handler Type:

    1. select Apex.

      image-20250925-120952.png
    2. click Automatically create a registration handler template.

      image-20250925-135954.png
  8. In Execute Registration As, click on Find and select a user with administration rights.

    image-20250925-135631.png
  9. Click Save.

    image-20250925-140553.png
  10. Change the default created APEX script:

    1. Click on the Registration Handler link (e.g., AutocreatedRegHandlerXXXXXXXX).

      image-20250926-104514.png
    2. Click on Edit.

      image-20250925-143807.png
    3. Copy/Paste the content of the provided APEX script (See Prerequisites above).
      Then click Save.

      image-20250925-145015.png
    4. Come back to the Identity > Auth. Providers menu. Click on the newly created one.

      image-20250925-145344.png
    5. Verify the change of the Registration Handler and copy the Callback URL.

      image-20250925-152741.png
    6. Go back to TrustBuilder administration console > Applications > Applications. Click on the previously created Salesforce application.

      image-20250925-093842.png
    7. In Security settings tab, paste the copied Callback URL in the Whitelist of redirect URLs field. Then click Save.

      image-20250925-151047.png
  11. Now, enable the newly created authentication provider to be available for users to connect:

    1. Go back to your Salesforce organization setup console > Settings > Company Settings > My Domain menu. In Authentication Configuration section, click the Edit button.

      image-20250925-152157.png
    2. Check the newly created Authentication Service (here TrustBuilder).
      ⚠️ Keep Login Form checked for admin access to your Salesforce organization setup until other authentication methods are valid for administrator access.

      image-20250925-152613.png
    3. Click Save.

Testing

  1. Be sure to have a TrustBuilder user:

    • with at least firstname, lastname and email attributes,

    • with at least one authentication method activated.

      image-20250929-063832.png
  2. Head up to your Saleforce URL,
    Select Log in with TrustBuilder.

    image-20250925-153205.png
  3. Choose an authentication method activated for the user.

    image-20250925-153827.png
  4. Authenticate.

    image-20250925-154602.png
  5. Grant Access on the showed consent.

    image-20250925-154635.png
  6. You should be connected to Salesforce with your user.
    If the user email address was not an already existing username, the user was created in Salesforce, otherwise the existing Salesforce user is used.

    image-20250925-154934.png

Configuring the APEX Script

User mapping

User mapping between TrustBuilder (the Identity Provider) and Salesforce (the Service Provider) is managed by the Apex script.

The script provided (see Prerequisites above) maps the TrustBuilder user to the Salesforce username using the email address from the TrustBuilder user’s email attribute. This mapping is based on the Subject value in the OIDC ID Token.

If you want to use a different identifier, you must update both:

  • the OIDC configuration in TrustBuilder (update subect value in the OIDC application configuration)

  • the Apex script in Salesforce accordingly.

Required attributes

Salesforce requires the following fields for every user: First name, Last name and Email address.

Make sure these attributes are correctly handled in the Apex script, especially when new users are created automatically.

License configuration

The provided script is designed for testing and demo environments.
It creates users with the Chatter Free User license, which is a free Salesforce license.

If you plan to use this setup in production, update the license type in the script (lines 60–63):

SQL
// 'Chatter Free User' profile useful for tests and demos as free SF licence
 Profile p = [SELECT Id FROM Profile WHERE Name = 'Chatter Free User' LIMIT 1];
            
// 'Standard User' profile for production or others, consult SF doc
// Profile p = [SELECT Id FROM Profile WHERE Name = 'Standard User' LIMIT 1];

Extending user attributes

You can extend the script to include or update additional attributes (for example language which is hardcoded in the script). To do this, add additional OIDC scopes and map their corresponding attributes in the Apex script.

Troubleshooting

There is a debug/log system within Salesforce. Once activated you will be able to see the debug of the Salesforce Authentication Framework and the debug of the APEX Script.

The debug will only show APEX script execution NOT OIDC authentication Framework execution.
After enabling debug, if you do not have debug logs this mean that the issue is with OIDC configuration either on TrustBuilder or Salesforce side

This debug logs need to be activated, at 2 different locations at the same time : one in the APEX script itself, and one in the user executing the script.
Both need to be activated to gather debug logs

  1. Connect to your Salesforce organization setup console
    Head up to the Settings > Identity > Auth. Providers menu,
    Click on the newly created one TrustBuilder

    image-20250925-145344.png
  2. Click on the link Registration Handler : OIDCTrustbuilder

    image-20250929-074757.png
  3. Click on Trace Flags tab,
    Click on the New button

    image-20250929-074909.png
  4. Adjust the time window during which you want to activate debugging with Start Date and Expiration Date,
    Click the New Debug Level button

    image-20250929-075019.png
  5. Type a name in the Name field,,
    Select Finest in the Apex Code drop-down list,
    Click the Save button

    image-20250929-072815.png
  6. Click the Save button on the previous window

    image-20250929-075213.png

     

  7. Head up to the Environment > Logs > Debug Logs menu,
    Click the New button

    image-20250929-075521.png
  8. Click on the search button on Traced Entity Name

    image-20250929-075950.png

     

  9. Select the user you use on Salesforce OIDC Identity Provider, point 9

    image-20250929-080145.png
  10. Click on the search button on Debug Level

    image-20250929-080423.png

     

  11. Select the debug level you created above

    image-20250929-080655.png
  12. Click on the Save button

    image-20250929-081026.png
  13. Test a user authentication and come back to the Environment > Logs > Debug Logs menu,
    Refresh the page,
    You should get a new line with the debug logs corresponding to the try
    You can view/download the logs

    image-20250929-081829.png