Немного новое с услугами WCF при использовании имени пользователя и паролей. Я следил за учебником, найденным в http://www.codeproject.com/Articles/96028/WCF-Service-with-custom-username-password-authenti, чтобы защитить мою веб-службу с помощью имени пользователя и пароля.Служба WCF с именем пользователя и паролем
Мой файл конфигурации ниже
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="NewBehavior0" name="TService">
<endpoint address="mex" binding="mexHttpBinding" contract="ITechnology" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="Server" storeLocation="CurrentUser"
storeName="TrustedPeople" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TService, Services1"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Теперь я могу просмотреть WDSL в моем браузере и я знаю сертификат работы, как ожидается, на местном уровне. Когда я подключаюсь к службе с помощью инструмента тестирования WCF, он не запрашивает у меня имя пользователя и пароль.
Согласно ссылке, которую я опубликовал, и после ive даже не сделал последнего шага (добавление кода для ввода имени пользователя и пароля), но я все же могу подключиться к службе и получить все данные.
Что я пропустил и как я могу ограничить услугу, где только имя пользователя и пароль позволяют пользователю/сервису извлекать данные?
Edit 1:
<system.serviceModel>
<services>
<service behaviorConfiguration="NewBehavior0" name="TechService">
<endpoint address="mex" binding="mexHttpBinding" contract="ITechService" />
<endpoint address="TechService.svc" binding="wsHttpBinding" bindingConfiguration="" contract="ITechService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBinding0">
<security>
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="PeerTrust" />
</clientCertificate>
<serviceCertificate findValue="Server" storeLocation="CurrentUser"
storeName="TrustedPeople" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="TechService, Services1"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Ваш элемент службы и элемент конечной точки должны иметь атрибуты имени и контракта, чтобы быть полностью квалифицированными именами, то есть namespace.Service и namespace.ITechnology. В соответствии с вашей конфигурацией конечная точка не использует правильный механизм привязки. Это должно быть wsHttpBinding или basicHttpBinding с транспортной безопасностью – Rajesh