Open Closed

How to authenticate against separate database? #2653


User avatar
0
TonyH created

I've previously used ASP.NET Zero, where I could modify the authentication code so that the username / password combination was passed to my own external service, which would then authenticate the user against a standalone database used for a separate application.

When the response was returned, ASP.NET Zero was automatically creating the user in it's own database as well.

Is there a way to achieve something similar in ABP.io? Basically, I need to take the username / password that the user enters, and pass those, along with a custom key stored against the tenant, to an external service. That service will return a boolean indicating whether the username / password was a valid combination, along with a key/value list that will need to be stored against the ICurrentUser ... I'm guessing as Claims?

Any help / examples would be appreciated!

T


7 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Is it this?

    https://github.com/abpframework/abp/issues/4977

  • User Avatar
    0
    TonyH created

    Indeed, that could be the core of the solution! I will try it in the next day or so, and see if it meets the requirements.

    I'm not sure how/where I could create new user Claims in this scenario, though.

    Is that something that would happen in GetUserInfoAsync?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://docs.abp.io/en/abp/latest/Authorization#claims-principal-factory

  • User Avatar
    0
    TonyH created

    Okay, partway there with this. I'm just stuck on where to put this code:

    Configure<AbpIdentityAspNetCoreOptions>(options => { options.ExternalLoginProviders.Add<FakeExternalLoginProvider>(FakeExternalLoginProvider.Name); });

    I'm on current build, Blazor, minimal .NET 6.

    I thought it might have to go into the module class, in the "ConfigureExternalProviders" method ... but I can't seem to get the syntax correct.

    Can you please assist?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    This does't support the balzor wasm. You should configure it on the API website.

  • User Avatar
    0
    TonyH created

    Great, thanks.

    Read a little further down, and someone had corrected the registration code so that it used "AbpIdentityOptions", rather than "AbpIdentityAspNetCoreOptions":

    Configure<AbpIdentityOptions>(options => { options.ExternalLoginProviders.Add<FakeExternalLoginProvider>(FakeExternalLoginProvider.Name); });

    Actually got it working in the Blazor app ... I'm building for server-side Blazor, not WASM. That said, yes, it probably needs implementing in the API project as well.

    That's half the problem solved ... now to tackle the Claims component ... :-)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://docs.abp.io/en/abp/latest/Authorization#claims-principal-factory

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11