Open Closed

Identity Client Configuration #1781


User avatar
0
Spospisil created
  • ABP Framework version: v4.4.0
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I have overriden the default login page and call the base OnPostAsync() method but when the result is returned the user is still not authenticated. I looked in the log and I'm getting an error for the IdentityClientConfiguration for AbpAccountPublic. Either define a configuration for AbpAccountPublic or set a default configuration. How do I override this to see accoring to what my ideneityclient configurations are?


8 Answer(s)
  • User Avatar
    0
    Spospisil created

    There is a row in the SecurityLogs table who's action column value is 'LoginSucceeded' but the CurrentUser.IsAuthenticated value still is not set to 'true' after the base.OnPostAync(action) method is called.

  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Related answer: https://support.abp.io/QA/Questions/1668/Overriding-UI-of-Login-Page---Identity-Server#answer-3bdcd901-078a-260e-5aae-39fe9a763488

  • User Avatar
    0
    Spospisil created

    I'm still experiencing this issue depsite those two lines not being in the AddAuthentication call. Even though I get a successlogin row in the security log table the IsAuthenticated property is still set to false.

  • User Avatar
    0
    Spospisil created

    I've removed the following 2 lines from the AddAuthentication method but after I call the base.OnPostAsync(action) method from my class that overrides the LoginModel class but after the result is returned the CurrentUser.IsAuthenticated property is still set to false despite have a SuccessfulLogin row in the SecuirtyLogs table.

    options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc";

    Please advise.

  • User Avatar
    0
    Spospisil created

    This is my ConfigureAuthentication method

    private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
    {
        context.Services.AddAuthentication(options =>
            {
            })
            .AddCookie("Cookies", options =>
            {
                options.ExpireTimeSpan = TimeSpan.FromDays(365);
            })
            .AddAbpOpenIdConnect("oidc", options =>
            {
                options.Authority = configuration["AuthServer:Authority"];
                options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);;
                options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
    
                options.ClientId = configuration["AuthServer:ClientId"];
                options.ClientSecret = configuration["AuthServer:ClientSecret"];
    
                options.SaveTokens = true;
                options.GetClaimsFromUserInfoEndpoint = true;
    
                options.Scope.Add("role");
                options.Scope.Add("email");
                options.Scope.Add("phone");
            });
    }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi Spospisil

    Identity authentication will take effect in the next request.

    For current request:

    using (CurrentPrincipalAccessor.Change(await SignInManager.CreateUserPrincipalAsync(user)))
    {
        //Use currentuser here
    }
    
  • User Avatar
    0
    Spospisil created

    Below is my overridden OnPostAync method. The .IsAuthenticated is returning true when I supply the improper credentials now. Please tell me how this code block should look like for me to interrogate the result of the base.OnPostAsync method and to determine if authentication was successful or not so I can redirect the application to the appropriate page.

    Thanks.

    public override async Task<IActionResult> OnPostAsync(string action)
    {
        ReturnUrl = "../HostDashboard";
    
        var result = await base.OnPostAsync(action);
    
        var user = await GetIdentityUser(LoginInput.UserNameOrEmailAddress);
    
        if (user != null)
        {
            using (CurrentPrincipalAccessor.Change(await SignInManager.CreateUserPrincipalAsync(user)))
            {
                if (CurrentUser.IsAuthenticated)
                {
                    return RedirectToPage(ReturnUrl);
                }
            }
        }
    
        return Page();
    }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think you can copy all code from the base method.

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