Open Closed

TokenCleanupOptions Not Applying #4368


User avatar
0
jackmcelhinney created
  • ABP Framework version: v6.0.2
  • UI type: Angular
  • DB provider: EF Core
  • Identity Server Separated (Angular): no

After updating to OpenIddict, we want to adjust the token lifetimes and pruning behavior. We successfully changed the lifetimes with PreConfigure<OpenIddictServerBuilder> in the Host module, but PreConfigure<TokenCleanupOptions> is not working.

Host module:

public override void PreConfigureServices(ServiceConfigurationContext context)
{
    ...
    PreConfigure<OpenIddictServerBuilder>(builder =>
    {
        ...
        builder.SetRefreshTokenLifetime(TimeSpan.FromMinutes(15)); // Test lifetime
    });
    
    PreConfigure<TokenCleanupOptions>(options =>
    {
        options.CleanupPeriod = 60000;
        options.MinimumAuthorizationLifespan = TimeSpan.FromMinutes(15);
        options.MinimumTokenLifespan = TimeSpan.FromMinutes(15);
    });
    ...
}

With these values, the refresh token lifetime is set to 15 minutes, but the pruning job still runs once an hour and does not use the new minimum lifespans. Is this a bug or is something wrong with this configuration?

Thanks!


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<TokenCleanupOptions>(options =>
        {
            options.CleanupPeriod = 60000; //Default: 3,600,000 ms, 1 hour
            options.MinimumAuthorizationLifespan = TimeSpan.FromMinutes(15);
            options.MinimumTokenLifespan = TimeSpan.FromMinutes(15);
        });
    }
    
  • User Avatar
    0
    jackmcelhinney created

    Thanks @maliming that worked. This section of the docs may need to be updated to use Configure instead of PreConfigure:

    https://docs.abp.io/en/abp/latest/Modules/OpenIddict#automatically-removing-orphaned-tokens-authorizations

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07