Mar*_*ran 6 authentication thinktecture-ident-model thinktecture-ident-server identityserver3
我的目标是使用Web服务的Angular应用程序,使用Windows身份验证对应用程序/ Web服务的用户进行身份验证.用户应该能够登录我们的Windows域中的计算机,打开浏览器并使用Angular应用程序而无需再次登录.
研究
我从https://github.com/IdentityServer/IdentityServer3.Samples/下载了所有源代码示例
我使用了最简单的OAuth2演练示例.没问题.
然后我打开了Web Host(Windows Auth All-In-One)示例.在评论出导致问题的两行代码后,我可以恢复和构建项目(Clients.cs行313,359,设置'AllowAccessTokensViaBrowser = false'.可能不相关.)
当应用程序运行时,我可以在localhost:44333上看到IdentityServer3登录页面.大.
我还可以在localhost:44333/windows上看到Windows身份验证服务元数据(SAML文档).还有,很棒.
问题是,我不知道接下来该做什么.本文档似乎建议下一步涉及编写一个调用Windows身份验证服务来获取令牌的客户端:
http://github.com/IdentityServer/IdentityServer3/issues/1463
这是正确的方法吗?我无法使代码示例工作.我甚至不确定我是否可以指向OAuth2Client正确的地方.请有人解释这个过程,或者给我一个工作客户的例子吗?提前谢谢你的帮助:)
编辑
我一直在做进一步的研究.我检查了Identity服务器的日志,以确保在配置期间完成添加WS-Federation端点操作.确实如此.
然后我创建了一个简单的控制台应用程序来调用Windows身份验证服务,如下所示:github.com/IdentityServer/IdentityServer3/issues/2318
导入Thinktecture.IdentityModel.Client后,我修改了该页面上的代码以适应我的端口号等,我最终得到了这个:
var handler = new HttpClientHandler
{
UseDefaultCredentials = true
};
var oauthClient = new OAuth2Client(
new Uri("https://localhost:44333/windows/token"),
handler);
var result = oauthClient.RequestCustomGrantAsync("windows").Result;
Run Code Online (Sandbox Code Playgroud)
我的结果对象仍然有一个NotFound的HttpErrorStatusCode ,这让我很伤心.
另一个编辑
我尝试将客户端指向Identity Server端点,如Branimir所示.所以我的代码现在写道:
var oauthClient = new OAuth2Client(
new Uri("https://localhost:44333/connect/token"),
handler);
Run Code Online (Sandbox Code Playgroud)
这也不起作用.这是Identity Server日志所说的内容:
Start token request
iisexpress.exe Information: 0 : 04/27/2016 20:35:23 +01:00 [Information] (IdentityServer3.Core.Validation.SecretParser)
Parser found no secret
iisexpress.exe Information: 0 : 04/27/2016 20:35:23 +01:00 [Information] (IdentityServer3.Core.Validation.ClientSecretValidator)
No client secret found
iisexpress.exe Information: 0 : 04/27/2016 20:35:23 +01:00 [Information] (IdentityServer3.Core.Endpoints.TokenEndpointController)
End token request
iisexpress.exe Information: 0 : 04/27/2016 20:35:23 +01:00 [Information] (IdentityServer3.Core.Results.TokenErrorResult)
Returning error: invalid_client
Run Code Online (Sandbox Code Playgroud)
所以我没有进一步前进.
为什么要使用令牌端点 - 只需执行 OAuth/OpenID Connect 隐式流程。这将使用 Windows 身份验证自动对用户进行身份验证。