dotnet / dotnet/aspnetcore

AddUserStore should allow injection via IUserStore<T> as well as actual type

Open
#15,168 8 comments 0 reactions 0 assignees View on GitHub
affected-very-few area-identity enhancement severity-nice-to-have
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

For identity services such as UserManager or RoleManager, when using a custom type, the service is available under both the UserManager AND the custom type itself for dependency injection. Similarly RoleManager and a few others also forward the services for both the required type and the custom type.
However other identity services dont, specifically the IUserStore.
In my application, I have some additional methods added to IUserStore so I need it under a more specific type, and it requires a
`services.AddScoped(typeof(CustomStore), serviceFinder => serviceFinder.GetRequiredService(typeof(IUserStore)));`
It just seems inconsistent that I have to forward the IUserStore service manually, but the UserManager and SignInManager and RoleManager, ect don't need to be.

Interestingly enough, the AddUserStore() method also isn't doing any type validation whereas all the other methods do.

### Describe the solution you'd like
I would like the implementation of AddUserStore()
https://github.com/aspnet/AspNetCore/blob/master/src/Identity/Extensions.Core/src/IdentityBuilder.cs#L108
to look more like that of AddUserManager()
https://github.com/aspnet/AspNetCore/blob/master/src/Identity/Extensions.Core/src/IdentityBuilder.cs#L145

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.