Greg P
Greg P

Reputation: 117

IdentityServer4 Asp.Net Core Identity with custom store

I am using IdentityServer4 with Asp.Net Identity. I need to implement a custom identity store which sounds easy enough, but all of the examples I see use EntityFramework core which I am not using.

Perhaps there is another way to use a custom user store. Can anyone point me to an example of using a custom credential store using IdentityServer4.

Upvotes: 2

Views: 6558

Answers (1)

Icad
Icad

Reputation: 101

Basically it boils down to Implementing an IProfileService and an IResourceOwnerPasswordValidator and registering the implementations with the config builder.

This blog post shows a succinct implementation of this

https://damienbod.com/2017/04/14/asp-net-core-identityserver4-resource-owner-password-flow-with-custom-userrepository/

This extension class is where it all happens

public static class CustomIdentityServerBuilderExtensions
{
    public static IIdentityServerBuilder AddCustomUserStore(this IIdentityServerBuilder builder)
    {
        builder.Services.AddSingleton<IUserRepository, UserRepository>();
        builder.AddProfileService<CustomProfileService>();
        builder.AddResourceOwnerValidator<CustomResourceOwnerPasswordValidator>();

        return builder;
    }
}

Upvotes: 5

Related Questions