翻译我去issues提问的回答内容
我提问的原因主要是我要做.net core ABP的Token刷新功能,基本都根据网上的文章整合进ABP了,在如何存储的时候,总觉得系统的AbpUserTokens表为啥不利用进来,但是又找不到相关介绍的文章,因此去issues提问,回答的内容分为3部分,有点杂,所以打算整理一份,以下为回答的原文
user token removal was implemented in #4441
By default, the worker run at an interval of 1 hours, you can configure it yourself. See https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#user-token-removal-period
The user token should be generated by Microsoft.AspNetCore.Identity via IUserAuthenticatorKeyStoreinterface
翻译:
1、用户令牌移除在#4441中实现
2、默认情况下,工作进程以1小时为间隔运行,您可以自己配置它。请参阅https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#user-token-removal-period
3、用户令牌应改通过继承Microsoft.aspnetcore.identity下的IUserAuthenticatorKeyStore接口生成
- Make
RemoveTokenValidityKeyAsync
delete ALL keys from the same TokenValidityKeyProvider - Remove auto clean up when calling
IsTokenValidityKeyValidAsync
- Introduce
UserTokenExpirationWorker
periodic job (1 hour) that start inPostInitialize
ofAbpZeroCoreModlue
Introduce clean up methodRemoveTokenValidityKeysAsync
that delete ALL keys that are older than the givenexpireDateTime
Impact
ExpiredUser.Tokens
will no longer be removed automatically when callingIsTokenValidityKeyValidAsync
ExpiredUser.Tokens
can be removed by callingRemoveTokenValidityKeysAsync(user)
使用RemoveTokenValidityKeyAsync
从TokenValidityKeyProvider中删除所有key相同的令牌
要移除自动清理,请调用IsTokenValidityKeyValidAsync在AbpZeroCoreModlue的PostInitialize
中
引入清除方法RemoveTokenValidityKeysAsync ,该方法删除所有早于给定expiredatetime的密钥 (这里为什么是删除线,可能是已经过期了)
影响
已过期的用户。调用IsTokenValidityKeyValidAsync时不再自动删除令牌
已过期的用户。可以通过调用removetokenvaliditykeysasync(user)删除令牌
具体的实现方法在源码的 src/Abp.ZeroCore/Authorization/Users/AbpUserStore.cs
第二部分:修改工作进程间隔时间
User token removal period
ABP Framework defines a background worker named UserTokenExpirationWorker which cleans the records in table AbpUserTokens. If you disable background job execution, this worker will not run. By default, UserTokenExpirationWorker runs every one hour. If you want to change this period, you can configure it like below:
用户令牌移除期
abp框架定义了一个名为UserTokenExpirationWorker 的后台工作进程,它清除表AbpUserTokens中的记录。如果禁用后台作业执行,则此工作进程将不会运行。默认情况下,UserTokenExpirationWorker 每一小时运行一次。如果要更改此时段,可以如下配置:
public class MyProjectWebModule : AbpModule { public override void PreInitialize() { Configuration.BackgroundJobs.CleanUserTokenPeriod = 1 * 60 * 60 * 1000; // 1 hour } //... }
3、如何生成用户令牌
IUserAuthenticatorKeyStore<TUser> Interface
提供存储有关用户身份验证器信息的存储的抽象。
他最重要的方法应该是这两个,可是为何我还一脸懵逼呢,不过既然主要的点都提到了,剩下的应该就是百度了