This documentation is for WSO2 Identity Server 5.1.0 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

This topic provides instructions on how to create a service provider and identity provider in the WSO2 Identity Server using configuration files which is typically used during the deployment stage. This is done so that multiple tenants in the Identity Server can have the same identity provider.

While this topic need not be specifically about federated authentication, this scenario addresses a federated authentication solution. This scenario requires two WSO2 Identity Server instances, where one acts as the external identity provider, and the other acts as the service provider. From this point onwards, the Identity Server instance that acts as the external identity provider will be referred to as  identity provider IS  and the instance that acts as the service provider will be referred to as  service provider IS . Once we are done with the configuration, the  service provider IS  will have the travelocity application configured as a service provider and an identity provider configured and shared across its tenant space. This is illustrated in the following diagram.

The following are the high level steps required for this scenario.

  1. Add the  identity provider IS  in the  service provider IS  as an identity provider.
  2. Add the  service provider IS  in the  identity provider IS  as a service provider.
  3. Add the application in the  service provider IS  as a service provider. This uses the identity provider created earlier (in step 1) as a federated authenticator. 

The above processes can be easily done using the Management Console, but the service provider and identity provider created in  service provider IS  are only visible to the tenant who creates them. So the difference here is that the identity provider and service provider in service provider IS are created using configuration files so that they are available to all the tenants in service provider IS.

The following sections provide instructions on how to carry out the above steps.

Before you begin

Do the following steps to setup the two WSO2 Identity Server instances for the scenario.

  1. Download and install the two Identity Server instances.
  2. In the <IDENTITY_PROVIDER_IS_HOME>/repository/conf/carbon.xml file, locate the Offset element and change this to 1. This is done to increment the port values in the identity provider IS so that there is no port conflict with the service provider IS . Port conflicts occur when multiple WSO2 product instances run on the same machine.


Now you have setup the Identity Server instances so you can proceed with the configuration steps.

Adding the service provider in the identity provider IS

This section involves adding the  service provider IS  as a service provider in the  identity provider IS .

  1. Start the  identity provider IS  and access the Management Console.
  2. Navigate to the Main menu to access the Identity menu. Click Add under Service Providers.
  3. Fill in the Service Provider Name and provide a brief Description of the service provider. For the purposes of this scenario, enter the Service Provider Name as ServiceProviderSP_IS.
  4. Click Register to add the service provider.
  5. Expand the Inbound Authentication and SAML2 Web SSO Configuration sections and click Configure.
  6. Do the following configurations.

    Configurations to be doneDescription


    This must be the same as the value you enter for the Service Provider Entity Id when configuring the identity provider in the service provider IS .

    Assertion Consumer URL­: https://localhost:9443/commonauthThis is the URL to which the browser should be redirected to after the authentication is successful. This is the Assertion Consumer Service (ACS) URL of the service provider. The identity provider redirects the SAML2 response to this URL. However, if the SAML2 request is signed and SAML2 request contains the ACS URL, the Identity Server will honor the ACS URL of the SAML2 request. It should be defined in this format: https://(host-name):(port)/commonauth.
    Use fully qualified username in the NameIDA fully qualified username is basically the username with the user store domain. In short, the username must be in the following format: {user store domain}{user name}.
    Enable Single LogoutWhen single logout is enabled, the identity provider sends logout requests to all service providers. Basically, the identity provider acts according to the single logout profile.
  7. Click Register to save your changes.

Adding the identity provider in the service provider IS

This section involves adding the  identity provider IS  as an identity provider in the  service provider IS .

Create a file named identityProviderIDP_IS.xml inside the <SERVICE_PROVIDER_IS_HOME>/repository/conf/identity/identity­-providers directory and add the following content into it. These configurations basically add the identity provider in the  service provider IS . Additionally, this has the configurations necessary for a federated authentication scenario.

Note: This configuration will only allow the file based identity provider to be visible in file based service providers. Additionally, it will only be visible to the super tenant. To make it visible across tenants and in the SP registration UI, add the prefix "SHARED_" before the identity provider name to the<IdentityProviderName> element, as seen below.


Adding this prefix allows this identity provider to be shared between the service providers across all tenants. Consequently, it will also be shown in the UI drop down as a federated identity provider when configuring a service provider.


Tip: When studying the above configurations, you can identify the Service Provider Entity Id in the following code snippet.


Here, travelocitySP must be the same value as the value configured as the Issuer in the identity provider IS.

About certificates: The following is a sample command if the identity provider is WSO2 Identity Server where you can export the public certificate in PEM format.

keytool -exportcert -alias wso2carbon -keypass wso2carbon -keystore wso2carbon.jks -storepass wso2carbon -rfc -file ispublic_crt.pem

Then, you can open the certificate file with a notepad so you see the certificate value. Copy this certificate value and put in the file within the <Certificate> tag.

Please note that above is only if the identity provider is the WSO2 Identity Server. If the identity provider is a third party IDP, then you can get the certificate in PEM format and read the value. You need to copy the entire content of the PEM file and place it between the <Certificate> tags.

Adding the service provider in the service provider IS

This section involves adding the travelocity application as a service provider in the  service provider IS .

  1. Open the <SERVICE_PROVIDER_IS_HOME>/repository/conf/identity/sso-idp-config.xml file and add the following configuration to it. This adds the travelocity application as a service provider.

  2. Create a file named in the <SERVICE_PROVIDER_IS_HOME>/repository/conf/identity/service-providers directory.
  3. Add the following configurations into the file you created. This adds the necessary SAML configurations to the travelocity service provider.

    If you added the "SHARED_" prefix to the identity provider name when adding the identity provider, replace the  <IdentityProviderName>  value (found under the  <LocalAndOutBoundAuthenticationConfig>  element) in the  file, with the following value.

        <Description>travelocity Service Provider</Description>

Running the travelocity application

Do the following steps to run the travelocity application.

  1. Check out the single sign on sample from the following GitHub repository. See the Downloading a Sample topic for more information.
  2. Remove the parent entry in the pom.xml file that comes along with the sample. Once you are done with this step, the contents of the pom.xml file will look similar to the following.

    <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    	<name>Identity Server : SSO Samples</name>
  3. In your command line, navigate to <SAMPLE_HOME>/sso/ in the folder you checked out and build the sample using the following command. You must have Apache Maven installed to do this (see Installation Prerequisites for the appropriate version to use).

    mvn clean install
  4. After successfully building the sample, a .war file named can be found inside the <HOME>/sso/SSOAgentSample/ target folder. Deploy this sample web app on a web container. To do this, use the Apache Tomcat server.

    Note: 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:

    1. Stop the Apache Tomcat server if it is already running.
    2. Copy the travelocity.war file to the <TOMCAT_HOME>/webapps folder.
    3. Start the Apache Tomcat server.
  5. When you access the following link to the travelocity application, you are directed to the identity provider for authentication: http://localhost:8080/

Testing with tenants

Now you can test if the configurations you have done work in a tenant scenario.

  1. Create new tenants in the  service provider IS .

    Note: You cannot provide access to the service provider and identity provider for a specific tenant domain. This is accessible to all the tenants configured.

  2. Open the <TOMCAT_HOME>/webapps/­INF/classes/ file.

     Click here to see the full contents of the file.
    #This is the URL of the page that is used to choose the login scheme
    #such as SAML SSO or OpenID. This Url will not be processed by the
    #Url to do send SAMLSSO AuthnRequest
    #Url to do send SAML2 Grant OAuth2 Request
    #Url to send OpenID Authentication Request
    #A unique identifier for this SAML 2.0 Service Provider application
    #SAML.Request.Query.Param=&tenantDomain=tenant.domain#The URL of the SAML 2.0 Assertion Consumer
    #The URL of the SAML 2.0 Identity Provider
    #This is the attribute name under which the authenticated session information
    #of SAML SSO and OpenID are stored
    #Identifier given for the Service Provider for SAML 2.0 attributes
    #Specify if SingleLogout is enabled/disabled
    #This is the URL that is used for SLO
    #Specify if SAMLResponse element is signed
    #Specify if SAMLAssertion element is signed
    #Specify if SAMLAssertion element is encrypted
    #Specify if AuthnRequests and LogoutRequests should be signed
    #Specify if force authentication enabled
    #Custom credentials class
    #KeyStore to cryptographic credentials
    #Password of the KeyStore for SAML and OpenID
    #Alias of the IdP's public certificate
    SAML.IdPCertAlias=wso2carbon#Alias of the SP's private key
    #Private key password to retrieve the private key used to sign
    #AuthnRequest and LogoutRequest messages
    #OAuth2 token endpoint URL
    #OAuth2 Client ID
    #OAuth2 Client Secret
    #OpenId Provider Url
    #openid.return_to parameter
    #This is the request parameter name under which to find the
    #openid.claimed_id value to send OpenID authentication request
    #Custom OpenID AttributesRequestor class
    #Additional request parameters
  3. In the file, locate and uncomment the following value. Replace the tenant domain (tenant.domain) with your newly created tenant domain.


    Tip: You can uncomment values in this file by removing the “#”.

  4. If you made any changes to the port offset, you must ensure that this change is reflected in the port value of the following property.

  5. Restart Apache Tomcat and access the travelocity application. You will be able to log in using the identity provider credentials regardless of the tenant domain you are using. Access the travelocity application using the following: http://localhost:8080/

Related links

The following links provide additional information that may be relevant when attempting the instructions in this topic.

  • No labels