admin管理员组

文章数量:1289381

I have an existing ASP.NET MVC app on .NET 4.7.2 that we are updating and also trying to implement SSO using WSFederation. In our Startup class, we have the following code:

public void Configuration(IAppBuilder app)
{
    app.MapSignalR();
    app.SetDefaultSignInAsAuthenticationType (WsFederationAuthenticationDefaults.AuthenticationType);
    app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
        });
    app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
        {
            MetadataAddress = ";,
            Wtrealm = "https://xxxxxxxxxx/appname"
        });
}

In our web.config in the system.web section, we have the following:

<authentication mode="None" />
<sessionState timeout="15" />
<customErrors mode="Off" />
<authorization>
    <deny users="?" />
</authorization>

When we try to run the app locally, we get this error:

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.

The code does not even try to redirect to the url for authentication, it just immediately throws the error.

--- UPDATE I have added the following in FilterConfig.cs:

filters.Add(new AuthorizeAttribute());

And set authentication mode="forms" in web.config <system.web>

Then it would reach out to login.microsoftonline to authenticate but it seems like its in a loop and not actually returning to my accountsController.

I have added break points in accountsController.Login but it never stops there it just keeps looping as in the SamlTracer above.

So I am closer but still missing something?

本文标签: single sign onASPNET MVC on NET 472 implementing SSOStack Overflow