Open Closed

Redirect to login failure on Azure Appservice #5976


User avatar
0
listtraderdev2 created
  • ABP Framework version: v7.3.3
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no

I have configured this to redirect users to the login page after they have logged out. This works on localhost but when I push to azure I am unable to get it to work.

@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components
@using Volo.Abp.DependencyInjection
@inherits  Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication
@inject NavigationManager _navigationManager;
@attribute [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication))]
@attribute  [Dependency(ReplaceServices = true)]

<Card>
    <CardBody>
        <RemoteAuthenticatorView Action="@Action">
            <LoggingIn>
                <LoadingIndicator/>
            </LoggingIn>
            <CompletingLoggingIn>
                <LoadingIndicator/>
            </CompletingLoggingIn>
            <LogOut>
                <LoadingIndicator/>
            </LogOut>
            <CompletingLogOut>
                <LoadingIndicator/>
            </CompletingLogOut>
            <LogOutSucceeded>
                @{
                    _navigationManager.NavigateTo("/authentication/login");
                }
            </LogOutSucceeded>
        </RemoteAuthenticatorView>
    </CardBody>
</Card>
public partial class Authentication
    {
        public Authentication(
            WebAssemblyCachedApplicationConfigurationClient webAssemblyCachedApplicationConfigurationClient)
            : base(webAssemblyCachedApplicationConfigurationClient)
        {
        }
    }

In localhost, I observed that the state parameter is present in the logout and the logout-callback call but not available in production(azure appservice). Can you help with a solution?


10 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try to output the log here and check it in the console tab.

  • User Avatar
    0
    listtraderdev2 created

    Kindly specify what I should be looking out for in the logs.

    this is from my logs.txt file

    2023-10-18 00:46:24.907 +00:00 [INF] The logout request was successfully validated. 2023-10-18 00:46:24.923 +00:00 [INF] Executing endpoint 'Volo.Abp.OpenIddict.Controllers.LogoutController.GetAsync (Volo.Abp.OpenIddict.AspNetCore)' 2023-10-18 00:46:24.928 +00:00 [INF] Route matched with {action = "Get", controller = "Logout", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] GetAsync() on controller Volo.Abp.OpenIddict.Controllers.LogoutController (Volo.Abp.OpenIddict.AspNetCore). 2023-10-18 00:46:24.929 +00:00 [INF] Executing action method Volo.Abp.OpenIddict.Controllers.LogoutController.GetAsync (Volo.Abp.OpenIddict.AspNetCore) - Validation state: "Valid" 2023-10-18 00:46:24.952 +00:00 [INF] AuthenticationScheme: Identity.Application signed out. 2023-10-18 00:46:24.954 +00:00 [INF] AuthenticationScheme: Identity.External signed out. 2023-10-18 00:46:24.954 +00:00 [INF] AuthenticationScheme: Identity.TwoFactorUserId signed out. 2023-10-18 00:46:24.955 +00:00 [INF] Executed action method Volo.Abp.OpenIddict.Controllers.LogoutController.GetAsync (Volo.Abp.OpenIddict.AspNetCore), returned result Microsoft.AspNetCore.Mvc.SignOutResult in 26.1952ms. 2023-10-18 00:46:24.962 +00:00 [INF] Executing SignOutResult with authentication schemes (["OpenIddict.Server.AspNetCore"]). 2023-10-18 00:46:24.986 +00:00 [INF] The logout response was successfully returned to 'https://.../authentication/logout-callback': Microsoft.AspNetCore.Http.DefaultHttpResponse. 2023-10-18 00:46:24.987 +00:00 [INF] Executed action Volo.Abp.OpenIddict.Controllers.LogoutController.GetAsync (Volo.Abp.OpenIddict.AspNetCore) in 59.0532ms 2023-10-18 00:46:24.987 +00:00 [INF] Executed endpoint 'Volo.Abp.OpenIddict.Controllers.LogoutController.GetAsync (Volo.Abp.OpenIddict.AspNetCore)'

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    As you know, the Blazor wasm will output the logs in the console tab.

    You can output the log to check whether the logout callback is available.

  • User Avatar
    0
    listtraderdev2 created

    I get the log output in localhost but not in production

    -- localhost

    -- azure

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you share the URL link of the web site and a test user account? I will check it. my email is shiwei.liang@volosoft.com

  • User Avatar
    0
    listtraderdev2 created

    Hi, I have forwarded the information requested. Do you have any feedback on the issue?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I didn't receive the email. Can you send it again?

  • User Avatar
    0
    listtraderdev2 created

    Hi,

    I didn't receive the email. Can you send it again?

    Ok. I have sent it again

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Will it work if you try this?

    MyAuthentication.razor

    @using Microsoft.AspNetCore.Components.WebAssembly.Authentication
    @using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components
    @using Volo.Abp.DependencyInjection
    @inherits  Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication
    
    @attribute [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication))]
    @attribute  [Dependency(ReplaceServices = true)]
    
    <Card>
        <CardBody>
            <RemoteAuthenticatorView Action="@Action">
                <LoggingIn>
                    <LoadingIndicator/>
                </LoggingIn>
                <CompletingLoggingIn>
                    <LoadingIndicator/>
                </CompletingLoggingIn>
                <LogOut>
                    <LoadingIndicator/>
                </LogOut>
                <CompletingLogOut>
                    <LoadingIndicator/>
                </CompletingLogOut>
                <LogOutSucceeded>
                </LogOutSucceeded>
            </RemoteAuthenticatorView>
        </CardBody>
    </Card>
    

    MyAuthentication.razor.cs

    public partial class MyAuthentication
    {
        public MyAuthentication(WebAssemblyCachedApplicationConfigurationClient webAssemblyCachedApplicationConfigurationClient) : base(webAssemblyCachedApplicationConfigurationClient)
        {
        }
        
        protected override void OnInitialized()
        {
            if (Action == "logout-callback")
            {
                NavigationManager.NavigateTo("/authentication/login");
            }
        }
    }
    
  • User Avatar
    0
    listtraderdev2 created

    Hi,

    Will it work if you try this?

    MyAuthentication.razor

    @using Microsoft.AspNetCore.Components.WebAssembly.Authentication 
    @using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components 
    @using Volo.Abp.DependencyInjection 
    @inherits  Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication 
     
    @attribute [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication))] 
    @attribute  [Dependency(ReplaceServices = true)] 
     
    <Card> 
        <CardBody> 
            <RemoteAuthenticatorView Action="@Action"> 
                <LoggingIn> 
                    <LoadingIndicator/> 
                </LoggingIn> 
                <CompletingLoggingIn> 
                    <LoadingIndicator/> 
                </CompletingLoggingIn> 
                <LogOut> 
                    <LoadingIndicator/> 
                </LogOut> 
                <CompletingLogOut> 
                    <LoadingIndicator/> 
                </CompletingLogOut> 
                <LogOutSucceeded> 
                </LogOutSucceeded> 
            </RemoteAuthenticatorView> 
        </CardBody> 
    </Card> 
    

    MyAuthentication.razor.cs

    public partial class MyAuthentication 
    { 
        public MyAuthentication(WebAssemblyCachedApplicationConfigurationClient webAssemblyCachedApplicationConfigurationClient) : base(webAssemblyCachedApplicationConfigurationClient) 
        { 
        } 
         
        protected override void OnInitialized() 
        { 
            if (Action == "logout-callback") 
            { 
                NavigationManager.NavigateTo("/authentication/login"); 
            } 
        } 
    } 
    

    This worked. Thank you

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11