SSO with openiddict set login page absolute url

Viewed 610

I am using openiddict for custom sso and want to host login ui on a separate domain in spa application. The issue I am facing is propper configuration of challenge action.

I've tried to overwrite OnRedirectToLogin event but that obviously not working

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
            {
                options.Events = new CookieAuthenticationEvents()
                {
                    OnRedirectToLogin = async (context) =>
                    {
                        context.HttpContext.Response.Redirect("https://example.com/account/login");
                    }
                };
            });

Am I doing smth wrong?

1 Answers

The solution to the following issue was found in this answer

Code to add:

services.ConfigureApplicationCookie(options =>
        {
            options.Events.OnRedirectToLogin = context =>
            {
                context.HttpContext.Response.Redirect("http://example.com/login");
                return Task.CompletedTask;
            };
        });
Related