Skip to content

Configuring a Separate JDBC Session Store

WSO2 identity server uses the identity database as the session store. This document will guide to you to configure a separate JDBC session store. By default, the WSO2 Identity Server embedded H2 database contains session store tables.

Configuring the internal database as session store

Add the following configuration to <IS-HOME>/repository/conf/deployment.toml.

[session]
data_source="jdbc/WSO2SessionDB"
[datasource.WSO2SessionDB]
id = "WSO2SessionDB"
url = "jdbc:h2:./repository/database/WSO2IDENTITY_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000"
username = "wso2carbon"
password = "wso2carbon"
driver = "org.h2.Driver"
[datasource.WSO2SessionDB.pool_options]
defaultAutoCommit = true
maxActive = 50
maxWait = 60000
jmx_enable = false
validationInterval = 30000

Configuring an external database as JDBC user store.

  1. Create a database on any supported RDBMS database.

  2. Following are the example configurations for each database type.

PostgreSQL
  1. deployment.toml Configurations.

    [session]
    data_source="jdbc/WSO2SessionDB"
    [datasource.WSO2SessionDB]
    url = "jdbc:postgresql://localhost:5432/sessiondb"
    username = "root"
    password = "root"
    driver = "org.postgresql.Driver"

  2. Execute the database scripts.

    Navigate to <IS-HOME>/dbscripts/identity/postgresql.sql. Execute the scripts in the following tables. IDN_AUTH_SESSION_STORE IDN_AUTH_SESSION_APP_INFO IDN_AUTH_SESSION_META_DATA IDN_AUTH_TEMP_SESSION_STORE IDN_AUTH_USER IDN_AUTH_USER_SESSION_MAPPING IDN_AUTH_WAIT_STATUS

    Execute the scripts related to following indexes.

    IDX_IDN_AUTH_SESSION_TIME IDX_IDN_AUTH_TMP_SESSION_TIME IDX_AUTH_USER_UN_TID_DN IDX_AUTH_USER_DN_TOD IDX_USER_ID IDX_SESSION_ID against the database created.

  3. Download the PostgreSQL JDBC driver for the version you are using and copy it to the <IS_HOME>/repository/components/lib folder.

MySQL
  1. deployment.toml Configurations.

    [session]
    data_source="jdbc/WSO2SessionDB"
    [datasource.WSO2SessionDB]
    url = "jdbc:mysql://localhost:3306/sessiondb?useSSL=false"
    username = "root"
    password = "root"
    driver = "com.mysql.jdbc.Driver"

  2. Execute the database scripts.

    Navigate to <IS-HOME>/dbscripts/identity/mysql.sql. Execute the scripts in the following tables. IDN_AUTH_SESSION_STORE IDN_AUTH_SESSION_APP_INFO IDN_AUTH_SESSION_META_DATA IDN_AUTH_TEMP_SESSION_STORE IDN_AUTH_USER IDN_AUTH_USER_SESSION_MAPPING IDN_AUTH_WAIT_STATUS

    Execute the scripts related to following indexes.

    IDX_IDN_AUTH_SESSION_TIME IDX_IDN_AUTH_TMP_SESSION_TIME IDX_AUTH_USER_UN_TID_DN IDX_AUTH_USER_DN_TOD IDX_USER_ID IDX_SESSION_ID against the database created.

  3. Download the MySQL JDBC driver for the version you are using and copy it to the <IS_HOME>/repository/components/lib folder.

DB2
  1. deployment.toml Configurations.
    [session]
    data_source="jdbc/WSO2SessionDB"
    [datasource.WSO2SessionDB]
    url = "jdbc:db2://localhost:50000/sessiondb"
    username = "root"
    password = "root"
    driver = "com.ibm.db2.jcc.DB2Driver"
  2. Execute the database scripts.

    Navigate to <IS-HOME>/dbscripts/identity/db2.sql. Execute the scripts in the following tables. IDN_AUTH_SESSION_STORE IDN_AUTH_SESSION_APP_INFO IDN_AUTH_SESSION_META_DATA IDN_AUTH_TEMP_SESSION_STORE IDN_AUTH_USER IDN_AUTH_USER_SESSION_MAPPING IDN_AUTH_WAIT_STATUS

    Execute the scripts related to following indexes

    IDX_IDN_AUTH_SESSION_TIME IDX_IDN_AUTH_TMP_SESSION_TIME IDX_AUTH_USER_UN_TID_DN IDX_AUTH_USER_DN_TOD IDX_USER_ID IDX_SESSION_ID against the database created.

  3. Download the DB2 JDBC driver for the version you are using and copy it to the <IS_HOME>/repository/components/lib folder.

MSSQL
  1. deployment.toml Configurations.
    [session]
    data_source="jdbc/WSO2SessionDB"
    [datasource.WSO2SessionDB]
    url = "jdbc:sqlserver://localhost:1433;databaseName=sessiondb;SendStringParametersAsUnicode=false"
    username = "root"
    password = "root"
    driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  2. Execute the database scripts.

    Navigate to <IS-HOME>/dbscripts/identity/mssql.sql. Execute the scripts in the following tables. IDN_AUTH_SESSION_STORE IDN_AUTH_SESSION_APP_INFO IDN_AUTH_SESSION_META_DATA IDN_AUTH_TEMP_SESSION_STORE IDN_AUTH_USER IDN_AUTH_USER_SESSION_MAPPING IDN_AUTH_WAIT_STATUS

    Execute the scripts related to following indexes

    IDX_IDN_AUTH_SESSION_TIME IDX_IDN_AUTH_TMP_SESSION_TIME IDX_AUTH_USER_UN_TID_DN IDX_AUTH_USER_DN_TOD IDX_USER_ID IDX_SESSION_ID against the database created.

  3. Download the MSSQL JDBC driver for the version you are using and copy it to the <IS_HOME>/repository/components/lib folder.

Oracle
  1. deployment.toml Configurations.
    [session]
    data_source="jdbc/WSO2SessionDB"
    [datasource.WSO2SessionDB]
    url = "jdbc:oracle:thin:@localhost:1521/sessiondb"
    username = "root"
    password = "root"
    driver = "oracle.jdbc.OracleDriver"
  2. Execute the database scripts.

    Navigate to <IS-HOME>/dbscripts/identity/oracle.sql. Execute the scripts in the following tables. IDN_AUTH_SESSION_STORE IDN_AUTH_SESSION_APP_INFO IDN_AUTH_SESSION_META_DATA IDN_AUTH_TEMP_SESSION_STORE IDN_AUTH_USER IDN_AUTH_USER_SESSION_MAPPING IDN_AUTH_WAIT_STATUS

    Execute the scripts related to following indexes.

    IDX_IDN_AUTH_SESSION_TIME IDX_IDN_AUTH_TMP_SESSION_TIME IDX_AUTH_USER_UN_TID_DN IDX_AUTH_USER_DN_TOD IDX_USER_ID IDX_SESSION_ID against the database created.

  3. Download the Oracle JDBC driver for the version you are using and copy it to the <IS_HOME>/repository/components/lib folder.

Top