Step by step guide to Setup Federated Authentication (SAML) based SSO in Salesforce – Video Tutorial

In this post, We will be dicussing how to setup Federated SAML based Authentication in Salesforce.

SAML stands for “Security Assertion Markup Language” and it is Open standard for exchanging Authentication and Authorization between Systems. SAML based authentication is supported by all editions of Salesforce.

User Validation can be initiated by any one of below two types:

  1. Service Provider Initiated SSO
  2. Identity Provider (IDp) initioated SSO

We are going to use Identity Provider Initiated SSO in this article. Means User will Login from Outside(IDp) and will be redirected to Salesforce (Service Provider). Identity Provider must follow Federated Authentication (SAML) standard which should be deployed to DMZ (URL should be publicly accessible on Internet) layer of your Organization. As a Salesforce developer you should assume that you will always get IDp URL which implements SSO and implements valid SAML response. To Quickly start with this tutorial assume that your organization already deployed SAML based Authentication endpoint and for that we will be using great Heroku app available freely as open source named “AXIOM“.

AXIOM is java based heroku application which implements SAML and can be used for testing  purpose to check whether SSO is working properly or not.

IDp Initiated Single Sign On :

In IDp Initiated SSO, User Directly logins to Identity provider and IDp redirects user to proper Salesforce Instance with SAML assertion in request (Service Provider). If SAML assertion is valid then Salesforce validates that user successfuly.

IDp Initiated SAML Based Single Sign On
Image 1 – IDp Initiated SAML Based Single Sign On

Step 1 : Enable My Domain

First step is to enable “My Domain” in Salesforce. This functionality will provide a unique name to your salesforce Instance. It may take 24 hours to activate. Your Domain name must be unique and not used by someone else.

Step 2: Download Identity Provider Certificate

In this step we are going to get certificate from IDp. This certificate will be used by Salesforec to validate that client coming for user authentication is valid to avoid any unauthorized access to Service Provider (In our case it is Salesforce).

You can download certificate by navigating to Axiom application here.

Step 3: Enable Single Sign On in Salesforce

Navigate to “Setup | Security Controls | Single Sign-On Settings” and check “SAML Enabled” option.

Step 4 : Configure Single Sign On

Once SAML is enabled, new section will appear on same page to create New “SAML Single-On Settings”.

Click on New Button and provide following informations

  • NAME – any name will work
  • API Name – any valid name
  • Issuer – Any name. You must remember this as your IDp must pass the same name while sending request
  • Identity Provider Certificate – Upload certificate here downloaded on step 2.
  • Entity Id – “https://saml.salesforce.com”
  • SAML Identity Type – Assertion contains the Federation ID from the User object
  • SAML Identity Location – Identity is in the NameIdentifier element of the Subject statement
  • Identity Provider Login URL – “http://axiomsso.herokuapp.com/RequestSamlResponse.action” (This URL must be publicly accesible on Internet)
  • Service Provider Initiated Request Binding – HTTP POST

Once you are done with settings, you should be able to see seetings page something like this:

SAML Single Sign-On Settings
Image 2 – SAML Single Sign-On Settings

Step 5: Generate a SAML Response

Navigate to this URL and click on “generate a SAML Response” link.

Enter following detail in next screen:

  • SAML Version – 2.0
  • Username OR Federated ID – Once saml is enabled, One new field is created on user record “Federation ID”. This field can be used as a username to validated against IDp. In my case i have provided Employee numver – 123456. Note this is not in Email format.
  • User ID Location – Subject
  • Issuer – Issuer name which we already in Step4 while configuring SSO. In our case it is AXIOM
  • Recipient URL – This should be “Salesforce Login URL” which will be visible once we save SSO settings in Step 4. You can see it in Image 2 above.
  • Entity Idhttps://saml.salesforce.com
  • SSO Start Pagehttp://axiomsso.herokuapp.com/RequestSamlResponse.action
  • User Type – Standard
Generate SAML response
Image 3 – Generate SAML response

After providing above details click on “Request SAML response” button. Below Screen will appear.

Login using SAML Response from AXIOM
Image 4 – Login using SAML Response from AXIOM

In this page, you can see format of SAML response. You dont have to change anything on this screen, click on Login button.

If everything is OK, you will be on Salesforce Home page.

Question : Can I force users to login with Federated SSO only?
Answer : Yes, Please refer this Article from Salesforce.

Dont allow user to use Standard Login page to Login in Salesforce
Image 5 – Dont allow user to use Standard Login page to Login in Salesforce

Video Tutorial

Related posts

  • mailtoharshit

    Neat, you know what, I am big fan of article and video and that what I am pushing in with editorial team here. I love the flow when you see video and re-read the blog to follow the step, neat job

    • JitendraZaa

      Thanks Harshit….

  • Ajith

    Hi Jitendra, how do we handle the relay states in SAML based SSO? I have set up IDP initiated SSO (IBM Tivoli) and works like a charm in a normal browser. But when trying to login from Salesforce1, the IDP redirects the Salesforce1 pages to the desktop version of the page – means normal browser page loads inside the Salesforce 1 container. After doing some research, I got a hint on Relay states but not a clue yet how to set it. Have you encountered such a scenario?

    • JitendraZaa

      Hi ajith, I also faced something like this. You can check my other post on same topic. I asked questions on stack exchange and twitter also. You will need to use SP initiated SSO.

  • Balaji Bondar

    Nice artical jitendra

    • JitendraZaa

      Thanks Balaji

  • Rishav

    HI jitendra,

    i am trying to configure this it’s returning me error ” saying to fill all the field like “Start URL / Relay State” that i left empty” what is this please tell

  • anandha prassanna

    Very Good and neatly documented. Came in handy for a quick verification. As the test site of herokuapp can be generically used to submit a SAML artifact response to any site which is SAML compliant. – aprassanna

  • krishna Dev Annamaneni

    Hi Jitendra,
    In case of Federated SSO with ADFS how to exclude System Admins and integration user accounts so that they we not be impacted when ADFS is down or some interruption in service.

    Regards,
    krishna Dev

  • Vikash Kumar

    Its worth watching it. Very helpful.

    I am facing a problem with implementing SSO with ADFS. I’m sure from salesforce I configured everything perfect but while testing sometimes it is allowing user to login and sometimes not. Also as soon as I’m clicking on SSO button it is first taking me to the ADFS login page which seems strange to me.

    Am I missing something here?

    Thanks in advance.

    -Vikash Kumar

  • Neeraj Jadhav

    If my service provider is a force.com site application, how do I verify the user? What will the IDP send back to the force.com site and how do I find it? Is the assertion sent in the form of cookies or response headers? Is there an apex code to do that?

    • Neeraj Jadhav

      Sorry, I did not get that.