I've run into a problem migrating the authentication system of two MVC websites using Framework 4.8. My two sites each had their own authentication system. I configured my two sites so that they could connect to an identity server based on identity server 4 developed in .NET core 6. I have another site that uses this identity server and works perfectly. The problem is with the two 4.8 sites, both of which are behaving in ways I can't understand. On both sites, I've integrated the packages for Owin and configured the clients in the identity server with an implicit grant type. The first site manages to connect when I'm local, so there's no problem, but as soon as I deploy it on my Windows server, the connection attempt loops and I get a "Bad Request - Request Too Long" error. For the second site, the looping problem occurs locally and I also get a "Bad Request - Request Too Long" error. On the identity server side, I enter the "GetProfileDataAsync" method, which sets the user's claims, but when I enter my client's "ExternalLoginCallback" method, the request "await HttpContext.GetOwinContext().Authentication.GetExternalLoginInfoAsync();" is always null. I've searched for answers but can't find a solution.
Below is the configuration of my different sites:
- Identity server: .NET core 6, Duende.IdentityServer 6.2.3
- Site 1 running locally: Framework 4.8, Microsoft.AspNet.Identity.Owin 2.2.4
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "site1",
Authority = ConfigurationManager.AppSettings["UrlIdentity"],
RedirectUri = ConfigurationManager.AppSettings["UrlSite1"] + "Account/ExternalLoginCallback",
ResponseType = "id_token",
Scope = "openid profile",
SignInAsAuthenticationType = "Cookies",
});
}
- Site 2 not running locally: Framwork 4.8, Microsoft.AspNet.Identity.Owin 2.2.4
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = "site2",
Authority = ConfigurationManager.AppSettings["UrlIdentity"],
RedirectUri = ConfigurationManager.AppSettings["UrlSite2"] + "Account/ExternalLoginCallback",
ResponseType = "id_token",
Scope = "openid profile",
SignInAsAuthenticationType = "Cookies",
});
}
Thanks