AspNetCore.Authentication issue with login path and redirect_uri

Hello -

I’m working with Auth0.AspNetCore.Authentication in a Blazor Server app.

I noticed that I was forced to use /Account/Login and /Account/Logout as the paths were not exposed in the Auth0WebAppAuthenticationBuilder options.

I found a way to override this, with this code, which is fine, but it seems the redirect_uri doesn’t work

builder.Services.Configure<CookieAuthenticationOptions>(CookieAuthenticationDefaults.AuthenticationScheme, options => {
    options.LoginPath = new PathString("/login");
    options.LogoutPath = new PathString("/logout");
});

Then I struggled to get redirect URI to work at all, until I modified the app.MapGet for /login as follows. Please tell me if I’m doing something wrong here? The code works, but it doesn’t line up with your tutorial for Blazor Server apps:

app.MapGet("/login", async (HttpContext httpContext, string redirectUri = "/") =>
    {
        var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
                .WithRedirectUri(redirectUri)
                .Build();

        if (authenticationProperties.RedirectUri == "/" && httpContext.Request.Query.ContainsKey("ReturnUrl"))
        {
            authenticationProperties.RedirectUri = httpContext.Request.Query["ReturnUrl"];
        }

        await httpContext.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
    });