Skip to content

Remove Unused Tokens from the Database

As you use MWARE IAM, the number of revoked, inactive, and expired tokens accumulate in the IDN_OAUTH2_ACCESS_TOKEN table. These tokens are kept in the database for logging and audit purposes but they can have a negative impact on the server's performance over time. Therefore, it is recommended to clean them periodically in order to enhance the token lookup and to avoid a growing access token table.

You can use one of the following methods for token cleanup.

Note

We recommend using stored procedures instead of the MWARE IAM to cleanup tokens.


Use the store procedure for token cleanup

You can use the provided stored procedures to run a token cleanup task periodically to remove the old and invalid tokens. Follow the instructions below to configure token cleanup using this method.

Tip

It is safe to run these steps in read-only mode or during a time when traffic on the server is low, but it is not mandatory.

  1. Disable the internal token cleanup process by configuring the following property in the deployment.toml file found in the <IS_HOME>/repository/conf folder.

    [oauth.token_cleanup]
    enable = false
  2. Depending on your database, select the appropriate token cleanup script based on the links mentioned in the sub-points below and run it on the database. This takes a backup of the necessary tables, turns off SQL updates and cleans the database of unused tokens.

  3. Once the cleanup is over, start the MWARE IAM pointing to the cleaned-up database. You can also schedule a cleanup task that will be automatically run after a given period of time.

Configure MWARE IAM for token cleanup

Alternatively, you can use the MWARE IAM, which triggers token cleanup during the following instances.

  1. New token generation
  2. Token refresh
  3. Token revocation

Enable token cleanup by configuring the following properties in the deployment.toml file found in the <IS_HOME>/repository/conf folder.

[oauth.token_cleanup]
enable = true
retain_access_tokens_for_auditing = true
Property Description
enable

Set this property to true to enable token cleanup.

Set it to false to disable token cleanup.

retain_access_tokens_for_auditing

Set this property to true to move the old, invalid tokens to the Audit table when token cleaning is enabled.

Set it to false if you do not wish to store old tokens in the Audit table.


Top