1

web.config を介して構成したい次の (削減された) コードがあります。

var security = new TransportSecurityBindingElement();
security.EndpointSupportingTokenParameters.SignedEncrypted.Add(new UserNameSecurityTokenParameters());

var binding = new CustomBinding(security);

Web 構成を使用してこのカスタム バインドを構成することは可能ですか? 可能であれば、トークン パラメータをサポートするエンドポイントをどのように構成できますか? 次の構成を試しましたが、DotNetConfig.xsd に対して検証されません。

<system.serviceModel>
  <bindings>
    <customBinding>
      <binding name="SomeBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
        <transportSecurity> <!-- Fails validation -->
            <!-- How do I configure the EndpointSupportingTokenParameters -->             
        </transportSecurity>
      </binding>
    </customBinding>
  </bindings>
  <client>
    ...
  </client>
</system.serviceModel>
4

1 に答える 1

0

customBinding/securityおそらくauthenticationModeofを使用するだけだと思いますUserNameOverTransport

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding>
          <security authenticationMode="UserNameOverTransport" />
        </binding>
      </customBinding>
    </bindings>
</system.serviceModel>

それができない場合は、次の場所に手動でトークンを追加してみてくださいissuedTokenParameters:

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding>
          <security authenticationMode="UserNameOverTransport">
              <issuedTokenParameters tokenType="http://schemas.microsoft.com/ws/2006/05/identitymodel/tokens/UserName" />
          </security>
        </binding>
      </customBinding>
    </bindings>
</system.serviceModel>

(から盗まれた tokenType UserNameSecurityTokenParameters)

正直なところ、おそらくコードで行う方が簡単なほど面倒です。環境ごとに異なる必要がある場合は、構成でファクトリを定義し、DI を使用してそれを使用してバインディングを作成します。

于 2012-09-18T02:21:13.033 に答える