1
Hello,
I am implementing the MVC with Asp.Net Identity, however, I’m having some problems...
Setting: I’m logging in from protocol HTTP, everything enters normally. When I try to access any page with HTTPS protocol, it does not see that I am logged in. However, the cookie authentication is there... I searched what it could be and discovered that Cookie is not specifying Flag Secure.
Goal: I need to authenticate myself with only one user, I can force the HTTPS at the time of logging in, but if someone access a page by HTTP the system will not see that I am authenticated. How do I see a single authentication both in the HTTP and in the HTTPS ?
Here’s my Identity Startup class:
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromSeconds(0),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
ExpireTimeSpan = System.TimeSpan.FromDays(100),
});
}
}
I don’t know where to put this configuration (force HTTP to see HTTPS authentication in a more generic way).
Thanks, I was already getting a headache trying to find this configuration.
– Wilson Santos
It was giving problems in the localhost. I checked and it generated the Identity authentication cookie without Flag Secure, but it did not see in both cases. I tested through the external server and it worked properly. I don’t know if it was a specific setup of my Local IIS that ended up coming into conflict. Thanks for the help.
– Wilson Santos