2

Some weeks ago I discovered OpenID Connect and IdentityServer V3. I ran some of the supplied examples and I am today at the point where I need to go further but I don't know how to proceed:

Actually we have an "home made" authentication and authorization process and we'd like to move to an OpenID Connect solution. Identity Server seems to be the perfect candidate to do this.

Today our users are stored into an SQL Server Database and ideally I'd like to "connect" this table to Identity Server (without touching to the schema of this table). I read about "MembershipReboot" but it uses its own Database. I also heard about making a custom user service but in the sample (CustomUserService) I did not find anything helpfull. Today I'am a little bit lost because I don't know where to go and I realize that I'am not very far from the target.

I need help

Thank you

4

1 回答 1

2

In the Custom User Service Sample you mentioned, it includes three variations of user service to show different approaches, but you really only need one of them.

In the LocalRegistrationUserService sample you'll find lines like these:

    public override Task AuthenticateLocalAsync(LocalAuthenticationContext context)
    {
        var user = Users.SingleOrDefault(x => x.Username == context.UserName && x.Password == context.Password);
/// snip ...

and these:

   public override Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        // issue the claims for the user
        var user = Users.SingleOrDefault(x => x.Subject == context.Subject.GetSubjectId());
/// snip...

You need to replace those calls which look up values from the in-memory Users collection with something that opens a connection to SQL server and looks them up there instead.

See the Custom User Service documentation for more methods supported, but those two (AuthenticateLocalAsync, GetProfileDataAsync) plus your SQL lookup are all you need to get started.

于 2015-09-11T18:10:01.877 回答