Search code examples
owinidentityserver4claims-based-identityclaimsowin-middleware

OWIN Signin not working


User.Identity.IsAuthenticated is always false. I've been googling for hours and I cannot get this to work. I have a set of claims and I'm creating the identity and signing in with it using OWIN, but for some reason, IsAuthenticated is always false.

Here is my web.config relevant portion:

<authentication mode="Forms">
  <forms name="FormsAuth1" loginUrl="https://localhost/SecureAuth.ClaimsAdapter.WebApp/Oidc/Authenticate" timeout="5" requireSSL="false"  domain="localhost"  />
</authentication>

Here is Startup.Auth.cs

 app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
 app.UseCookieAuthentication(new CookieAuthenticationOptions
 {
                AuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
                LoginPath = new PathString("/OIDC/Authenticate")
 });

Here is my controller

        var identity = new ClaimsIdentity(validatedToken.Claims, DefaultAuthenticationTypes.ExternalCookie);

        //Sign in using the created identity
        HttpContext.GetOwinContext().Authentication.SignIn(identity);

        //redirect to Pass the cookie to the client app
        return RedirectToAction("Confirm");

In the "Confirm" action, the "User.Identity.IsAuthenticated" is still set to false.


Solution

  • Apparently, I wasn't calling the

    ConfigureAuth(IappBuilder app) ....

    Proceed to slap self...