6

I am trying to authenticate a user against an existing user database. I have an existing database with a users table and I want the Identity Server to look at this database and get authenticate the user.

I have found examples for MembershipReboot and AspNetIdenetity, but I am confused on how I need to create my own user database mapping.

I am not trying to create an external provider e.g Facebook

Has anyone got any ideas or seen any tutorials on how this can be done?

Carl Thomas
  • 3,605
  • 6
  • 38
  • 50

1 Answers1

9

You can implement your own IUserService, then in your startup you can set IdentityServer to use your new User Service

var factory = InMemoryFactory.Create(
    clients: Clients.Get(), 
    scopes: Scopes.Get());

var userService = new MyUserService();
factory.UserService = new Registration<IUserService>(resolver => userService);

https://identityserver.github.io/Documentation/docsv2/advanced/userService.html

EDIT: Fixed dead link

Community
  • 1
  • 1
Yes
  • 308
  • 3
  • 11
  • 2
    How would this work with clients, scopes etc stored in the same database and not in memory like all the examples? This is partly what I am confused about. – Carl Thomas Jul 30 '15 at 20:56
  • 1
    You can write your own custom stores for those. I have yet to find any documentation but I just followed the source for the EntityFramework package found here https://github.com/IdentityServer/IdentityServer3.EntityFramework/tree/master/Source/Core.EntityFramework/Stores – Yes Aug 03 '15 at 08:48
  • 1
    Thanks for the heads up about that repo, I must have missed that before. I will follow your lead and base it off that. – Carl Thomas Aug 03 '15 at 11:44