Base solution for your next web application
Open Closed

External authentication via web service #1533


User avatar
0
geckotechnical created

Hi,

I am trying to enable external authentication at the login screen following the documentation written: here

I have created a class inheriting DefaultExternalAuthenticationSource

public class GeckoAuthenticate : DefaultExternalAuthenticationSource<Tenant, User>
    {
        public override string Name
        {
            get
            {
                return "GeckoAPI";
            }
        }

        public override async Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, Tenant tenant)
        {
            //Authenication
        }
    }

and then added

Configuration.Modules.Zero().UserManagement.ExternalAuthenticationSources.Add<GeckoAuthenticate>();

into the PreInitalize of the module, but when attempting to log in I get an exception

Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service TaxwiseTest.GeckoServices.GeckoAuthenticate was found
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)
   at Castle.Windsor.WindsorContainer.Resolve(Type service)
   at Abp.Dependency.IocManager.Resolve(Type type) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Dependency\IocManager.cs:line 194
   at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver, Type type) in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Dependency\IocResolverExtensions.cs:line 32
   at Abp.Authorization.Users.AbpUserManager`3.&lt;TryLoginFromExternalAuthenticationSources&gt;d__60.MoveNext() in D:\Halil\GitHub\module-zero\src\Abp.Zero\Authorization\Users\AbpUserManager.cs:line 499

I'm guessing this means I have missed something somewhere, but I don't know where Any help would be appreciated

Thanks


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

    Hi,

    just derive your class from either ITransiendDependency or ISingletonDependency according to your needs.

    public class GeckoAuthenticate : DefaultExternalAuthenticationSource<Tenant, User>, ITransientDependency
    

    We will add this to documentation as well, thanks for informing us.

  • User Avatar
    0
    geckotechnical created

    Working now Thanks very much