Open Closed

Show login page after logout #3071


User avatar
0
safi created

Hi

I want to show the login page after the logout click currently when we click on logout so it calls authentication/loggedout page and logout page so can we direct show the login page after logout.

I want to restrict extra redirection. Please suggest me.

  • ABP Framework version: v4.43
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

17 Answer(s)
  • User Avatar
    0
    safi created

    Is there anybody who can help me out!

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    If you set your default application's home/index page with [Authorize], you will automatically redirected back to login page.

  • User Avatar
    0
    safi created

    [Authorize]

    Are you talking about index.razor page. We have this page in blazor project and [Authorize] tag is already there.

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    If you have it authorized, it should be redirecting back to login page already. Can you share a video, or gif of the process that show the problem you are having with?

  • User Avatar
    0
    safi created

    If you have it authorized, it should be redirecting back to login page already. Can you share a video, or gif of the process that show the problem you are having with?

    Can u send me your mail id?

  • User Avatar
    0
    safi created

    If you have it authorized, it should be redirecting back to login page already. Can you share a video, or gif of the process that show the problem you are having with?

    See I don't want to show this screen instead of this it should show login screen

  • User Avatar
    0
    safi created

    If you have it authorized, it should be redirecting back to login page already. Can you share a video, or gif of the process that show the problem you are having with?

    See I don't want to show this screen instead of this it should show login screen

    Any update?

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?
  • User Avatar
    0
    safi created
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?

    No not able to see any error in console also I am using blazor webassembly non-tiered and the version is 4.4.3.

  • User Avatar
    0
    safi created
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?

    Are you guys looking into it or Just joking with me?

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?

    Are you guys looking into it or Just joking with me?

    Hello,

    It could be shorter if you would share the link (/authentication/logged-out) in the screenshot.

    After IdentityServer single logout action, the user is redirected back to Blazor application. This URL (/authentication/logged-out) is handled by the Microsoft OIDC Provider and it is not related to ABP.

    When we investigate more about the Microsoft.AspNetCore.Components.WebAssembly.Authentication, we have limited options to modify the remote views.

    Instead of modifying the remote view, you can set the authentication/logged-out path to index page should redirect you back to login page since the index.razor is supposed to be authorized already.

    Update the ConfigureAuthentication method of BlazorModule as follows:

    private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
    {
        builder.Services.AddOidcAuthentication(options =>
        {
            builder.Configuration.Bind("AuthServer", options.ProviderOptions);
            options.UserOptions.RoleClaim = JwtClaimTypes.Role;
            options.AuthenticationPaths.LogOutSucceededPath = "/"; // This will redirect the application to "/" instead of logged-out page which will trigger authentication again
            options.ProviderOptions.DefaultScopes.Add("MyApp");
            options.ProviderOptions.DefaultScopes.Add("role");
            options.ProviderOptions.DefaultScopes.Add("email");
            options.ProviderOptions.DefaultScopes.Add("phone");
        });
    }
    

    <br> You can see Microsoft documentation of Blazor Web Assembly for additional scenarios for more information.

  • User Avatar
    0
    safi created

    index.razor

    Hi

    I tried this but it's taking too much time can we connect on zoom? It would be a quick easy fix for you but I am taking much time.

  • User Avatar
    0
    safi created
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?

    Are you guys looking into it or Just joking with me?

    Hello,

    It could be shorter if you would share the link (/authentication/logged-out) in the screenshot.

    After IdentityServer single logout action, the user is redirected back to Blazor application. This URL (/authentication/logged-out) is handled by the Microsoft OIDC Provider and it is not related to ABP.

    When we investigate more about the Microsoft.AspNetCore.Components.WebAssembly.Authentication, we have limited options to modify the remote views.

    Instead of modifying the remote view, you can set the authentication/logged-out path to index page should redirect you back to login page since the index.razor is supposed to be authorized already.

    Update the ConfigureAuthentication method of BlazorModule as follows:

    private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) 
    { 
        builder.Services.AddOidcAuthentication(options => 
        { 
            builder.Configuration.Bind("AuthServer", options.ProviderOptions); 
            options.UserOptions.RoleClaim = JwtClaimTypes.Role; 
            options.AuthenticationPaths.LogOutSucceededPath = "/"; // This will redirect the application to "/" instead of logged-out page which will trigger authentication again 
            options.ProviderOptions.DefaultScopes.Add("MyApp"); 
            options.ProviderOptions.DefaultScopes.Add("role"); 
            options.ProviderOptions.DefaultScopes.Add("email"); 
            options.ProviderOptions.DefaultScopes.Add("phone"); 
        }); 
    } 
    

    <br> You can see Microsoft documentation of Blazor Web Assembly for additional scenarios for more information.

    Please check this

  • User Avatar
    0
    safi created
    1. Do you have any errors when you check developer console (F12) of the browser?
    2. Is your project template Blazor WebAssemby non-tiered? What is your exact template version?
    3. Do you have front-channel logout altered or any identityserver-related data changes?

    Are you guys looking into it or Just joking with me?

    Hello,

    It could be shorter if you would share the link (/authentication/logged-out) in the screenshot.

    After IdentityServer single logout action, the user is redirected back to Blazor application. This URL (/authentication/logged-out) is handled by the Microsoft OIDC Provider and it is not related to ABP.

    When we investigate more about the Microsoft.AspNetCore.Components.WebAssembly.Authentication, we have limited options to modify the remote views.

    Instead of modifying the remote view, you can set the authentication/logged-out path to index page should redirect you back to login page since the index.razor is supposed to be authorized already.

    Update the ConfigureAuthentication method of BlazorModule as follows:

    private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)  
    {  
        builder.Services.AddOidcAuthentication(options =>  
        {  
            builder.Configuration.Bind("AuthServer", options.ProviderOptions);  
            options.UserOptions.RoleClaim = JwtClaimTypes.Role;  
            options.AuthenticationPaths.LogOutSucceededPath = "/"; // This will redirect the application to "/" instead of logged-out page which will trigger authentication again  
            options.ProviderOptions.DefaultScopes.Add("MyApp");  
            options.ProviderOptions.DefaultScopes.Add("role");  
            options.ProviderOptions.DefaultScopes.Add("email");  
            options.ProviderOptions.DefaultScopes.Add("phone");  
        });  
    }  
    

    <br>
    You can see Microsoft documentation of Blazor Web Assembly for additional scenarios for more information.

    Please check this

    After logout it's going to login page but if we try to login again it's going to swagger link

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    Sorry, I am not available for remote sessions. But these are the steps I have followed:

    I had removed ABP CLI to install ABP CLI version 4.4.3 in order to create a Blazor application for version 4.4.3.

    Updated the Index.razor.cs file:

    namespace MyApp.Blazor.Pages
    {
        [Authorize]
        public partial class Index
        {
    
        }
    }
    

    This configuration automatically redirects the application to login page. Update MyAppBlazorModule.cs file:

    private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
    {
        builder.Services.AddOidcAuthentication(options =>
        {
            builder.Configuration.Bind("AuthServer", options.ProviderOptions);
            options.UserOptions.RoleClaim = JwtClaimTypes.Role;
            options.AuthenticationPaths.LogOutSucceededPath = "/";
            options.ProviderOptions.DefaultScopes.Add("MyApp");
            options.ProviderOptions.DefaultScopes.Add("role");
            options.ProviderOptions.DefaultScopes.Add("email");
            options.ProviderOptions.DefaultScopes.Add("phone");
        });
    }
    

    Result:

  • User Avatar
    0
    safi created

    Sorry, I am not available for remote sessions. But these are the steps I have followed:

    I had removed ABP CLI to install ABP CLI version 4.4.3 in order to create a Blazor application for version 4.4.3.

    Updated the Index.razor.cs file:

    namespace MyApp.Blazor.Pages 
    { 
        [Authorize] 
        public partial class Index 
        { 
     
        } 
    } 
    

    This configuration automatically redirects the application to login page. Update MyAppBlazorModule.cs file:

    private static void ConfigureAuthentication(WebAssemblyHostBuilder builder) 
    { 
        builder.Services.AddOidcAuthentication(options => 
        { 
            builder.Configuration.Bind("AuthServer", options.ProviderOptions); 
            options.UserOptions.RoleClaim = JwtClaimTypes.Role; 
            options.AuthenticationPaths.LogOutSucceededPath = "/"; 
            options.ProviderOptions.DefaultScopes.Add("MyApp"); 
            options.ProviderOptions.DefaultScopes.Add("role"); 
            options.ProviderOptions.DefaultScopes.Add("email"); 
            options.ProviderOptions.DefaultScopes.Add("phone"); 
        }); 
    } 
    

    Result:

    Yes, it's working like this. Is there any way to remove account/loggedout page redirection?

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Unfortunately, there is no mention of it in this documentation: https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/additional-scenarios?view=aspnetcore-6.0

    We (as ABP Framework) don't implement directly this flow. It's implemented by Microsoft, you may ask them about it. There may be an internal API or something else but I don't think so. Because that component performs the functionality, if you can achieve to remove it, the logout functionality won't be performed at the end.

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