This documentation is for older versions of WSO2 products and may not be relevant now. Please see your respective product documentation for clustering details and configurations.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Mentioned examples of the artifacts are shared in the reg_DB with IS as KM and APIM.

...

  1. Log into the Identity Server and access the Management Console.
  2. After starting the Identity Server, install the Key Manager feature.

    Warning

    Warning: Installing this feature will result in changes to some of the configuration files in Identity Server. The <IS_HOME>/repository/conf/identity.xml file and the <IS_HOME>/repository/conf/datasources/master-datasouces.xml file will lose their current configurations.

    To install the feature:

    1. Navigate to the Features section in the Configure menu of the management console.
    2. Add the following feature repository in the Feature Management section in the Identity Server. See here for information on how to do this.
      P2 Repohttp://product-dist.wso2.com/p2/carbon/releases/wilkes/
    3. After adding the repository, navigate to the Available Features tab and find the feature in that repository by clicking the Find Features button. The list of available features appear.

      1. Expand the API Key Manager feature from the Features category and select API Key Manager 5.0.3.
      2. Click on the Install button and go through the wizard to complete the installation. See here if you require more information on how to do this.
  3. Download WSO2 API Manager from here  and install it .
  4. Copy the  identity.xml  file from the <APIM_HOME>/repository/conf/identity  directory and paste it into the <IS_HOME>/repository/conf/identity directory. You must replace the file that is already available there. This is because you just installed the key manager feature, and you need to use a new identity.xml file that contains some additional changes.
  5. Copy the api-manager.xml file from the <APIM_HOME>/repository/conf directory and paste it into the <IS_HOME>/repository/conf directory. 
  6. Make the following changes in the api-manager.xml file you just copied. 

    1. Change the GatewayType property to the following. This is done because the default value here is Synapse. Synapse runtime is used for various ESB related functionality that is not available in the Identity Server, so this must be changed to None.
      <GatewayType>None</GatewayType>

    2. Change the <RevokeAPIURL> so that it points to the API Manager server. Note that if API Manager is running in distributed mode (has a separate node for the Gateway), you need to point this URL to the Gateway worker node. This is done so that when the token is revoked, the Gateway cache is updated as well. The port value you enter here must be the NIO port. See Default Ports of WSO2 Products for more information.
      <RevokeAPIURL> https://${GATEWAY_SERVER_HOST}:{port}/revoke </RevokeAPIURL>

    3. Change the <ServerURL> occurring under the <APIGateway> section so that it points to the API Manager server. If you are using distributed mode, this needs to point to the Gateway manager node. This is done so that when the token is regenerated, the Gateway cache is updated as well. The port value you enter here must be the management transport port. See Default Ports of WSO2 Products for more information.
      <ServerURL>https://${GATEWAY_SERVER_HOST}:{port}/services/</ServerURL>

    4. Change EnableThriftServer to false. The Identity Server does not come with a thrift server and this causes issues at runtime if not disabled.
      <EnableThriftServer>false</EnableThriftServer>

  7. Open the <IS_HOME>/repository/conf/datasources/master-datasources.xml file and add the following datasources.

    Info

    Ensure that you keep the 'WSO2_CARBON_DB' datasource the way it is and simply add the following datasources in the master-datasources.xml file. Also note that the WSO2AM_DB is already added in the master-datasources.xml file so you do not need to add it again. However, you must edit this datasource to point to your new database as this still points to the default H2 database. The following code block includes a sample of the WSO2AM_DB datasource as a sample configuration when pointing to the new database.

    Code Block
    languagexml
    <datasource>
        <name>WSO2AM_DB</name>
        <description>The datasource used for API Manager database</description>
        <jndiConfig>
            <name>jdbc/WSO2AM_DB</name>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>  <url>jdbc:mysql://localhost:3306/apimgt?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>
                <defaultAutoCommit>false</defaultAutoCommit>
            </configuration>
        </definition>
    </datasource>
     
    <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>
    
    <datasource>
        <name>WSO2UM_DB</name>
        <description>The datasource used for user management</description>
        <jndiConfig>
            <name>jdbc/WSO2UM_DB</name>
        </jndiConfig>
        <definition type="RDBMS">
            <configuration>
       <url>jdbc:mysql://localhost:3306/userstore?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>

    The following diagram illustrates how databases are shared between IS and APIM as per the above configuration.

    • WSO2REG_DB - This is used to keep the registry information. The registry database is shared between WSO2 IS as the Key Manager and WSO2 APIM to share artifacts such as, meta data configurations, policies, and API details.

    • WSO2UM_DB - This is used to store the permissions (i.e. permission store) and the internal roles of the users.

    • WSO2AM_DB - This will be used to keep the identity data and API-related data. This includes OAuth tokens and keys. When serving key-validation requests, the key manager validates whether there are subscriptions made by the particular key. For this WSO2AM_DB should be accessed.

  8. Make the following change to the  <IS_HOME>/repository/conf/registry.xml file. Create the registry mounts by inserting the following sections into the registry.xml file. 

    Info

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

    Code Block
    languagexml
    <dbConfig name="govregistry">
            <dataSource>jdbc/WSO2REG_DB</dataSource>
    </dbConfig>
    
    <remoteInstance url="https://localhost">	
            <id>gov</id>
            <dbConfig>govregistry</dbConfig>
    		<cacheId>apiuser@jdbc:mysql://localhost:3306/registry</cacheId>
            <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>
  9. Change the datasource in the user-mgt.xml file found in the <IS_HOME>/repository/conf/ directory to WSO2UM_DB.

    Code Block
    languagexml
    titleuser-mgt.xml configurations
    <Realm>
            <Configuration>
    			...
    			<Property name="dataSource">jdbc/WSO2UM_DB</Property>
            </Configuration>
    		...
    </Realm>
  10. Add the user store configuration correctly in the <IS_HOME>/repository/conf/user-mgt.xml file so that both the Identity Server and API Manager point to the same user store. For more information on configuring user stores, see here.

    Info

    You must change the <UserStoreManager> element here since the internal LDAP user store is used by default. The <UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager"> code block needs to be removed or modified and the right code block must be used.

     

  11. Create the following databases in the MySQL database server.

    • userstore

    • registry

    • apimgt

    For creating the userstore and registry database, use the <IS_HOME>/dbscripts/mysql.sql script.

    Note

    Note that MySQL is used as an example here and you can use a different database if required.

    When creating the apimgt db, run the following script; <APIM_HOME>/dbscripts/apimgt/mysql.sql. The script found in the <APIM_HOME>/dbscripts/apimgt/ directory has all the tables required to manage OAuth access tokens and also includes other identity-related features.

    Note

    You can change the CREATE TABLE statements to CREATE TABLE IF NOT EXISTS when running the identity scripts after you have run the apimgt script.

  12. Create a user ‘apiuser’ with password ‘apimanager’. Grant all permissions for this user in the above three databases. For example:

    Code Block
    languagesql
    grant all on apimgt.* TO apiuser@localhost identified by "apimanager";
    grant all on userstore.* TO apiuser@localhost identified by "apimanager"; 
    grant all on registry.* TO apiuser@localhost identified by "apimanager";
  13. JWT configuration must be done in the <IS_HOME>/repository/conf/api-manager.xml file in the Identity Server. See here for more information on JWT Token generation. Enable the ClaimsRetrieverImplClassConsumerDialectURI and SignatureAlgorithm. Set SignatureAlgorithm to NONE.

  14. Start the server for the changes to take effect.

...