Hello.
I found, that issuing a new token takes too much time when AbpUserTokens table has more than a few thousands records. This is caused by the way UserRepository adds new record to the table.
AbpUserStore.cs:
public virtual async Task AddTokenValidityKeyAsync(...)
{
...
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
user.Tokens.Add(new UserToken(user, TokenValidityKeyProvider, tokenValidityKey, null, expireDate));
...
}
In the tickets with similar issue (https://support.aspnetzero.com/QA/Questions/10764/Bad-performance-due-to-AbpUserTokens-table, https://support.aspnetzero.com/QA/Questions/10764/Bad-performance-due-to-AbpUserTokens-table) the suggesting was to clear the table from time to time. But what is the purpose of the stored information at all? Where is the data from this table used? Is it possible to skip saving tokens info at all and what side effects will I get then?
P.S. Asp.net zero 12.0
5 Answer(s)
-
0
Hi,
You shouldn't remove this functionality, it is used by the framework. Do you have backgroundjobs enabled on your app ? If so, this job https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore/Zero/AbpZeroCoreModule.cs#L37 should remove expired items.
-
0
Hello,
This background job is enabled, but the table contains few thousands not expired token items. What exactly are this records used for?
-
0
Hi @npdevs
It is used to support token based authentication. We will be working on this problem https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5244. If that doesn't affect your app, you can disable this feature.
-
0
Hello again,
I see AddTokenValidityKeyAsync method which inserts new token record without loading a full list of tokens was introduced (https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5244#issuecomment-1446209120), but it is still not used by TokenAuthController (v12.3.1). Could you please explain why?
Thanks.
-
0