brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
743 stars 239 forks source link

How to set up a CustomUserRepository? #701

Open Vincent026 opened 7 years ago

Vincent026 commented 7 years ago

Hello,

we want to make a CustomUserRepository based on our own database repository (no EF, Mongo or Raven). I derive this repo from QueryableUserAccountRepository, register the user & group repo's (as singletons) plus their services with the IdentityManagerServiceFactory and implement the repo-methods. I have some trouble to make it work. I manage to get the list of users on the screen but when I try to edit a single user I get Error: An error has occurred.

Some useful hints would be great.

thanks, Vincent

brockallen commented 7 years ago

Maybe this helps: https://github.com/brockallen/BrockAllen.MembershipReboot/wiki/Implementing-A-Custom-Storage-Mechanism

Vincent026 commented 7 years ago

Thanks for the quick response Brock! I will have a close look at this article again.

Vincent026 commented 7 years ago

Our current implementation, based on your examples, uses some InMemory clients, users and scopes, registered in the IdentityServerServiceFactory, which is mapped to the path "/identity". I see that there is also a mapped path named "/core". Which mapping do I need to the configure the IdentityServerServiceFactory, in order to register the custom user service?

kind regards

brockallen commented 7 years ago

Whichever you want. All of those are just samples.

Vincent026 commented 7 years ago

Thanks! My first thought was that these where compulsory predefined end points. I am getting closer to what I want.

Vincent026 commented 7 years ago

I am making progress with implementing CustomUserAccountService and CustomUserRepository. It seems that a hashed password is expected to be stored. Our table has a readable password field and that is ok with us. I rather don't modify the schema of the user table, What I am trying to do now is intercepting authentication by overriding the Authenticate method(s) in the CustomUserAccountService. Is this a good strategy for overriding authentication (to validate the password with the readable field instead of using the hashedpassword)?

brockallen commented 7 years ago

If you have an existing DB for users, then I don't see why you want to use MR. Just implement the IUserService in IdentityServer.

Vincent026 commented 7 years ago

You are right that we already have a way of filling our DB and there is no need for us to have MR to do the CRUD actions. However, this may change in the future. Besides that, we have several user sources and I can use MR to show the combined set. I don't implement the Create, Update and Delete methods in the repo.