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/.
Configuring Single Sign-On
Single sign-on is a key feature of the WSO2 Identity Server that enables users to access multiple applications using the same set of credentials. Additionally, the user can access all these applications without having to log into each application individually. For instance, if users log into application A, they would automatically have access to application B as well for the duration of that session without having to re-enter their credentials.
The profile specification for Security Assertion Markup Language 2.0 (SAML 2.0) defines single sign-on based on a web browser. This topic provides instructions on how to use the sample available in the WSO2 Identity Server to configure SSO using SAML 2.0 with a sample service provider.
You can find more information regarding the SAML2 and SAML2 Web Browser SSO Profile in the saml-core specification and the saml-profile specification.
See the following topics for instructions on how to configure the sample with the WSO2 Identity Server.
Before you begin!
- To ensure you get the full understanding of this tutorial, the sample travelocity applciation is used in this use case. Therefore, make sure to download the samples before you begin.
- Download Tomcat 7.x. The samples are written on Servlet 3.0. Therefore, they need to be deployed on Tomcat 7.x.
- Install Apache Maven. For more information, see Installation Prerequisites.
Configuring the SSO web application
To obtain and configure the single sign-on travelocity sample, follow the steps below.
Add the following entry to the
/etc/hosts
file of your machine to configure the hostname.Why is this step needed?
Some browsers do not allow you to create cookies for a naked hostname, such as
localhost
. Cookies are required when working with SSO. Therefore, to ensure that the SSO capabilities work as expected in this tutorial, you need to configure theetc/host
file as explained in this step.The
etc/host
file is a read-only file. Therefore, you won't be able to edit it by opening the file via a text editor. To avoid this, edit the file using the terminal commands.
For example, use the following command if you are working on a Mac/Linux environment.sudo nano /etc/hosts
127.0.0.1 wso2is.local
Open the
travelocity.properties
file found in theis-samples/modules/samples/sso/sso-agent-sample/src/main/resources
directory of the samples folder you just checked out. Configure the following property with the hostname (wso2is.local
) that you configured above.#The URL of the SAML 2.0 Assertion Consumer SAML2.AssertionConsumerURL=http://wso2is.local:8080/travelocity.com/home.jsp
In your terminal, navigate to
is-samples/modules/samples/sso/sso-agent-sample
folder and build the sample using the following command. You must have Apache Maven installed to do thismvn clean install
After successfully building the sample, a
.war
file named travelocity.com can be found inside theis-samples/sso/sso-agent-sample/
target
directory. Deploy this sample web app on a web container. To do this, use the Apache Tomcat server.Since this sample is written based on Servlet 3.0 it needs to be deployed on Tomcat 7.x.
Use the following steps to deploy the web app in the web container:
- Stop the Apache Tomcat server if it is already running.
- Copy the
travelocity.com.war
file to the<TOMCAT_HOME>/webapps
directory. - Start the Apache Tomcat server.
Tip: If you wish to change properties like the issuer ID, consumer URL, and IdP URL, you can edit the travelocity.properties file found in the travelocity.com/WEB-INF/classes
directory. If the service provider is configured in a tenant you can use the QueryParams
property to send the tenant domain. For example, QueryParams=tenantDomain=wso2.com
.
This sample uses the following default values.
Properties | Description |
---|---|
SAML2.SPEntityId=travelocity.com | A unique identifier for this SAML 2.0 Service Provider application. |
| The URL of the SAML 2.0 Assertion Consumer. |
SAML2.IdPEntityId=localhost | The unique identifier for this SAML 2.0 Service Provider application. Note: If you are updating the value, make sure to define the same value for the Identity Provider Entity Id of the Resident IdP. Follow the steps given below:
|
| The URL of the SAML 2.0 Identity Provider. |
If you edit the travelocity.properties
file, you must restart the Apache Tomcat server for the changes to take effect.
Now the web application is successfully deployed on a web container.
Configuring the service provider
The next step is to configure travelocity.com as the service provider. The following steps instruct you on how to do this.
- Start the Identity Server and access the management console using
https://localhost:9443/carbon/
. - Log in to the Identity Server using default administrator credentials (the username and password are both
admin
). If you need to create the service provider in a tenant space, you need to login with tenants user. - Select the Main menu that is on the left side of the management console and click Add under Service Provider.
- Enter
travelocity.com
as the value for the Service Provider Name filed and click Register. - Expand the Inbound Authentication Configuration section and then expand SAML2 Web SSO Configuration.
Click Configure.
- Select Manual Configuration.
Register the new service provider by providing the following values. See the table below for more information about the fields in this form.
Note: To add the correct tenant domain with the username as the subject identifier in tenant mode,
Expand the Local & Outbound Authentication Configuration section and do the following.
- Select Use tenant domain in local subject identifier to append the tenant domain to the local subject identifier.
- Select Use user store domain in local subject identifier to append the user store domain that the user resides in the local subject identifier.
For super tenant mode, this step is not required and the two options mentioned above should remain disabled by default.
- Click Update to register.
Configuring Claims
- Configure claims for the service provider. To do this, do the following. For more information on configuring this, see Configuring Claims for a Service Provider.
- Expand the Claim Configuration section in the service provider form.
- You can select the claims that must be sent to the service provider. If you just want to send them as claim URIs, select Use Local Claim Dialect.
- Alternatively, if you want to define new claim URIs for the attributes that are sent, you can define any values for them and map these values with the claim URIs local to WSO2.
For example, you want to set the email address of the user ashttp://testclaims.com/claims/emailaddress
claim URI, you can define it here and map it in tohttp://wso2.org/claims/emailaddress
. To specify this, select the Define Custom Claim Dialect option and click Add Claim URI. Enter the Service Provider Claim URIs and select the matching local claim from the dropdown. You can also mark them as a Requested Claim or a Mandatory Claim. For more information, see Configuring Claims for a Service Provider.
- Configure outbound authentication as Default authentication type. This specifies that the identity provider authenticates the users with the username/password by validating with the identity provider's user store.
- After providing the above information, click Register.
After successfully registering the service provider, log out from management console. The next step is to run the sample.
Running the sample
- Visit
http://wso2is.local:8080/travelocity.com
. You are directed to the following page:
- Since you need to use SAML2 for this sample, click the first link, i.e., Click here to login with SAML from Identity Server. You are redirected to the Identity Server for authentication.
- Enter the default admin credentials (admin/admin).
- Now you are logged in and you can see the home page of the travelocity.com app.
If you need to view the SAML request and response, please add the following debug log to the
log4j.properties
file found inside<PRODUCT_HOME>/repository/conf
.log4j.logger.org.wso2.carbon.identity=DEBUG
- Since single log out is enabled, if you click the logout button in the travelocity.com home page, you will successfully log out.
- To configure single sign on with different standards or protocols, see the following topics:
- To set up reCaptcha for single sign on, see the following page:
- To configure single sign on for Microsoft Sharepoint web applications with the WSO2 Identity Server, see the following article: