Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Upgrade to .net 6 and latest version of Optimizely, custom login doesn't work

Vote:
 

After upgrading to the latest version of optimizely my custom login/logout doesn't work properly anymore and the path for login that is set in startup it goes to :

.../Util/Login?returnUrl=%2F

 app.UseEndpoints(endpoints =>
            {
                //login
                endpoints.MapControllerRoute("CustomLogin", "login/",
                    new { controller = "IdentityServerAuthentication", action = "Login" });
                //logout
                endpoints.MapControllerRoute("CustomLogout", "logout/",
                    new { controller = "IdentityServerAuthentication", action = "Logout" });

                endpoints.MapControllerRoute(name: "Default", pattern: "{controller}/{action}/{id?}");
                endpoints.MapControllers();
                endpoints.MapRazorPages();
                endpoints.MapContent();
            });

The same code was working in .net 5 and CMS 11 :-) Anyone has any idea how to solve this?

Best Regards

Maryam

#292112
Nov 23, 2022 2:57
Vote:
 

Hi, we would need more information to be able to help. You write that the login path is /util/Login, but the endpoints in your posted code is mapped to /login. What are you trying to achive, remap /util/login so it uses IdentityServer, or do you want to change the login URL for the whole application to use /login instead? Does the login work if you navigate to /login?

#292117
Nov 23, 2022 8:24
Maryam Sarrafkia - Nov 23, 2022 8:48
Hi!

I would like to use identity server login and remap util/login to /login. The code above was doing doing the remapping correctly in previous version.
/login is going to identity server login page.

Best regards
Maryam
Vote:
 

You can change the login path, to not use /util/login, in the cookie auth scheme:

services.Configure<CookieAuthenticationOptions>(o => o.LoginPath = "/login");

or directly when you configure the authentication schemes:

services
    .AddAuthentication()
    .AddCookie(options =>
    {
        options.LoginPath = "/login";
    })
#292120
Nov 23, 2022 9:10
Maryam Sarrafkia - Nov 23, 2022 13:13
Sure this has been added since beginning to the identity server part of the code at start up but some how util/login is overriding it and I don't know how it is possible :-) Should look in to it more!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.