Oauth重新生成标识回调不工作
我正在应用程序中使用oauth和owin进行身份验证。 我希望在一段时间间隔内使用新声明重新生成标识,但从未调用分配给它的函数处理程序的方法 这是我的密码:Oauth重新生成标识回调不工作,oauth,owin,Oauth,Owin,我正在应用程序中使用oauth和owin进行身份验证。 我希望在一段时间间隔内使用新声明重新生成标识,但从未调用分配给它的函数处理程序的方法 这是我的密码: public static void ConfigureCookieAuthentication(IAppBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions { Authe
public static void ConfigureCookieAuthentication(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(30),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, PouyaKianParham.ContentProviderSystem.BusinessObjectLayer.Account.Models.ApplicationUser, int>(
validateInterval: TimeSpan.FromSeconds(15),
regenerateIdentityCallback: (a, b) => GenerateUserIdentityAsync(null,null),
getUserIdCallback: (id) => (id.GetUserId<int>()))
},
LoginPath = new PathString("/Account/Login")
});
}
公共静态无效配置CookieAuthentication(IAppBuilder应用程序)
{
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationOkie,
ExpireTimeSpan=时间跨度从分钟(30),
Provider=新CookieAuthenticationProvider
{
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromSeconds(15),
regenerateIdentityCallback:(a,b)=>GenerateUserIdentityAsync(null,null),
getUserIdCallback:(id)=>(id.GetUserId())
},
LoginPath=新路径字符串(“/Account/Login”)
});
}
下面是我的回调方法(也在OAuthconfig.cs中):
公共静态异步任务GenerateUserIdentityAsync(ApplicationUserManager ApplicationUserManager,UserManager)
{
//用新的声明重新定义身份
返回标识WithClaim;
}
提前感谢我也遇到了同样的问题,但以下几点对我有效。
我使用UserStore、UserManager等的自定义实现。事实证明,UserStore必须实现
IUserSecurityStampStore
实施后,需要时会调用
regenerateIdentityCallback
委托,一切都很顺利。感谢您的回答,我将尝试一下,并将结果通知您:)
public static async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager ApplicationUserManager, UserManager manager)
{
//regenrating identity with new claims
return identitywithClaim;
}