Skip to content

NavigationManager.NavigateToLogout() stuck on authentication/logout-callback after upgrade to dotnet 8 #53131

Closed
@yuominae

Description

@yuominae

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a dotnet-hosted blazor wasm project that I have been developing since dotnet 6. Auth is done using duende identity server with locally stored user accounts, based on the way it was done at the time I started the project.

The project was migrated to dotnet 7 about a year ago and was running in production without problems until I recently upgraded it to dotnet 8. After upgrading, the logout process gets stuck at authentication/logout-callback page with the message "processing logout callback...". Manually navigating back to "/" gets things unstuck, but previously the redirection to "/" was happening automatically. Getting stuck on logout is not optimal for the users.
The interesting part is that when I run the app in debug mode on my local environment everything works fine. The problem occurs when the app is hosted in the azure app service.

Auth is configured in the api project in the following way

_ = services.AddDefaultIdentity<IdentityUser>(options =>
                {
                    options.SignIn.RequireConfirmedEmail = false;

                    options.SignIn.RequireConfirmedAccount = false;
                }).AddRoles<IdentityRole>()
                .AddRoleManager<RoleManager<IdentityRole>>()
                .AddEntityFrameworkStores<MycoAuthDbContext>();

            services.AddIdentityServer()
                .AddApiAuthorization<IdentityUser, MycoAuthDbContext>();

            services.AddTransient<IProfileService, ProfileService>();

            _ = JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("role");

            services.AddAuthentication()
                    .AddIdentityServerJwt();

            services.AddAuthorization(options =>
            {
                foreach (var policy in Policies.GetAll())
                {
                    if (policy.HasRoles)
                    {
                        options.AddPolicy(policy.Name, apb => apb.RequireRole(policy.Roles));
                    }

                    if (policy.HasRequirements)
                    {
                        options.AddPolicy(policy.Name, abp => abp.AddRequirements(policy.Requirements));
                    }
                }
            });

            foreach (var authorizationHandlerType in Policies.GetAuthorizationHandlerTypes())
            {
                services.AddScoped(typeof(IAuthorizationHandler), authorizationHandlerType);
            }

            return services.Configure<IdentityOptions>(options => options.ClaimsIdentity.UserIdClaimType = ClaimTypes.NameIdentifier);

And in the client the signout code consists of

private void BeginSignOut(MouseEventArgs args)
            => NavigationManager.NavigateToLogout(
                "authentication/logout",
                "/properties");`

Here's what it looks like in the hosted app

image

And here is what it looks like locally

image

Expected Behavior

NavigationManager.NavigateToLogout() should redirect to another url after successful log out.

Steps To Reproduce

Migrate project with identity stores from dotnet 7 to dotnet 8 and host in azure app service?

Exceptions (if any)

None

.NET Version

8

Anything else?

On azure

image

Locally

dotnet 8.0.100 with VS 2022

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions