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.44k stars 10.02k forks source link

Blazor Webassembly Authentication Logout with OpenIDConnect endsession missing id_token_hint #46741

Open nirab25 opened 1 year ago

nirab25 commented 1 year ago

Is there an existing issue for this?

Describe the bug

Blazor WASM OIDC logout redirected to https://auth.xyz.com/connect/endsession works fine for main domain(https://app.com). It redirects with id_token_hint, post_logout_uri and state.

But it does not work with subdomain(https://subdomain.app.com). it misses id_token_hint.

Expected Behavior

It should redirect to endsession with id_token_hint

Steps To Reproduce

@code{
    private async Task BeginLogout(MouseEventArgs args)
    {
        await SignOutManager.SetSignOutState();
        NavigationManager.NavigateTo("authentication/logout");
    }
}

Exceptions (if any)

No response

.NET Version

6.04

Anything else?

No response

steinbachio commented 1 year ago

Overloading the NavigationManager.NavigateToLogout() function with InteractiveRequestOptions like NavigationManager.NavigateToLogin() would be great. So you could use it like this:

    var options = new InteractiveRequestOptions()
    {
        Interaction = InteractionType.SignOut,
        ReturnUrl = "authentication/logout"
    };
    options.TryAddAdditionalParameter("id_token_hint", GetIdToken());
    Navigation.NavigateToLogout($"authentication/logout", options);
ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

paulsuart commented 5 months ago

Instead of

options.TryAddAdditionalParameter("id_token_hint", GetIdToken());

Try

options.TryAddAdditionalParameter("idTokenHint", GetIdToken());

It seems the idTokenHint form is msal.js's internal name, and it will convert it to a querystring parameter named id_token_hint.