I am using WebAPI and hosting it with Katana. I'm writing some middleware right now that will be used for authentication and authorization. I have to use basic authentication with SSL because requests could be coming from a variety of platforms. OAuth is also not an option at this time. The middleware needs to take the username and password provided from basic authentication and validate that the user is a member in a local Windows Group.
Right now I am trying to figure out how to create a WindowsPrincipal. If I could figure how to create a WindowsPrincipal from a username and password I know how to do the rest. Here is what I have right now.
//TODO
WindowsPrincipal userPrincipal = null; //This is where I need to take the username and password and create a WindowsPrincipal
Thread.CurrentPrincipal = userPrincipal;
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
PrincipalPermission permission = new PrincipalPermission(null, "Local Group Name");
permission.Demand();
I am struggling to find a good way to use the username and password to validate that the member is part of a specific group. What is the best way to do this? Thanks for the help in advance.