I am adapting ASP Identity authentification functionalitys to be called from a WCF web service.
I am using ninject for dependency injection across the project, so I have a custom class (UserProfilManager) witch i use to implement Identity functions by injecting dependencies required by my constructor.
public class UserProfilManager
{
private readonly UserStore _userStore;
private readonly UserManager<IdentityUser, Guid> _userManager;
private readonly SignInManager<IdentityUser, Guid> _signInManager;
public UserProfilManager(UserStore userStore,
UserManager<IdentityUser, Guid> userManager,
SignInManager<IdentityUser, Guid> signInManager)
{
_userStore = userStore;
_userManager = userManager;
_signInManager = signInManager;
}
//here I call Identity functionality (PasswordSignInAsync), GetByLogin is a function ment to be called from WCF
public async Task<SignInStatus> GetByLogin(string login, string password, bool RememberMe, bool shouldLockout)
{
return await _signInManager.PasswordSignInAsync(login, password, RememberMe, shouldLockout);
}
//FindByNameAsync function works fine, UserStore binding : OK
public User GetByName(string login)
{
var user = _userStore.FindByNameAsync(login);
return new User
{
//...
};
}
}
the 'UserStore' and the 'UserManager' bindings are done fine, but 'SignInManager' throws an ActivationException : Error activating IAuthenticationManager, No matching bindings are available, and the type is not self-bindable. I fixed it by adding this:
public class UserModule : NinjectModule
{
public override void Load()
{
Bind<IDbContext>().To<DbContext>();
Bind<IUserProfilManager>().To<UserProfilManager>();
Bind<IUserStore<IdentityUser, Guid>>().To<UserStore>();
Bind<IAuthenticationManager>().
ToMethod(c => HttpContext.Current.GetOwinContext().Authentication).InRequestScope();
}
}
Now it's giving me this Error:
The following errors occurred while attempting to load the app. - No assembly found containing an OwinStartupAttribute. - No assembly found containing a Startup or [AssemblyName].Startup class. To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config. To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
I don't have a startup class and I don't need it, I tried to top hip from searching that class by adding <add key="owin:AutomaticAppStartup" value="false" />
in my WCF web.config but it throws an Internal Server Error :
Failed to add a service. The metadata of the service may be unavailable. Make sure your service is running and exposes metadata.
can someone please tell me what I am doing wrong, or suggest a solution based on my code.