Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Custom User Service for Tehinktecture Identity Server

$
0
0

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.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>