Base solution for your next web application
Open Closed

ExternalAuth with custom provider #3196


User avatar
0
VuCA created

Hi admin,

I want to authentication asp.net zero web application with custom provider (it's just a services that allow end user input user name and their password and then return true or false), please show me how to do that.

Thanks!


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can follow this document <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Zero/User-Management#external-authentication">https://aspnetboilerplate.com/Pages/Doc ... entication</a>.

    Thanks.

  • User Avatar
    0
    VuCA created

    Can you tell me more about this? In my case I have two type authentication, with internal user I use ADFS (it's ok now), and with external user I have another database stored username and password. Please tell me all I need to do to create custom external authentication in aspnet zero project

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    First you need to define an external auth source like this.

    public class MyExternalAuthSource : DefaultExternalAuthenticationSource<Tenant, User>
    {
        public override string Name
        {
            get { return "MyCustomSource"; }
        }
    
        public override Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, Tenant tenant)
        {
            //TODO: authenticate user and return true or false
        }
    }
    

    Then, you need to add it to ExternalAuthenticationSources like this:

    Configuration.Modules.Zero().UserManagement.ExternalAuthenticationSources.Add<MyExternalAuthSource>();
    
  • User Avatar
    0
    VuCA created

    Hi, And what i need to do next? How the system know the custom login form? Do I need some config in web.cofig file. I don't know how to implement that, please let me know more detail.

    Thanks!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @VuCA,

    As I remember it should just work in that way. Have you tried it ?

    Thanks.

  • User Avatar
    0
    VuCA created

    Hi ismcagdas,

    I've already tried but it was not successfull, please give me an example to deal with exteranal authentication. Pls

    It's alway throw error "loginResult" = "InvalidUserNameOrEmail", when I debug on Abp.Zero project, TryLoginFromExternalAuthenticationSources function, it await long time and doesn't reponse :o

    Thanks!