Azure-Samples / ms-identity-blazor-wasm

ms-identity-blazor-wasm
MIT License
19 stars 20 forks source link

Blazor WASM logout issue #7

Open avslnara opened 1 year ago

avslnara commented 1 year ago

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I have a Blazor WASM application deployed to Azure Blob storage as a static website. I am using Azure B2C authentication with Social Login and Email login. When I am running the code through Visual Studio, both login and logout work as expected. When I deploy the code to my static website on azure, login seems to work fine but logout has a problem. See the below screenshots.

Local Debugging

image

Static website

image

I am using the default RemoteAuthenticatorView in my code with no changes.

@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

@code{
    [Parameter] public string? Action { get; set; }
}

Below is the code for my LoginDisplay.razor component

@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

<AuthorizeView>
    <Authorized>
        Hello, @context.User.Identity?.Name!&nbsp;<MudDivider Vertical="true" FlexItem="true"></MudDivider>
        <MudButton Color="Color.Warning" @onclick="BeginLogout" EndIcon="@Icons.Filled.Logout">Log out</MudButton>
    </Authorized>
    <NotAuthorized>
        <MudButton Color="Color.Tertiary" Link="authentication/login" StartIcon="@Icons.Filled.Login">Login</MudButton>
    </NotAuthorized>
</AuthorizeView>

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

What am I missing?

Any log messages given by the failure

Expected/desired behavior

I would expect that after deploying to blob storage as well, the logout functionality works as expected.

Versions

.NET 6

Mention any other details that might be useful


Thanks! We'll be in touch soon.

jmprieur commented 1 year ago

@kalyankrishna1 can you please have a look?

aremo-ms commented 1 year ago

Hello @avslnara

I see from this article that AuthN/AuthZ are not supported for static websites. May it be the reason?

For meanwhile I did deploy the sample to Azure as App Service and had a successful login. Not so much on your direction, just a sanity check.

Let me know what you think.

Alex

aremo-ms commented 1 year ago

Hello @avslnara

I see from this article that AuthN/AuthZ are not supported for static websites. May it be the reason?

For meanwhile I did deploy the sample to Azure as App Service and had a successful login. Not so much on your direction, just a sanity check.

Let me know what you think.

Alex

@avslnara never mind - let me check it about static website