77Vetter
77Vetter

Reputation: 269

ASP.NET MVC on .NET 4.7.2 implementing SSO

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 = "https://login.microsoftonline.com/##########",
            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 https://login.microsoftonline.com 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.com to authenticate but it seems like its in a loop and not actually returning to my accountsController.

enter image description here

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?

Upvotes: 0

Views: 41

Answers (0)

Related Questions