Agrando / IdentityServer.Contrib.RavenDB

RavenDB stores for Identityserver v3
0 stars 0 forks source link

Tokens can be cleaned up before expected #2

Closed ben-jacobs closed 7 years ago

ben-jacobs commented 7 years ago

If the server time isn't set to UTC, then Tokens can be potentially cleaned up before expected (e.g. in +10:30 they effectively get cleaned up immediately. Changing DateTimeOffset.Now to DateTimeOffset.UtcNow appears to fix the problem.

Cheers Ben

private async Task ClearTokens()
        {
            try
            {
                Logger.Info("Clearing tokens");
                await options.Store.AsyncDatabaseCommands.DeleteByIndexAsync("TokenCleanupIndex",
                    new IndexQuery
                    {
                        Query = "Expires:[* TO \"" + DateTimeOffset.UtcNow.ToString("s") + "\"]"
                    }, new BulkOperationOptions
                    {
                        AllowStale = true
                    });
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Exception cleaning tokens", ex);
            }
        }
bjarteskogoy commented 7 years ago

Thanks. Should be fixed in this commit: 9e38bd3ce8eaba07392bbfe113ecb84d8ec4ad26