Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

ExpiredTokenCollector gone? #36

Closed
LeandroPT opened this issue Jan 12, 2015 · 4 comments
Closed

ExpiredTokenCollector gone? #36

LeandroPT opened this issue Jan 12, 2015 · 4 comments
Assignees

Comments

@LeandroPT
Copy link

Hello,

I see that the ExpiredTokenCollector (reported in #3) disappeared..
Is this intended?

@brockallen
Copy link
Member

We're not sure what we want to do with this. Stay tuned.

@brockallen
Copy link
Member

We won't ship this in RTM. You can add your own app to do this using the DbContexts.

@brockallen
Copy link
Member

I added a token cleanup helper on dev. Take a look and provide some feedback.

@LeandroPT
Copy link
Author

Hello,

Well.... it kind of works....

Why it didn't make it for me? Because of the following block:

private async Task ClearTokens()
        {
            try
            {
                Logger.Info("Clearing tokens");

                using (var db = new OperationalDbContext(this.options.ConnectionString, this.options.Schema))
                {
                    var query =
                        from token in db.Tokens
                        where token.Expiry < DateTimeOffset.UtcNow
                        select token;

                    db.Tokens.RemoveRange(query);

                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Exception cleanring tokens", ex);
            }
        }

Since it is possible to "inject" the context, this class should not directly instantiate the DbContext, but instead see the IdentityServer factory for identity manager for the OperationalDbContext.
So it kind of sucks to be in this class....

A question has arisen in my head, how will IDSRV handle expired tokens?
It is the developer that has to implement in production a "batch" to erase those?
The tokens table will increase until the end of the world, or disk space full?

Provocative Question: Shouldn't this be in Thinktecture.IdentityServer.Core.Services.ITokenService?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants