[英]WCF Security Mode TransportWithMessageCredential
I've not a WCF service running as a windows service that I've converted to use the Custom UserNamePasswordValidator. 我没有作为Windows服务运行的WCF服务,我已将其转换为使用自定义UserNamePasswordValidator。
This all worked perfectly on the original setting of SecurityMode = "Transport". 在SecurityMode =“ Transport”的原始设置上,所有这些都可以完美运行。
However the only problem is that none of the faultexceptions would come back correctly. 但是,唯一的问题是没有任何错误异常会正确返回。 I guessed this was because it needs to be a security mode of TransportWithMessageCredential.
我猜这是因为它必须是TransportWithMessageCredential的安全模式。
The problem I have is when I set the security mode to be TransportWithMessageCredential the UserNamePasswordValidator validate method is now not hit. 我遇到的问题是,当我将安全模式设置为TransportWithMessageCredential时,现在没有找到UserNamePasswordValidator validate方法。
Below is my app.config. 以下是我的app.config。 Any advice would be greatly appreciated.
任何建议将不胜感激。
Thanks. 谢谢。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<!-- hidden -->
</connectionStrings>
<system.serviceModel>
<services>
<service name="ThisApp.Global.Service.ServiceImpl" behaviorConfiguration="serviceBehaviour">
<host>
<baseAddresses>
<add baseAddress="https://testapi.ThisApp.com" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="ThisApp.Global.Service.IServiceImpl" />
</service>
</services>
<!--WCF Service Binding Configurations-->
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True"/>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="ThisApp.Global.Service.Security.AuthorizationPolicy, ThisApp.Global.Service" />
</authorizationPolicies>
</serviceAuthorization>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ThisApp.Global.Service.Security.CustomUserNameValidator, ThisApp.Global.Service" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.diagnostics>
<trace autoflush="true" indentsize="2">
<listeners>
<add name="myListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="ThisApp Global API" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
You need to include transport in the binding security section, thus: 您需要在绑定安全性部分中包括传输,因此:
<binding name="TransportSecurity">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
<transport clientCredentialType="Basic" />
</security>
</binding>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.