Ive built a custom provider to support groups and nosql databases. And it all seems to work apart from authentication (accounts can be created end som forth without issues). I use my own entity classes which are not inherited from identityuser etc should be noted.
The issue im having is as said that running for example var loginres = await this.signInManager.PasswordSignInAsync("username", "paswd", false, false) is giving me an exception,
InvalidOperationException: No authentication handler is configured to handle the scheme: Identity.Application
The way ive setup my code is as follows:
services.AddIdentity<User, Role>()
.AddUserStore<NoSqlUserStore<User, Role>>()
.AddRoleStore<NoSqlRoleStore<Role>>()
.AddUserManager<IdentityUserManager<User>>()
.AddRoleManager<IdentityRoleManager<Role>>()
.AddDefaultTokenProviders();
The manager classes just inherits the User and role manage classes, nothing is changed or added atm.
public class IdentityUserManager<TUser> : UserManager<TUser>
where TUser : User, new()
{
public IdentityUserManager(IUserStore<TUser> store, IOptions<IdentityOptions> optionsAccessor, IPasswordHasher<TUser> passwordHasher, IEnumerable<IUserValidator<TUser>> userValidators, IEnumerable<IPasswordValidator<TUser>> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger<IdentityUserManager<TUser>> logger)
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
{
}
}
public class IdentityRoleManager<TRole> : RoleManager<TRole>
where TRole : Role
{
public IdentityRoleManager(IRoleStore<TRole> store, IEnumerable<IRoleValidator<TRole>> roleValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, ILogger<RoleManager<TRole>> logger, IHttpContextAccessor contextAccessor)
: base(store, roleValidators, keyNormalizer, errors, logger, contextAccessor)
{
}
}
The signatures for the stores are as follows:
public class NoSqlRoleStore<TRole> : RoleStoreBase, IRoleStore<TRole>
where TRole : Role, new()
{
}
public class NoSqlUserStore<TUser, TRole> : UserStoreBase<TUser>, //todo: include groups in rolechecking
IUserLoginStore<TUser>,
IUserRoleStore<TUser>,
IUserClaimStore<TUser>,
IUserPasswordStore<TUser>,
IUserSecurityStampStore<TUser>,
IUserEmailStore<TUser>,
IUserLockoutStore<TUser>,
IQueryableUserStore<TUser>,
IUserTwoFactorStore<TUser>,
IUserAuthenticationTokenStore<TUser>
where TUser : User, IEntity, new() where TRole : Role, IEntity, new()
{
}
Of course they contain all interface methods, it compiles, runs and works except for the error. The User And role classes are plain entities that is somewhat similar to the provided ones.
My guess is im missing some configurationsetting (even if, as far as ive seen, that identity should provide working default in regards to this?) or something. Ive never used identity outside the default entity framework provider. But i was hoping that someone perhaps knows what is needed here? (if any more code is needed to illustrate the situation ill fix it)