With the proliferation of SaaS and other web-based applications, identity management is becoming a major concern for businesses. Just think about the number of usernames and password you regularly type each day. You probably log into your company's network, portal, webmail, benefits system, Google Apps, bespoke applications and of course Force.com applications. Now multiply this by the number of users in your company and think about the support and security implications. You need dedicated resources to manage your identity store, respond to password reset requests, provision new users for each system and deactivate users that no longer need access. Just think of the number of man hours you could save if you could eliminate 25-50% of your passwords and their associated costs!
Implementing a Single Sign-On (SSO) infrastructure enables users to sign in once and have access to all authorized resources. In this article, we'll look at the different methods of implementing SSO with Force.com, how to set up your own open source identity management system for federated authentication using SAML 2, and how to configure the Force.com platform to utilize your new identify provider. We'll also provide some troubleshooting techniques and outline some best practices to help you avoid common roadblocks, getting you up and running fast.
Implementing SSO provides not only time-saving benefits for end users but financial benefits for your company. Major benefits of SSO include:
In other words, there are substantial benefits to implementing SSO. Let's now turn to the options available on Force.com, before delving into a SAML implementation.
Force.com supports both delegated and federated authentication for SSO. Since federated authentication is the default form of single sign-on, we will be covering it in detail in the rest of this article. However, for the sake of completeness, we'll briefly cover delegated authentication first.
Using delegated authentication, Force.com does not validate passwords but instead uses an external Web service to validate user credentials. When a user attempts to login, the platform checks the user's profile to see if they are enabled for SSO. If so, it makes a Web services call to the the endpoint specified for the organization (environment), asking it to validate the username and password. The Web services checks the credentials against an identity store (for example LDAP or OpenID) and either returns "true" or "false". If true, the user is granted access to the application and proceeds normally. If false, the user is informed that their credentials are invalid.
Delegated authentication has a few drawbacks with respect to federated authentication. First, delegated authentication is inherently less secure than federated authentication. Even if encrypted, delegated authentication still sends the username and password (possibly even your network password) over the internet to Force.com. Some companies have policies that preclude a third party for handling their network passwords. Second, delegated authentication requires much more work for the company implementing it. The Web services endpoint configured for the org must be developed, hosted, exposed on the Internet, and integrated with the company's identity store.
As with delegated authentication, federated authentication does not validate the user's actual password on the Force.com platform either. Instead, the platform receives a SAML assertion in an HTTP POST request. The SAML assertion has a limited validity period, contains a unique identifier, and is digitally signed. If the assertion is still within its validity period, has an identifier that has not been used before, and has a valid signature from a trusted identity provider, the user is granted access to the application. If the assertion fails validation for any reason, the user is informed that their credentials are invalid. The rest of this article shows how to set this up.
Security Assertion Markup Language (SAML) provides a secure, XML-based solution for exchanging user security information between an identity provider (your company) and a service provider (Force.com). SAML 2 is a major revision from the SAML 1.1 standard and now supports, among other things, W3C XML encryption and service provider initiated web single sign-on exchanges. This allows service providers like Force.com to query the identity provider for authentication. SAML 2 also adds a useful feature called "single logout", which defines a mechanism for logging out of all service providers quickly and easily. Some of the major features of SAML 2 include:
There are three roles involved in a SAML transaction:
The identity provider is the authority system that provides the user information. We will be setting up our identity provider shortly. The service provider is the system, in this case Force.com, that trusts the identity provider's user information, and uses the data to provide access to the service or application. The user and their identity combined are known as the subject.
The transaction from our identity provider to Force.com is called a SAML assertion. Force.com assumes that all data contained in the assertion from our identity provider is valid. The structure of the SAML assertion is defined by an XML schema that is specified by the OASIS SAML standard and contains header information, the subject and statements about the subject in the form of attributes and conditions such as a start and logout URL. In our examples, our SAML assertions will contain a Federated ID from the identity provider which is guaranteed to be unique within the Force.com org.
Web browser SSO is SAML's most widely used feature and is typically used in conjunction with the HTTP POST binding and authentication request protocol. Web browser SSO may be initiated by the identify provider or by Force.com if a user's session has not been established. If initiated by the identity provider, the assertion is signed. With the web browser SSO profile, Force.com receives all of the assertion information at once using any of the HTTP bindings and protocols. Force.com checks the message integrity using the contained signature against the identity provider certificate defined in our org. Next, it parses the SAML XML statements and gathers any attributes that were passed (for example Force.com username, employeeId), and then attempts the login process.
There are two important use cases for SAML -- Identity Provider Initiated Login, where a user starts directly at their identity provider, logs in, and is then redirected to a landing page at the service provider; and Service Provider Initiated Login, where a user starts by clicking a link to the the service provider (e.g. a bookmark, mailed link, etc) and temporarily redirected to the identity provider for authentication, then returned to the link they initially requested. Force.com supports both of these use cases.
With the theory out of the way, let's get down to business and create an implementation.
There are a number of open source identity solutions that support federated authentication using SAML. OpenSAML, a widely-used open source Java and C++ toolkit, is available to develop solutions with SAML. Notable projects using SAML 2 include Shibboleth, JOSSO and JBoss Federated SSO. Your company may already have an identity provider in place, but for our example, we'll be setting up an identity provider using OpenSSO, the open source version of OpenSSO Enterprise from Sun Microsystems. Sun has gone to great lengths to make the configuration process as painless as possible and even has a specialized configuration process for Force.com. Thanks Sun! OpenSSO runs on a large number of Java EE servers but we'll be using Sun's GlassFish open source application server as it is OpenSSO's preferred container.
To set up federated authentication, we need to configure a local entity, a partner entity (your Force.com environment) and then establish an association between the two in the Force.com administrative interface which forms a federation. To manually configure our local entity, we need to first determine what will be the unique identifier that will be passed to Force.com as part of the assertion. Typically with SSO this value is an employee number or corporate email address that is guaranteed to be unique for each users. To tie into a company's existing security infrastructure, these values typically originate from data sources such as LDAP, a corporate HR system or even identity service such as OpenID. In our example we are going to use a simple phone number.
You can download GlassFish v2.1 here along with documentation. Use the installation guide to set the server up (I used the jar installer) and the quick start guide to start the server. The installation process is fairly straightforward and should only take about 10-15 minutes to get the server up and running. Make sure the server you install GlassFish on is accessible to Force.com and not hidden behind a firewall. Also, you'll have to run the server on a fully qualified domain name. In the example below, we use dev.bluemethod.com - choose your own. For OpenSSO to work properly it cannot run on an IP address or localhost.
The OpenSSO download is quite large, +300MB, so be prepared for a wait. There is a really great article that walks you through the entire installation and configuration process. You can accept most of the defaults during the configuration process but pay attention to the selection in step #4. This is the step where you select a data store that holds your users. By default, the "Other User Data Store" option is selected allowing you to configure your LDAP connection. Select the "OpenSSO User Data Store" instead (the screenshot in the article displays it as "Embedded"). You should see a warning that states the OpenSSO user data store is only for development purposes and is not supported for production environments. When you eventually put this solution into production you'll need to circle-back to this screen and configure your production data store.
Once OpenSSO is configured properly it's time to configure our identity and service providers. Log into the OpenSSO Administration Console, click "Create Hosted Identity Provider" and then create a new Circle of Trust. Choose the "test" signing key and enter a name for the Circle of Trust. You do not need to specify any Attribute Mappings at this time.
After your identify provider has been configured click the link to "Configure Salesforce CRM". This is the crucial step. We are going to create the mapping for the values that will be passed to Force.com in the SAML assertion. For our example we are going to send the value of the identity providers user's telephone number in the assertion so that the Force.com platform can use this in conjunction with the Force.com user's matching Federation ID value.
Type "ATTR_PHONE" in the first input. This is the attribute in the assertion that contains the identity provider's telephone number. Type "telephonenumber" in the second input and click the Add button.
After clicking the Create button a screen that looks like the one below displays. This screen contains important information that you need for Force.com so we are going to leave it open for a while. Sun has done a good job of providing step-by-step instructions but we are going to go through them in a little different order. The last item, #18, is a little confusing so we'll discuss that during the Force.com setup.
First, download the Verification Certificate to your local machine in a plain text file. We'll need this file when setting up SSO in Force.com. Also, notice the "Salesforce Login URL" at the bottom. This URL will be generated for us by Force.com when setting up SSO so do not close this screen or click finish at this time. After configuring Force.com we will paste the Force.com Login URL into this field.
Now that we have our identity provider built it's time to configure Force.com to use SSO. Fortunately this is the easiest part of the entire process. Login into your Force.com org and click Setup -> Security Controls -> Single Sign-On Settings. The screen should initially look like the following.
Click the Edit button and then check the SAML Enabled checkbox to display the input fields for the SAML. Upload your Verification Certificate file and set up your organization to look like the screen below. This configuration tells the Force.com platform that the attribute, ATTR_PHONE, is being mapped to the Force.com user's Federation ID attribute.
After saving the settings your screen should look like this the following. This screen contains the Force.com Login URL that OpenSSO requires. Copy this URL and paste it into the "Salesforce Login URL" in OpenSSO. You can now click the Finish button on the OpenSSO screen.
Be careful if you make changes to these SSO settings as it may generate a new Force.com Login URL. If it does, you will need to update the Force.com URL in OpenSSO.
To test the SSO configuration we need to configure a user in the identity provider's user data store. For this example, we'll use the default user OpenSSO has already created - demo. In the OpenSSO Administration Console, click Access Control -> Top Level Realm -> Subjects -> demo. Enter a telephone number for the user (copy it to your clipboard) and Save the user.
Configuring users for federated authentication is a little different than delegated authentication. With delegated authenticated you enable a profile to use SSO, and all users in that profile have access to Force.com using SSO. Federated authentication is simpler and more straightforward as everything is done at the user level.
Either select an existing user or setup a new one. Since SSO is enabled you'll see a new field on the user details page called, "Federation ID". Edit the user details and enter the same phone number you used for the identity provider's user. The value should still be on your clipboard. Once you save the user, setting up federated authentication is complete and we are ready to test our SSO solution.
To test the SSO solution, sign out of both OpenSSO and your Force.com environment. Modify the URL below for your server and enter it into your browser.
Since you are not logged in to OpenSSO, the OpenSSO login screen should now display. Enter your demo user's credentials for access ("demo" and "changeit" by default). Once you submit the login form, the SAML assertion is passed to the Force.com platform and, if everything is configured correctly, you should be logged into your Force.com org and viewing your user's home page.
If SSO is not working for you there are a few ways you can troubleshoot the issue.
Consider the following best practices when implementing federated single sign-on for your organization:
This tutorial demonstrates how an SSO infrastructure can be beneficial to users and companies. It compares the different SSO methods available with the Force.com platform and provides a quick overview of how federated authentication works with SAML 2. The meat of the article lies in setting up an identity provider with OpenSSO and GlassFish, and walking you through the process of setting up the Force.com platform for SSO.
This tutorial is meant to get you up and running with SSO on the Force.com platform. In a production deployment of SAML and SSO, be sure to consult your security and network infrastructure teams on the configuration of your identity provider solution.
Jeff Douglas is a Senior Technical Consultant at Appirio where he creates cutting-edge applications on the Force.com platform for some of the best companies in the world. He is a foster and adoptive parent and actively tries to work the word "chartreuse" into everyday technical conversations. He actively blogs about cloud computing - especially Force.com.