- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 Katana 项目提供的 OpenID Connect 身份验证中间件。
实现中存在一个错误,在这些情况下会导致死锁:
SignOut
用于身份验证方法。死锁的发生是由于身份验证中间件处理来自主机的回调信号( header 已发送)的方式。问题的根源在于这个方法:
private static void OnSendingHeaderCallback(object state)
{
AuthenticationHandler handler = (AuthenticationHandler)state;
handler.ApplyResponseAsync().Wait();
}
来自 Microsoft.Owin.Security.Infrastructure.AuthenticationHandler
调用Task.Wait()
只有在返回 Task
时才是安全的已经完成,而在 OpenID Connect 中间件的情况下还没有完成。
中间件使用 Microsoft.IdentityModel.Protocols.ConfigurationManager<T>
的一个实例管理其配置的缓存副本。这是使用 SemaphoreSlim
的异步实现作为异步锁和 HTTP 文档检索器来获取配置。我怀疑这是死锁的触发因素 Wait()
打电话。
这是我怀疑是原因的方法:
public async Task<T> GetConfigurationAsync(CancellationToken cancel)
{
DateTimeOffset now = DateTimeOffset.UtcNow;
if (_currentConfiguration != null && _syncAfter > now)
{
return _currentConfiguration;
}
await _refreshLock.WaitAsync(cancel);
try
{
Exception retrieveEx = null;
if (_syncAfter <= now)
{
try
{
// Don't use the individual CT here, this is a shared operation that shouldn't be affected by an individual's cancellation.
// The transport should have it's own timeouts, etc..
_currentConfiguration = await _configRetriever.GetConfigurationAsync(_metadataAddress, _docRetriever, CancellationToken.None);
Contract.Assert(_currentConfiguration != null);
_lastRefresh = now;
_syncAfter = DateTimeUtil.Add(now.UtcDateTime, _automaticRefreshInterval);
}
catch (Exception ex)
{
retrieveEx = ex;
_syncAfter = DateTimeUtil.Add(now.UtcDateTime, _automaticRefreshInterval < _refreshInterval ? _automaticRefreshInterval : _refreshInterval);
}
}
if (_currentConfiguration == null)
{
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ErrorMessages.IDX10803, _metadataAddress ?? "null"), retrieveEx);
}
// Stale metadata is better than no metadata
return _currentConfiguration;
}
finally
{
_refreshLock.Release();
}
}
我试过添加 .ConfigureAwait(false)
到所有等待的操作,以努力将延续编码到线程池,而不是 ASP.NET 工作线程,但我在避免死锁方面没有取得任何成功。
我可以解决更深层次的问题吗?我不介意更换组件 - 我已经创建了自己的 IConfiguratioManager<T>
实验性实现.是否有可用于防止死锁的简单修复?
最佳答案
@悲剧 Actor 我们针对此问题采取了这些修复措施。您能否更新并查看问题是否仍然存在(我们认为我们已经用 184 修复了它,但正如您所见,我们有 185)。另一位客户使用最新的 nuget 取得了成功。
http://www.nuget.org/packages/Microsoft.IdentityModel.Protocol.Extensions/1.0.2.206221351
https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/pull/185/files
https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/pull/184/files
关于c# - 使用 Katana OpenID Connect 中间件解决 OnSendingHeaders 死锁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31243412/
OpenID 是否改善了用户体验? 编辑 不是要贬低其他评论,但我在下面得到了一个非常好的回复,它以一种合理的底线方式概述了 OpenID 的 3 个优点。我还在其他评论中听到了一些耳语,你可以通过
我不想疏远我的用户,但是通过多种方式登录网站违背了实现 OpenID 的目的。这不是一个全新的网站,大约有 3000 名用户是顽固的(我们有一个很棒的社区),但并非所有人都是顽固的,我不想因为登录过程
我在 StackOverflow 上使用 OpenID 来验证我的用户身份,这与这里的使用方式非常相似。我真正需要做的是让 OpenID 在我网站的所有子域中工作。 该站点的行为与 Kijiji 大致
OpenID 有没有其他选择,我的意思是一个提供我们详细信息的站点,我们可以使用该 ID 登录到一个站点? 更新 假设认为我正在开发一个具有 openID 集成的网站,我将只有一个用户名,没有那么多细
有人可以帮助我了解 OpenID 的工作原理吗?我对以下答案感兴趣: 如果使用 OpenId,您还需要存储用户 ID 和密码吗? 当用户登录时,我的应用程序如何创建新 session ? 当用户退出应
最重要的问题是我的电子邮件地址是否被传输到消费服务。 例如,如果我使用 Google 在这里登录 SO,那么 SO 知道我的 gmail 地址吗? 他知道我在 gmail 设置中输入的用于外发邮件的名
OpenID 连接的当前状态是什么?我想将它用于新的 SSO 系统。是否有任何库可用于实现? 最佳答案 最终 OpenID Connect 规范于 2014 年 2 月 26 日根据 http://o
作为单点登录实现,我认为 OpenID 很棒。即便如此,它是否一定是电子商务的好选择?我知道它可以使用,但应该使用吗?您是否冒险将所有访问详细信息放在一个篮子中? 那里的普遍意见是什么? 最佳答案 当
我不是问具体的实现,也不是问跨站单点登录机制的全局世界观,我只是想知道社区对 OpenID 底层可用性的看法。您是否认为使用由(非技术观察者)随机提供的各种提供者发布的 URL 来代替实际的用户名是人
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
我是openID的新手。我花了很多时间思考最好的做法是为用户提供选择,并使用各种启用了OpenID的帐户登录。 (我必须进一步澄清,我的系统不是一个只需要简单的“一次性身份验证”即可进行博客发布的系统
我希望将 OpenID 实现为一组合作伙伴网站的提供商。问题是这个网站是为 child (13 岁以下)准备的,所以我有一些业务限制需要处理 - 主要是帐户不能用于任何非合作伙伴网站(我们与每个获得批
WordPress 的 OpenID 插件似乎不接受任何 Google OpenID 提供商链接: http://google.com/profiles/username 或 https://goog
我在看 DotNetOpenAuth samples并且有两个 OpenID 提供程序示例;和 OpenID 提供程序和一个 OpenID Web Ring SSO 提供程序。 有谁知道两者之间的区别
存在一个行为不当的 OpenID Connect“兼容”iDP(它现在应该保持无名)——它在使用范围 openid 和任何包含 id_token 的 response_type 时抛出错误。这肯定是一
有没有人知道或有任何我可以用来构建使用 OpenID 的站点的文档?例如,当用户访问我的网站时,我接受一个 OpenID,然后我会将他们重定向到 OpenID 提供商,然后当他们通过身份验证时,他们将
现在我使用 3rd 方网站作为我的 openid 提供者(myvidoop 和 myopenid)。我正在考虑让我的网站充当我的提供者。我认为肯定会有一些脚本可以安装并轻松实现。我已经尝试过 janr
我有用户帐户的本地表 用户 ID(nvarchar)、密码、电子邮件、姓氏角色等。 现在每个子表中都使用了 UserID。我想在我的站点中启用 OPENID 注册,稍后将集成本地用户注册功能。我应该将
我遇到了 google openid 标识符的问题。 我在简单的 asp.net mvc 项目中使用 dotnetopenauth 库(dotnetopenid 的继承者)。 在本地主机上的测试期间,
我对 OpenId 很陌生,并且在身份验证完成后理解如何使用 OpenId 时遇到了一些问题。 我正在创建一个新站点,并且在使 openId 身份验证正常工作方面没有问题。但是我不确定一旦用户登录,我
我是一名优秀的程序员,十分优秀!