I am having a classic ASP.net web application with windows authentication.
Now the requirement is to login using Auth0 with Forms authentication. I am getting an issue where Owincontect challenge is getting called continuously as a loop. Below is my code,
Enabled Forms authentication in IIS.
web config as,
<add key="oidc:Authority" value=" https://url/authorize" />
<add key="oidc:ClientId" value="abcd" />
<add key="oidc:ClientSecret" value="abcd" />
<add key="oidc:RedirectUrl" value="http://localhost:8080/callback" />
startup class,
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
public partial class Startup
{
public static string OidcAuthority = ConfigurationManager.AppSettings["oidc:Authority"];
public static string OidcRedirectUrl = ConfigurationManager.AppSettings["oidc:RedirectUrl"];
public static string OidcClientId = ConfigurationManager.AppSettings["oidc:ClientId"];
public static string OidcClientSecret = ConfigurationManager.AppSettings["oidc:ClientSecret"];
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
var oidcOptions = new OpenIdConnectAuthenticationOptions
{
Authority = OidcAuthority,
ClientId = OidcClientId,
RequireHttpsMetadata = false, //when deploy it should be http comment this
ClientSecret = OidcClientSecret,
GetClaimsFromUserInfoEndpoint = true,
PostLogoutRedirectUri = OidcRedirectUrl,
RedirectUri = OidcRedirectUrl,
ResponseType = OpenIdConnectResponseType.Code,
Scope = OpenIdConnectScope.OpenId,
};
app.UseOpenIdConnectAuthentication(oidcOptions);
}
}
And in all the pages , I have added helper class object which checks the authenticated conditions including global.asax file,
Helpers.AuthHelper help = new Helpers.AuthHelper();
help.IsAuthenticated();
public void IsAuthenticated()
{
if (!HttpContext.Current.Request.IsAuthenticated)
{
HttpContext.Current.GetOwinContext().Authentication.Challenge();
}
var claims = ClaimsPrincipal.Current.Claims;
}
The issue is , it is not redirecting to the page expected and also to the auth0 login page, It got stuck in login page which I created.
Gets the above error page, As I have no code added inside login.aspx page. Little stuck in the continuity here. I am not clear if I am in right direction or any change is required for enabling forms authentication with Auth0 as I should not add authentication mode inside web config.
Regards Sangeetha
