cro*_*arp 5 .net c# authentication wcf web-services
可以使用两种类型的身份验证:wcf中的窗口和用户名,使用消息安全模式和证书进行身份验证.我的UserName身份验证cfg/code看起来:
Server cfg:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceCredentialsBehavior">
<serviceCredentials>
<serviceCertificate findValue="cn=cool" storeName="TrustedPeople" storeLocation="CurrentUser" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Util.CustomUserNameValidator, Util" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceCredentialsBehavior" name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
客户cfg:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="LocalCertValidation">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" >
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:48097/WCFServer/Service.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService"
contract="ServiceReference1.IService"
name="WSHttpBinding_IService" behaviorConfiguration="LocalCertValidation">
<identity>
<dns value ="cool" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有什么变化,服务器要知道访问它的Windows身份?
有趣的问题!如果您确实需要混合使用身份验证,可以尝试将传输设置为一种身份验证类型,将消息设置为另一种身份验证类型。我不知道这在实践中是否可行,但考虑到您可以单独配置它们,这似乎是合理的:)
\n您可以看看是否可以为您的绑定设置类似于下面的内容来获取 Windows 凭据(wsHttpBinding 可以处理 Windows 凭据)。
\n <security mode="Transport">\n <transport clientCredentialType="Whatever your authentication method is" />\n <message clientCredentialType="Windows" />\n </security>\nRun Code Online (Sandbox Code Playgroud)\n如果您尝试一下,请告诉我是否有效!
\n编辑:
\n哦,根据文档,可以进行混合身份验证。您必须将模式设置为“混合”,因此配置可能如下所示:
\n <security mode="mixed">\n <transport clientCredentialType="Whatever your authentication method is" />\n <message clientCredentialType="Windows" />\n </security>\nRun Code Online (Sandbox Code Playgroud)\n从文档中:
\n混合安全。 混合安全性为您提供两全其美的优势:传输安全性确保消息的完整性和机密性,而用户凭证和声明则像消息安全性一样封装在每条消息中。这允许您使用严格的传输安全机制无法实现的各种用户凭据,并利用传输安全性\xe2\x80\x99s 性能。
\n| 归档时间: |
|
| 查看次数: |
4480 次 |
| 最近记录: |