微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – Azure Active Directory Auth Broken – 没有已知的根本原因

我正在构建一个依赖于AAD auth的ASP.NET MVC Web应用程序.我使用标准流程将auth添加到项目中(通过VS的AAD Auth),它在过去两周内完美运行.

今天,它突然被打破了:

ASP.NET MVC Error


ASP.NET MVC Error 2


这发生在ADALTokenCache初始化(标准AAD身份验证例程):

public ADALTokenCache(string signedInUserId)
{ 
    // associate the cache to the current user of the web app
    userId = signedInUserId;
    this.Afteraccess = AfteraccessNotification;
    this.BeforeAccess = BeforeAccessNotification;
    this.BeforeWrite = BeforeWriteNotification;
    // look up the entry in the database
    Cache = db.UserTokenCacheList.FirstOrDefault(c => c.webUserUniqueId == userId);
    // place the entry in memory
    this.Deserialize((Cache == null) ? null : MachineKey.Unprotect(Cache.cacheBits,"ADALCache"));
}

看起来很奇怪,根本原因对我来说是未知的 – 除了添加更多视图和控制器(没有任何混乱使用auth)之外,应用程序本身没有进行任何更改.

清除浏览器cookie什么都不做.手动设置MachineKey也没有帮助.

一旦部署了应用程序,这将在本地和远程服务器上进行复制.

有没有遇到过这个?

看起来很奇怪,没有对配置进行任何修改.

解决方法:

对此的解决方案是放弃数据库.

缓存基于本地MDF文件,并在Web.config中更改其名称

<add name="DefaultConnection" 
connectionString="Data Source=(LocalDb)\MSsqlLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Den-SomeNewName.mdf;Initial Catalog=aspnet-Den-SomeNewName;Integrated Security=True" 
providerName="System.Data.sqlClient" />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐