Very complex configuration
See original GitHub issueIn Startup.ConfigureServices
of Admin and AdminApi projects there are lots of Type parameters (Admin, for example).
It’s very difficult to understand, which parameter user should to change if he want to change something.
I suppose to create a builder to split this method. It’ll look something like this:
services.AddAdminAspNetIdentityServices(); // With default values like string keys, DbContexts, etc.
services.AddAdminAspNetIdentityServices(admin => {
admin.ConfigureIdentity(identity => {
identity.ConfigureKeys(keys => {
keys.UseUserKey<string>();
...
})
.ConfigureEntities(entities => {
entities.UseUser<IdentityUser<string>>();
...
});
}
...
});
In configuration we start from default values, so user can skip some blocks like ConfigureKeys
.
I start to making this, but I have some question for now (may be I’ll add some more later):
In Skoruba.IdentityServer4.Admin.EntityFramework.Identity.Repositories.IdentityRepository
you have TUserKey
, TRoleKey
, and TKey
parameters (src).
TUserKey
and TRoleKey
are never used except these 2 methods: ConvertUserKeyFromString
and ConvertRoleKeyFromString
All other parameters are depend from TKey
(TUser : IdentityUser<TKey>
, for example).
Later you use UserManager<IdentityUser<TKey>>.Users.AnyAsync(x => x.Id.Equals(_instance of TUserKey_));
here.
If TKey
and TUserKey
will be a different types, this code will fall, isn’t it?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (7 by maintainers)
Yes, of course. IdentityUserRole<TKey> from AspNetCore. Constraint for TUserRole in your code.
Hi @b0 I definitely agree with you, I am happy for this PR, but it is too complex - splitting would be perfect.