Chcę zabezpieczyć punkt końcowy usługi WCF, nie wiem, czy można zabezpieczyć niektóre punkty końcowe, a niektóre nie. Poniżej mam usuniętą usługę WCF (hostowane samodzielnie). Ta sama funkcja WCF obsługuje również plik zasad urzędu certyfikacji. Jeśli zabezpieczysz tę usługę WCF lub niektóre punkty końcowe ut, część CA Policy nie może zadać mi hasła do nazwy użytkownika. Plik zasad musi być dostępny przez cały czas. Czy to też jest możliwe?Zabezpieczanie punktu końcowego usługi WCF za pomocą niestandardowego uwierzytelniania
Znalazłem wiele niestandardowych blogów/postów WCF. Istnieje wiele sposobów na zapewnienie bezpieczeństwa. Wszystko, czego chcę, to to, że mogę zabezpieczyć niektóre punkty końcowe nazwą użytkownika/hasłem, ale poświadczenia nie mogą być widoczne przy użyciu narzędzi takich jak Fiddler. Dane jednak mogą być widoczne w tym przypadku.
Zaimplementowałem już Customvalidator, ale plik app.config jest również importerem, aby zdefiniować rzeczy. I nie jestem w tym dobry.
namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public ServiceHost _host = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Create a ServiceHost for the CalculatorService type and
// provide the base address.
_host = new ServiceHost(typeof(WmsStatService));
_host.AddServiceEndpoint(typeof(IPolicyProvider), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());
_host.Open();
}
}
// Define a service contract.
[ServiceContract(Namespace = "http://WindowsFormsApplication11")]
public interface IWmsStat
{
[OperationContract]
string getConnectedViewers(string channelName);
[OperationContract]
string sayHello(string name);
}
[ServiceContract]
public interface IPolicyProvider
{
[OperationContract, WebGet(UriTemplate = "/ClientAccessPolicy.xml")]
Stream ProvidePolicy();
}
//[DataContract]
public class Ads
{
// [DataMember]
public string AdFileName { get; set; }
//[DataMember]
public string AdDestenationUrl { get; set; }
public string ConnectedUserIP { get; set; }
}
//
public class CustomValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if(null == userName || null == password)
{
throw new ArgumentNullException();
}
if(userName == "Oguz" && password == "2009")
{
return;
}
FaultCode fc = new FaultCode("ValidationFailed");
FaultReason fr = new FaultReason("Good reason");
throw new FaultException(fr,fc);
}
}
//
public class WmsStatService : IWmsStat, IPolicyProvider
{
public string sayHello(string name)
{
return "hello there " + name + " nice to meet you!";
}
public Stream ProvidePolicy()
{
WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";
return new MemoryStream(File.ReadAllBytes("ClientAccessPolicy.xml"), false);
}
public string getConnectedViewers(string channelname)
{
// do stuff
return null;
}
}
}
Aplikacja.config. Ten plik konfiguracyjny nie działa. Chciałem umieścić niestandardowe uwierzytelnienie dla punktu końcowego. Nie mam pojęcia.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WindowsFormsApplication11.WmsStatService" behaviorConfiguration="mex">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.199:87" />
</baseAddresses>
</host>
<endpoint address="http://192.168.0.199:87/Test" binding="basicHttpBinding" bindingConfiguration="" contract="WindowsFormsApplication11.IWmsStat" behaviorConfiguration="MyServiceBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<!--<bindings>
<wsHttpBinding>
<binding name="wshttp">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>-->
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
</behavior>
<behavior name="MyServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WindowsFormsApplication11.CustomValidator, CustomValidator" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Cholera jestem coraz to teraz :( Nie można załadować pliku lub zestawu „CustomValidator” lub jeden z jego zależnościami System nie może odnaleźć określonego pliku – Shift
Błąd ten wynika z tego config tutaj: serviceCredentials> jest, że "CustomValidator" zespół dostępny po uruchomieniu usługi ?? –
Zmieniłem że do WindowsFormsAppiication11. to jest samodzielnym gospodarzem WCF usługa na Windows Forms Po tym, jak zmieniłem to na to, co powiedziałem, błąd zniknął, ale kolejny numer :( Program ChannelDispatcher pod adresem "http://192.168.0.199:87/Test" z umowami "" IWmsStat "nie może otworzyć swojego IChannelListener – Shift