在使用OWIN / Katana的Azure上,数据保护操作失败 [英] The data protection operation was unsuccessful on Azure using OWIN / Katana

查看:193
本文介绍了在使用OWIN / Katana的Azure上,数据保护操作失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试在运行在Azure上的基于OWIN / Katana的APS.NET MVC网站上实施密码重置。

  userManager.UserTokenProvider = new DataProtectorTokenProvider< ApplicationUser>(provider.Create(PasswordReset))

但是当我尝试生成



任何帮助都将不胜感激。



/ p>

  var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user.Id); 

System.Security.Cryptography.CryptographicException:数据保护操作未成功。这可能是因为没有为当前线程的用户上下文加载用户配置文件,这可能是线程模拟时的情况。
at System.Security.Cryptography.ProtectedData.Protect(Byte [] userData,Byte [] optionalEntropy,DataProtectionScope scope)
在System.Security.Cryptography.DpapiDataProtector.ProviderProtect(Byte [] userData)
at System.Security.Cryptography.DataProtector.Protect(Byte [] userData)
at Microsoft.Owin.Security.DataProtection.DpapiDataProtector.Protect(Byte [] userData)
at Microsoft.AspNet.Identity .Owin.DataProtectorTokenProvider`2。< GenerateAsync> d__0.MoveNext()
---从引发异常的上一个位置的堆栈跟踪结束 -
在System.Runtime.CompilerServices.TaskAwaiter。 ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
在Microsoft.AspNet.Identity.UserManager`2。< GenerateUserTokenAsync> d__e9.MoveNext()


解决方案

请参阅我的我的回答这个问题。一个更简单的解决方案可以通过使用 IAppBuilder.GetDataProtectionProvider()


I'm trying to implement password reset on an OWIN/Katana based APS.NET MVC website running in Azure.

It works fine when run locally but fails in production.

I create a UserToken Provider

 userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("PasswordReset"))

But when I attempt to generate the token as follows I get an exception show at end.

Any assistance would be appreciated.

Mat

var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
   at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope)
   at System.Security.Cryptography.DpapiDataProtector.ProviderProtect(Byte[] userData)
   at System.Security.Cryptography.DataProtector.Protect(Byte[] userData)
   at Microsoft.Owin.Security.DataProtection.DpapiDataProtector.Protect(Byte[] userData)
   at Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider`2.<GenerateAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.Identity.UserManager`2.<GenerateUserTokenAsync>d__e9.MoveNext()

解决方案

Please see my my answer to this question. A much simpler solution can be achieved by utilizing IAppBuilder.GetDataProtectionProvider()

这篇关于在使用OWIN / Katana的Azure上,数据保护操作失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆