ASPNET MVC Integration with OKTA, always redirect to OKTA login despite set CookieAuthenticationOptions.LoginPath

I have my aspnet project with nugets added: Okta.AspNet and Okta.AspNet.Abstractions
I have configuration:

     app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = AuthenticationTypes.ApplicationCookie,
                CookieName = AuthenticationCookie.CookieName,
                LoginPath = new PathString("/Account/Login"),
                CookieSecure = GetCookieSecureOption(),
                Provider = new CookieAuthenticationProvider
                {
                    OnApplyRedirect = ApplyRedirect
                },
             ...
                CookieHttpOnly = true
            });
   app.SetDefaultSignInAsAuthenticationType(AuthenticationTypes.ApplicationCookie);
app.UseOktaMvc(new OktaMvcOptions()
            {
                OktaDomain = System.Configuration.ConfigurationManager.AppSettings["okta:OktaDomain"],
                ClientId = System.Configuration.ConfigurationManager.AppSettings["okta:ClientId"],
                ClientSecret = System.Configuration.ConfigurationManager.AppSettings["okta:ClientSecret"],
                AuthorizationServerId = System.Configuration.ConfigurationManager.AppSettings["okta:AuthorizationServerId"],
                RedirectUri = System.Configuration.ConfigurationManager.AppSettings["okta:RedirectUri"],
                PostLogoutRedirectUri = System.Configuration.ConfigurationManager.AppSettings["okta:PostLogoutRedirectUri"],
                GetClaimsFromUserInfoEndpoint = true,
                Scope = new List<string> { "openid", "profile", "email" },
                OpenIdConnectEvents = new OpenIdConnectAuthenticationNotifications()
                {
                   //TokenResponseReceived = (a) => test(a)
                }
            }) ;

but when i start project it always redirect me to OKTA
https://dev-YYY.okta.com/oauth2/default/v1/authorize…
despite the LoginPath = new PathString(“/Account/Login”),
Any idea how to change it to Account/Login or debug?

Well after hours of searching I found the reason :slight_smile:

   app.UseOktaMvc(new OktaMvcOptions()
            {
              ...
                  LoginMode = LoginMode.SelfHosted
              ...
            });
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.