This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Logging in to Salesforce with Facebook
This topic provides instructions on how to log into Salesforce using your WSO2 Identity Server credentials.
Configuring Salesforce
Sign up as a Salesforce developer.
Fill out the relevant information found in the following URL: https://developer.salesforce.com/signup
Click Sign me up.
You will receive a security token by email to confirm your new account. If you did not receive the email successfully, you will be able to reset it by following the steps given here.
Log in with your new credentials as a Salesforce developer. Do this by clicking Login link in the top right hand side of https://developer.salesforce.com/.
Click Allow to enable Salesforce to access your basic information.
Once you are logged in, create a new domain and access it.
To do this, do the following steps.
Go to Domain Management in the left navigation pane and click My Domain.
In the page that appears, come up with a name for your domain. You can check if the domain is available by clicking the Check Availability button.
Check and agree with the Terms and Conditions before clicking Register Domain to register your new domain.
Once the domain is registered to your account, click the Click here to login button to test this out.
On the left navigation menu, go to Security Controls and click Single Sign-On Settings.
In the page that appears, click Edit and then select the SAML Enabled checkbox to enable federated single sign-on using SAML.
Click Save to save this configuration change.
Click New under SAML Single Sign-On Settings. The following screen appears.
Ensure that you configure the following properties.Click Save to save your configurations.
Go to Domain Management in the left navigation pane and click My Domain.
Click Deploy to Users. Click Ok to the confirmation message that appears.
In the page that appears, you must configure the Authentication Configuration section. Scroll down to this section and click Edit.
Under Authentication Service, select SSO instead of Login Page.
Click Save.
Next you need to obtain the Salesforce certificate and upload it to the Identity Server.
Do the following steps to obtain the certificate.
On the left navigation menu, go to Security Controls and click Certificate and Key Management.
If you have not done so already, you must create the certificate first. Do the following steps to create this.
Click Create Self-Signed Certificate.
Enter the Label and a Unique Name and click Save. The certificate is generated.
Click the Download Certificate button to download the certificate.
Configuring the service provider
Sign in. Enter your username and password to log on to the management console.
Navigate to the Main menu to access the Identity menu. Click Add under Service Providers.
Fill in the Service Provider Name and provide a brief Description of the service provider. Only Service Provider Name is a required field and we use Salesforce as the name for this example.
Click Register.
Expand the Inbound Authentication Configuration and the SAML2 Web SSO Configuration and click Configure.
In the form that appears, fill out the following configuration details required for single sign-on.
See the following table for details.Click Register to save your configurations.
Since Salesforce user names are actually email addresses, we must configure the Identity Server for email authentication. Do the following steps to achieve this.
Open the
<IS_HOME>/repository/conf/carbon.xmlfile and make the following change to the configuration.<EnableEmailUserName>true</EnableEmailUserName>Open the
<IS_HOME>/repository/conf/user-mgt.xmlfile and add the following property under the user store manager configurations. Using above property, you can change the pattern of your email address. By default it must be more than 3 characters and less than 30, but you can configure it as you wish.<Property name="UsernameWithEmailJavaScriptRegEx">^[\S]{3,30}$</Property>
Restart the Identity Server.
Configuring the Facebook app
Go to https://developers.facebook.com/ and log in using your Facebook credentials.
Navigate to the window where you can create a new app by clicking Add a New App under the Apps menu.
Choose the platform you wish to use. Select Website here when working with this sample.
Enter the name of your new app in the window that appears and click Create New Facebook App ID.
Add the relevant website details by pointing to https://localhost:9443/ and click Next.Click Skip to the Developer Dashboard to access the dashboard.
This will take you to the app Dashboard where you can find the App ID and App Secret as shown in the image below. Click Show to view the App Secret.
Click Settings on the left menu and navigate to the Advanced section by clicking on the tab at the top of your screen. Here you need to configure the OAuth Settings.
Make the following changes:Client OAuth Login should be set to Yes.
Valid OAuth redirect URIs should be set to https://localhost:9443/commonauth.
Click the Save Changes button to save the changes.
Now you have finished configuring Facebook as an Identity Provider.
About accessing the app
The app is not available to general public yet. To make to app available to every Facebook user, you have to submit the app for review. After a review, Facebook makes the app available to every Facebook user. You can find more information on the review process by clicking on Status and Review in the left navigation menu of your app's dashboard.
The review process may take some time, so for the purposes of this sample, you can specify some Facebook users as Developers or Testers. Only the users specified here can use this app to log in with Facebook until the app goes public. To do this, click on Roles in the left navigation menu of the dashboard and specify the required Facebook users as Developers or Testers.
Configuring the identity provider
Now you have to configure WSO2 Identity Server by adding Facebook as a new identity provider.
Log in to the management console as an administrator.
In the Identity section under the Main tab of the management console, click Add under Identity Providers.
Give a suitable name as the Identity Provider Name. In this case we can have Facebook as the identity provider name for clarity.
Go to Facebook Configuration under Federated Authenticators.
Enter the App ID and App Secret values from the Facebook app you created in the Client Id and Client Secret fields respectively.
Select both checkboxes to Enable Facebook Authenticator and make it the Default.
Click Register.
You have now added the identity provider.
Configuring the federated authenticator for the service provider
The next step is to configure the federated authenticator for the service provider. In this case, the service provider is Salesforce
Return to the management console.
In the Identity section under the Main tab, click List under Service Providers.
Go to the service provider that you created and click Edit.
Go to Local and Outbound Authentication Configuration section.
Select the Identity Provider you created from the dropdown list under Federated Authentication.
Ensure that the Federated Authentication radio button is selected and select Facebook from the dropdown. This is the name of the identity provider that you configured.
Click Update to save the changes.
You have now added the identity provider as the federated authenticator for Salesforce.
Configuring claim mapping for Facebook
The next step is to configure claims in the Identity Server and map them with Facebook.
In the Identity section under the Main tab, click List under Identity Providers.
Click Edit to edit the Facebook identity provider you created.
Under Claim Configuration, go to Basic Claim Configuration.
Select the Define Custom Claim Dialect option under Select Claim mapping Dialect.
Click Add Claim Mapping to add custom claim mappings as follows.
Do the following mappings as shown in the above screenshot.You can retrieve all the public information of the user and the email address. The following are some common attribute names.
More information is available from the following link: https://developers.facebook.com/docs/facebook-login/permissions/v2.0
You can map these attributes to any Local Claim URI that is suitable.
Configuring claim mapping for Salesforce
In the Identity section under the Main tab, click List under Service Providers.
Click Edit to edit the Salesforce service provider you created.
Expand the Claim Configuration section.
Select the Define Custom Claim Dialect option under Select Claim mapping Dialect.
Click Add Claim URI to add custom claim mappings as follows.
Add the following claim URIs.
Also do the following changes.
Select all of these claims as requested claims using the checkboxes provided.
Select email from the Subject Claim URI dropdown. The Subject Claim URI is important to define as it is the unique value used to identify the user. In cases where you have a user store connected to the Identity Server, this Subject Claim URI value is used to search for the user in the user store.
Click Update to save your changes.
Testing the configurations
Do the following steps to test out the configurations for a new user in Salesforce and the Identity Server.
Once you log into the Identity Server, navigate to the Main menu in the management console, click Add under Users and Roles.
Click Users. This link is only visible to users with the Admin role.
Click Add New User. When adding a new user, use the same credentials as the Facebook user. You must use an email address as the username.
Click Finish.
Log back into your Salesforce developer account.
On the left navigation pane, click Users under Manage Users.
On the page that appears, click the New User button to create a new user.
Create a user with the same credentials as the one you created in the Identity Server. This will also be the same as your Facebook user. Click Save to save your changes. An email will be sent to the email address you provided for the user.
Logout of Salesforce and log back in using the newly created user's credentials sent via the email.
Set the password to the same value you had in the Identity Server and Facebook and log out again.
Access your Salesforce login URL. For this example, the Salesforce login URL is https://identityprovisioning-dev-ed.my.salesforce.com?so=00D90000000ySEn. You are directed to the Facebook Login screen if you are not already logged in.
Log in using your Facebook credentials. You are then redirected back to Salesforce.