Der*_*uyk 2 c# authentication owin asp.net-mvc-5
我正在尝试设置一个概念证明,以便将我们的表单身份验证与SQL成员资格提供程序一起转移到代理身份验证过程中.为了做到这一点,我计划利用Thinktecture的Identity Server 2作为身份提供者.
我已经下载了IdentityServer 2并安装了它并尝试按照此处的说明进行操作:http: //www.cloudidentity.com/blog/2014/02/20/ws-federation-in-microsoft-owin-componentsa-quick-start/
但是,每当我尝试访问受AuthorizeAttribute限制的控制器操作时,我得到一个401的HttpResponse而不是重定向到IdentityServer的登录页面.Startup.Auth.cs设置如下:
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
});
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
MetadataAddress = "https://dvancuykidstrial.cloudapp.net/FederationMetadata/2007-06/FederationMetadata.xml"
,Wtrealm = "http://owin2.testing.com/"
,AuthenticationMode = AuthenticationMode.Passive
,BackchannelCertificateValidator = new FakeCertificateValidator()
});
}
}
Run Code Online (Sandbox Code Playgroud)
顺便提一下,FakeCertificateValidator只是ICertificateValidator的一个实现,它只在调用Validate函数时返回true.这只是让我通过我用于PoC的自签名证书.
public class FakeCertificateValidator : ICertificateValidator
{
public bool Validate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
谁能看到我在这里做错了什么?
我从这里得到了答案:https://katanaproject.codeplex.com/discussions/551624.问题是我设置了以下内容:
AuthenticationMode = AuthenticationMode.Passive
Run Code Online (Sandbox Code Playgroud)
根据讨论,两种模式之间的差异如下:
在被动模式下,需要通过名称调用中间件.在活动模式下,中间件将启动任何401响应
我假设(错误地)两种模式之间的差异更像是: WIF中的主动和被动联合
| 归档时间: |
|
| 查看次数: |
4294 次 |
| 最近记录: |