Possibly working custom authorization

This commit is contained in:
Cyberboss
2017-11-28 12:37:35 -05:00
parent 1e89391e89
commit 2894ea03d7
10 changed files with 152 additions and 22 deletions
+2 -9
View File
@@ -393,24 +393,17 @@ namespace TGS.Interface
}
//okay we're going over
var binding = new WSHttpBinding()
var binding = new BasicHttpsBinding()
{
SendTimeout = new TimeSpan(0, 0, 40),
MaxReceivedMessageSize = TransferLimitRemote
};
var requireAuth = InterfaceName != typeof(ITGConnectivity).Name;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Mode = requireAuth ? SecurityMode.TransportWithMessageCredential : SecurityMode.Transport; //do not require auth for a connectivity check
binding.Security.Message.ClientCredentialType = requireAuth ? MessageCredentialType.UserName : MessageCredentialType.None;
var url = String.Format("https://{0}:{1}/{2}/{3}", LoginInfo.IP, LoginInfo.Port, accessPath, InterfaceName);
var address = new EndpointAddress(url);
var res = new ChannelFactory<T>(binding, address);
if (requireAuth)
{
res.Credentials.UserName.UserName = LoginInfo.Username;
res.Credentials.UserName.Password = LoginInfo.Password;
res.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
}
res.Endpoint.EndpointBehaviors.Add(new AuthenticationHeaderApplicator(LoginInfo));
return res;
}