com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Configuring Single Sign-on with SAML 2.0

Single sign-on (SSO) allows users, who are authenticated against one application, gain access to multiple other related applications as well without having to repeatedly authenticate themselves. It also allows the Web applications gain access to a set of back-end services with the logged-in user's access rights, and the back-end services can authorize the user based on different claims like user role.

WSO2 API Manager includes Single Sign-On with SAML 2.0 feature, which is implemented according to the SAML 2.0 Web browser-based SSO support that is facilitated by WSO2 Identity Server (IS). This feature is available in any IS version from 4.1.0 onwards. We use IS 5.0.0 in this guide. WSO2 Identity Server acts as an identity service provider of systems enabled with single sign-on, while the Web applications such as API Manager apps act as SSO service providers. Using this feature, you can configure SSO across the two API Manager Web applications, which are API Publisher and API Store as well as other Web applications in your organization. After configuring, you will be able to access API Store or API Publisher in a single authentication attempt.

To learn more about Single Sign-On with WSO2 Identity Server, see the following article in WSO2 library: http://wso2.org/library/articles/2010/07/saml2-web-browser-based-sso-wso2-identity-server.

The topics below explain the configurations: 

For example, let's take a common JDBC user store (MySQL) for both IS and API Manager.

  1. Create a MySQL database (e.g., 410_um_db) and run the <AM_HOME>/dbscripts/mysql.sql script on it to create the required tables. 
    If you are using a different database type, find the relevant script from the <AM_HOME>/dbscripts directory.

  2. Open <AM_HOME>/repository/conf/datasources/master-datasources.xml file and add the datasource configuration for the database that you use for the shared user store and user management information. For example,

    <datasource>
         <name>WSO2_UM_DB</name>
         <description>The datasource used for registry and user manager</description>
         <jndiConfig>
                  <name>jdbc/WSO2UMDB</name>
         </jndiConfig>
         <definition type="RDBMS">
                  <configuration>
                      <url>jdbc:mysql://localhost:3306/410_um_db</url>
                      <username>username</username>
                      <password>password</password>
                      <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                      <maxActive>50</maxActive>
                      <maxWait>60000</maxWait>
                      <testOnBorrow>true</testOnBorrow>
                      <validationQuery>SELECT 1</validationQuery>
                      <validationInterval>30000</validationInterval>
                  </configuration>
           </definition>
    </datasource>
  3. Add the same datasource configuration above to <IS_HOME>/repository/conf/datasources/master-datasources.xml file.

  4. Copy the database driver JAR file to the <IS_HOME>/repository/components/lib and <AM_HOME>/repository/components/lib directories.

  5. Open <AM_HOME>/repository/conf/user-mgt.xml file. The dataSource property points to the default H2 database. Change it to the jndiConfig name given above (i.e., jdbc/WSO2UMDB). This changes the datasource reference that is pointing to the default H2 database.

    <Realm>
            <Configuration>
                ...
                <Property name="dataSource">jdbc/WSO2UMDB</Property>
            </Configuration>
            ...
    </Realm> 
  6. Add the same configuration above to the <IS_HOME>/repository/conf/user-mgt.xml file.
  7. The Identity Server has an embedded LDAP user store by default. As this is enabled by default, follow the instructions in Internal JDBC User Store Configuration to disable the default LDAP and enable the JDBC user store instead.

Sharing the registry space

Let's share a common registry space between the IS and APIM. This can be done by creating a registry database and mounting it on both the IS and APIM.

  1. Create a MySQL database (e.g., registry) and run the <IS_HOME>/dbscripts/mysql.sql script on it to create the required tables. 
    If you are using a different database type, find the relevant script from the <IS_HOME>/dbscripts directory.

  2. Add the following datasource configuration to both the <IS_HOME>/repository/conf/datasources/master-datasources.xml and <AM_HOME>/repository/conf/datasources/master-datasources.xml files.

    <datasource>
        <name>WSO2REG_DB</name>
        <description>The datasource used for registry</description>
        <jndiConfig>
            <name>jdbc/WSO2REG_DB</name>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>
                <url>jdbc:mysql://localhost:3306/registry?autoReconnect=true&amp;relaxAutoCommit=true&amp;</url>
                <username>apiuser</username>
                <password>apimanager</password>
                <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                <maxActive>50</maxActive>
                <maxWait>60000</maxWait>
                <testOnBorrow>true</testOnBorrow>
                <validationQuery>SELECT 1</validationQuery>
                <validationInterval>30000</validationInterval>
            </configuration>
        </definition>
    </datasource> 
  3. Create the registry mounts by inserting the following sections into the  <IS_HOME>/repository/conf/registry.xml  file.

    When doing this change, do not replace the existing <dbConfig> for "wso2registry". Simply add the following configuration to the existing configurations.

     

    <dbConfig name="govregistry">
            <dataSource>jdbc/WSO2REG_DB</dataSource>
    </dbConfig>
     
    <remoteInstance url="https://localhost">    
            <id>gov</id>
            <dbConfig>govregistry</dbConfig>
            <readOnly>false</readOnly>
            <enableCache>true</enableCache>
            <registryRoot>/</registryRoot>
    </remoteInstance>
     
    <mount path="/_system/governance" overwrite="true">
            <instanceId>gov</instanceId>
            <targetPath>/_system/governance</targetPath>
    </mount>
     
    <mount path="/_system/config" overwrite="true">
           <instanceId>gov</instanceId>
           <targetPath>/_system/config</targetPath>
    </mount>
  4. Repeat the above step in the  <AM_HOME>/repository/conf/registry.xml  file as well.

Next, let us look at the SSO configurations. 

Configuring WSO2 Identity Server as a SAML 2.0 SSO Identity Provider

  1. Start the IS server and log in to its Management Console UI ( https://localhost:9443/carbon).   

    If you use login pages that are hosted externally to log in to the Identity Server, give the absolute URLs of those login pages in the authenticators.xml and application-authenticators.xml files in the   <IS_HOME>/repository/conf/security  directory.

  2. Select Add under Service Providers menu.
  3. Give a service provider name and click Register.

    Tip: If you are working in a multi tenanted environment and you want all tenants to be able to log in to the APIM Web applications, you must click the SaaS Application option that appears after registering the service provider.

    If not, only users in the current tenant domain (the one you are defining the service provider in) will be allowed to log in to the Web application and you have to register new service providers for all Web applications (API Store and API Publisher in this case) from each tenant space separately. For example, let's say you have three tenants as TA, TB and TC and you register the service provider in TA only. If you tick the SaaS Application option, all users in TA, TB, TC tenant domains will be able to log in. Else, only users in TA will be able to log in.

  4. You are navigated to the detailed configuration page. Expand SAML2 Web SSO Configuration inside the Inbound Authentication Configuration section.

  5. Expand SAML2 Web SSO Configuration inside the Inbound Authentication Configuration section.
  6. Pro vide the following configurations to register the API Manager Web applications as SSO service providers.

    In the following configurations, use the exact values that were used to configure the API Manager Web applications.

    To register API Publisher as an SSO service provider:

      • Issuer : API_PUBLISHER
      • Assertion Consumer URL: https://localhost:9443/publisher/jagg/jaggery_acs.jag. Change the IP and port accordingly. This is the URL for the acs page in your running publisher app.
      • Select the following options:

        • Use fully qualified username in the NameID  

        • Enable Response Signing

        • Enable Assertion Signing

        • Enable Single Logout

      • Click Register once done.

    To register API Store as an SSO service provider:

      • Issuer : API_STORE
      • Assertion Consumer URL: https://localhost:9443/store/jagg/jaggery_acs.jag. Change the IP and port accordingly. This is the URL for the acs page in your running store app.
      • Select the following options:
        • Use fully qualified username in the NameID  
        • Enable Response Signing  
        • Enable Assertion Signing  
        • Enable Single Logout    
      • Click Register once done.

For example:

Configuring WSO2 API Manager Apps as SAML 2.0 SSO Service Providers

  1. Open <AM_Home>/repository/deployment/server/jaggeryapps/publisher/site/conf/site.json and modify the following configurations found under ssoConfiguration.
    • keyStoreName: The keystore of the running IDP. As you use a remote instance of WSO2 IS here, you can import the public certificate of the IS keystore to the APIM and then point to the APIM keystore. The default keystore of the APIM is <APIM_HOME>/repository/resources/security/wso2carbon.jks Be sure to give the full path of the keystore here.
    • keyStorePassword: Password for the above keystore.
    • identityAlias: wso2carbon.
    • enabled: Set this value to true to enable SSO in the application.
    • issuer: API_PUBLISHER. This value can change depending on the Issuer value defined in WSO2 IS SSO configuration above.
    • identityProviderURL: https://localhost:9444/samlsso. Change the IP and port accordingly. This is the redirecting SSO URL in your running WSO2 IS server instance.
  2. Similarly, configure the API Store with SSO. The only difference in API Store SSO configurations is setting API_STORE as the issuer.
  3. Access the API Publisher : https://localhost:<Port number>/publisher (e.g., https://localhost:9443/publisher). Observe the request redirect to the WSO2 IS SAML2.0 based SSO login page. For example,
  4. Enter user credentials. If the user authentication is successful against WSO2 IS, it will redirect to the API Publisher Web application with the user already authenticated.
  5. Access the API Store application, click its Login link (top, right-hand corner) and verify that the same user is already authenticated in API Store.

Even with SSO enabled, if the user doesn't have sufficient privileges to access API Publisher/Store or any other application, s/he will not be authorized to access them.

If there are many WSO2 products in your environment, you can configure SSO for the management consoles of all products by changing the SAML2SSOAuthenticator configuration in <PRODUCT_HOME>/repository/conf/security/authenticators.xml file as follows:

  • Set disabled attributes in <Authenticator> element to false
  • ServiceProviderID : In this example, it is the issuer name of the service provider created in step 1
  • IdentityProviderSSOServiceURL : In this example, it is the Identity Server port

    <Authenticator name="SAML2SSOAuthenticator" disabled="false">
            <Priority>10</Priority>
            <Config>
                <Parameter name="LoginPage">/carbon/admin/login.jsp</Parameter>
                <Parameter name="ServiceProviderID">carbonserver1</Parameter>
    			<Parameter name="IdentityProviderSSOServiceURL">https://localhost:9444/samlsso</Parameter>
                <Parameter name="NameIDPolicyFormat">urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</Parameter>
    </Config>

    Make sure the <priority> of the SAML2SSOAuthenticator is less than that of the BasicAuthenticator handler. See here for more information.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.