dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.4k stars 10k forks source link

AddOidcAuthentication Logout Not Sending State Query Parameter When Deployed #54515

Closed Eddie-Hartman closed 7 months ago

Eddie-Hartman commented 7 months ago

Is there an existing issue for this?

Describe the bug

When logging out from a local setup via NavigationManager.NavigateToLogout("authentication/logout"); I logout successfully. In the request, I can see the query parameter with state being sent in the request like so: https://localhost:5003/authentication/logout-callback?state=1cbc9e813e4f481cb01e2490d4a991ad

However, when this app is deployed on another server, the state query parameter is not sent and I suspect that causes the page to indefinitely say "Processing logout callback..." instead of logging out successfully. It sends this request (note the missing state parameter): https://devsnbicollector.mayvue.com/authentication/logout-callback

Logging in and out DOES work though. If I navigate to another page, it knows that I was logged out. There are no errors in the OIDC server, but from the logs I can see that the state parameter is missing when deployed vs when running locally (as we can see it's not being sent in).

I could not reproduce this behavior locally at all. I can run the OIDC server locally as well as the Blazor WASM app. I tried running in a production environment setup in release mode and when running locally it still works.

The part that made me post here is that I set up my Blazor WASM app to run locally and sign into the production OIDC server and was able to log out and it sent the state in as a parameter. We simply just do a dotnet publish and run the app in IIS, so what, if anything, could be preventing state from being sent as a parameter?

Is this a bug? What is causing the different behavior?

Expected Behavior

When deployed to the production environment, the behavior of signing out should be the same as what I'm experiencing locally.

Steps To Reproduce

Since this is a production project I can't set up a publicly accessible reproduction link. I have a deployed app that I can supply a demo login for via email request and could set up a local testing site via a dev tunnel.

If absolutely necessary, we could set up some sort of private minimum repro repo that I could invite others to help debug.

Exceptions (if any)

No response

.NET Version

8.0.102

Anything else?

Global.json contents: { "sdk": { "version": "8.0.100", "rollForward": "latestPatch" } // https://learn.microsoft.com/en-us/dotnet/core/tools/global-json // This file will need updated whenever the SDK version for builds we want to use gets updated. // However, this also means the servers running the application will need updated with the latest hosting bundle for that SDK version if they are not compatible. }

.NET SDK: Version: 8.0.102 Commit: 64f1bc458e Workload version: 8.0.100-manifests.5638171e

Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.102\

.NET workloads installed: Workload version: 8.0.100-manifests.5638171e [wasm-tools] Installation Source: SDK 8.0.100, VS 17.8.34525.116 Manifest Version: 8.0.2/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.2\WorkloadManifest.json Install Type: Msi

[ios] Installation Source: VS 17.8.34525.116 Manifest Version: 17.2.8022/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8022\WorkloadManifest.json Install Type: Msi

[maui-windows] Installation Source: VS 17.8.34525.116 Manifest Version: 8.0.6/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.6\WorkloadManifest.json Install Type: Msi

[wasm-tools-net7] Installation Source: VS 17.8.34525.116 Manifest Version: 8.0.2/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net7\8.0.2\WorkloadManifest.json Install Type: Msi

[maccatalyst] Installation Source: VS 17.8.34525.116 Manifest Version: 17.2.8022/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8022\WorkloadManifest.json Install Type: Msi

[android] Installation Source: VS 17.8.34525.116 Manifest Version: 34.0.79/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.79\WorkloadManifest.json

Install Type: Msi

Host: Version: 8.0.2 Architecture: x64 Commit: 1381d5ebd2

.NET SDKs installed: 3.1.426 [C:\Program Files\dotnet\sdk] 5.0.303 [C:\Program Files\dotnet\sdk] 5.0.408 [C:\Program Files\dotnet\sdk] 6.0.118 [C:\Program Files\dotnet\sdk] 6.0.321 [C:\Program Files\dotnet\sdk] 7.0.313 [C:\Program Files\dotnet\sdk] 7.0.406 [C:\Program Files\dotnet\sdk] 8.0.101 [C:\Program Files\dotnet\sdk] 8.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: arm64 [C:\Program Files\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation] x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: C:\Users\EddieHartman\source\repos\SNBI Collector\global.json

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

mkArtakMSFT commented 7 months ago

Thanks for contacting us. This is a known issue which is tracked as part of #49956. We will try to port this fix to one of the upcoming 8.0.x releases.

Eddie-Hartman commented 7 months ago

@mkArtakMSFT this does appear to be the issue. Is there a way that I can confirm locally?

I guess I don't understand why building in release mode with a release environment wouldn't cause the trimming. How do I replicate running from Visual Studio as closely as possible to what would be done once deployed so I can be 100% sure?

Do I run a publish and a dotnet run from the publish output?

Thanks.