小编Der*_*uyk的帖子

在IdentityServer中使用Passive身份验证与MVC5中的OWIN

我正在尝试设置一个概念证明,以便将我们的表单身份验证与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)

谁能看到我在这里做错了什么?

c# authentication owin asp.net-mvc-5

2
推荐指数
1
解决办法
4294
查看次数

标签 统计

asp.net-mvc-5 ×1

authentication ×1

c# ×1

owin ×1