3

.NET4.5に含まれているWIFフレームワークを使用してSTSを作成しています。私はこのSTSを(今のところ)WSTrustServiceHostクラスを使用してセルフホストしています。それをするために、私は次のことをしています:

var conf = new SecurityTokenServiceConfiguration("isser name here", true)
{
    DisableWsdl          = true,
    SecurityTokenService = typeof(MyTokenService),
};
var ct   = new WSTrustServiceContract(conf);
var host = new WSTrustServiceHost(ct);

host.Open();
// ...

ご覧のとおり、コンストラクターtrueloadConfigパラメーターを渡しています。これは、ドキュメントに記載されています。SecurityTokenServiceConfiguration

構成ファイルから設定をロードする場合はtrue 。それ以外の場合はfalse

構成ファイルにidentityConfiguration要素がありますが、ロードされていないようです。構成ファイルに変更を加えることができます。変更することができますがsecurityTokenHandlers、それらの変更は構築されたに反映されませんSecurityTokenServiceConfiguration

app.configファイルには、次のものがあります。

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="sts_behavior">
                <serviceCredentials useIdentityConfiguration="true" identityConfiguration="the_issuer_id">
                    <serviceCertificate findValue="7A5D7EB05EC741E45BF4EDA7E574F58DC31EF290" x509FindType="FindByThumbprint" storeName="My" storeLocation="LocalMachine" />
                </serviceCredentials>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <ws2007HttpBinding>
            <binding name="sts_binding">
                <security mode="Message">
                    <message clientCredentialType="UserName" />
                </security>
            </binding>
        </ws2007HttpBinding>
    </bindings>
    <services>
        <service name="System.ServiceModel.Security.WSTrustServiceContract" behaviorConfiguration="sts_behavior">
            <endpoint address="http://my-machine:54512/tokens" binding="ws2007HttpBinding" contract="System.ServiceModel.Security.IWSTrust13SyncContract" bindingConfiguration="sts_binding" />
        </service>
    </services>
</system.serviceModel>

ご覧のとおり、この要素は構成ファイルに存在する<serviceCredentials>要素を参照しており、<identityConfiguration>この名前をその要素と一致しないように変更すると<identityConfiguration>、サービスホストを開いたときにエラーがスローされます。ただし、セキュリティトークンハンドラーを使用できるため、この<identityConfiguration>要素はまだ使用されていません。また、リクエストが着信したときにトークンハンドラーが引き続き使用されます。<clear/>

最小限のプログラム構成でカスタムSTSを構成し、セルフホストするにはどうすればよいですか?

4

1 に答える 1

2

多くの調査の後、コンストラクターのオーバーロードの1 つを使用すると、構成の読み込み元の要素SecurityTokenServiceConfigurationの名前を指定できることがわかりました。<identityConfiguration>

//
// Summary:
//     Initializes a new instance of the System.IdentityModel.Configuration.SecurityTokenServiceConfiguration
//     class that has the specified issuer name and signing credentials. Settings
//     are loaded from the specified named configuration.
//
// Parameters:
//   issuerName:
//     The issuer name. Sets the System.IdentityModel.Configuration.SecurityTokenServiceConfiguration.TokenIssuerName
//     property.
//
//   signingCredentials:
//     The signing credentials for the STS. Sets the System.IdentityModel.Configuration.SecurityTokenServiceConfiguration.SigningCredentials
//     property.
//
//   serviceName:
//     The name of the <identityConfiguration> element from which the configuration
//     is to be loaded.
public SecurityTokenServiceConfiguration(string issuerName, SigningCredentials signingCredentials, string serviceName);
于 2013-01-28T17:43:50.210 に答える