2

I have a working IdentityServer2 auth server that works fine. I am creating a new .NET MVC application and following this article (http://www.cloudidentity.com/blog/2014/02/20/ws-federation-in-microsoft-owin-componentsa-quick-start/) to set up MS OWIN with IDS2. I can reach the login screen but after logging in, the user is sent back to the calling website and gets stuck in an endless loop.

Startup.Auth.cs

using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.WsFederation;
using Owin;

namespace AZBarMail
{
    public partial class Startup
    {
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(
                new CookieAuthenticationOptions
                {
                    AuthenticationType =
                       WsFederationAuthenticationDefaults.AuthenticationType
                });
            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = "https://auth.azbar.org/federationmetadata/2007-06/federationmetadata.xml",
                    Wtrealm = "https://localhost:44310/",
                });
        }
    }
}

Portion of web.config

<system.web>
  <authentication mode="None" />
  <compilation debug="true" targetFramework="4.6.1" />
  <httpRuntime targetFramework="4.6.1" />
</system.web>

Startup.cs

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(AZBarMail.Startup))]
namespace AZBarMail
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
        }
    }
}

Redirect URL in IDS2

https://localhost:44310/
4

2 回答 2

0

将您的用户重定向到 /account/login。

app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/account/Login"),
                CookieName = CookieAuthenticationDefaults.CookiePrefix + "SampleClient",
                ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter,
                LogoutPath = new PathString("/account/Logout")
            });

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

从 /account/login 重定向到外部提供商。

外部提供商将在其域上创建一个 cookie,您将在收到外部提供商的响应后在您的域上创建一个 cookie。

于 2016-05-25T09:11:35.753 回答
0

问题终于解决了。似乎是 cookie 类型/设置的问题。

于 2016-06-09T15:39:16.633 回答