How to extend the auth service to non-machine/non-domain users

Dec 7, 2012 at 10:27 PM


First thanks for this nice library. I am currently trying to extend it so that it is able to authenticate users from a database or xml file. i see the following code is called when a password auth is requested 


 public override void UserAuthRequestPacket(ITransportLayerManager manager, UserAuthRequestPacket packet)        {


   if (packet.AuthMethod == AuthenticationMethod.Password)            {                IPasswordAuthenticationService passwordAuthService = Dependency.Resolve<IPasswordAuthenticationService>();                UserAuthPasswordPayload passwordPayload = (UserAuthPasswordPayload) packet.AuthPayload;
                IIdentity identity = passwordAuthService.CreateIdentity(packet.UserName, passwordPayload.Password);
                if (identity != null)                {                    manager.WritePacket(new UserAuthSuccessPacket());                    manager.AuthenticatedIdentity = identity;                    manager.Password = passwordPayload.Password;                    manager.ChangeState(TransportLayerState.Authenticated);                    return;                }                else                {                    // Fall through to failure case                }            }


now i want to create a new class which would implement IPasswordAuthenticationService interface but instead of Windows Identity i want to be able to authenticate users from my database or xml file. So in the CreateIdentity method that is provided by the interface mentioned above i would just return a new Object that implements IIdentity. 

First question: Is this the right approach?

Second Question: How would i know whether the user wants to be authenticated via Database vs Windows?


Thanks for your help