locked
Custom User Service for Tehinktecture Identity Server RRS feed

  • Question

  • User1741474265 posted

    I am trying to create a custom user service for the Identity server. My user store will be multiple Active Directories. I have implemented Local Login.

    public Task<AuthenticateResult> AuthenticateLocalAsync(string username, string password, SignInMessage message)
            {
                AuthenticationService service = new AuthenticationService();
                ResponseStatus status = service.Authenticate(username, password);
    
                CustomUser user;
    
                if(status == ResponseStatus.Success)
                {
                    user =
                    new CustomUser()
                    {
                        Subject = username,
                        Username = username,
                        Claims = new List<Claim>
                        {
                            new Claim(Constants.ClaimTypes.PreferredUserName, username)
                        }
                    };
    
                    Users.Add(user);
    
                    return Task.FromResult<AuthenticateResult>(new AuthenticateResult(user.Subject, user.Username));
                }
                else
                {
                    return Task.FromResult<AuthenticateResult>(null);
                }
            }

    "Users" is a static List of CustomUser class. If I understand correctly this "Users" list will be in the memory and is used in other methods like "IsActiveAsync".

    public Task<bool> IsActiveAsync(ClaimsPrincipal subject)
            {
                var user = Users.SingleOrDefault(x => x.Subject == subject.GetSubjectId());
                return Task.FromResult(user != null);
            }

    Does this really help when I am using AD as this is not going to check if the user is active in AD. Do we really need to keep users in the memory? Or Is my implementation is off the track for this scenario?

    Thanks for the help.

    Thursday, February 26, 2015 4:24 PM

Answers

  • User1779161005 posted

    You really should post your IdentityServer questions to the github forums.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 26, 2015 5:55 PM

All replies

  • User1779161005 posted

    You really should post your IdentityServer questions to the github forums.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 26, 2015 5:55 PM
  • User1741474265 posted

    Thanks Allen. Just posted but I don't have rights to mark it as a question. so it is an issue for now.

    Thursday, February 26, 2015 10:09 PM