【发布时间】:2013-01-09 18:55:28
【问题描述】:
我正在使用 .NET 4.5 中包含的 WIF 框架创建 STS。我正在使用 WSTrustServiceHost 类自行托管这个 STS(目前)。为了做到这一点,我正在做以下事情:
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();
// ...
如您所见,我将true 传递给SecurityTokenServiceConfiguration 构造函数的loadConfig 参数,文档中说:
true 从配置文件加载设置;否则 false。
我的配置文件中有一个identityConfiguration 元素,但它似乎没有被加载。我可以更改配置文件 f.e.我可以更改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?
【问题讨论】:
-
我撤回了我的回答,因为你不喜欢它,但无论如何都会尽力帮助你:Thinktecture 的东西只是你正在使用的东西的包装器,not需要编程配置。它具有广泛的基于文件的配置机制。
-
Thinktecture 的东西使用程序化配置。不管那个程序化配置是否由配置文件驱动,它仍然是程序化配置。我想使用内置的xml配置基础设施。
标签: c# wcf wif sts-securitytokenservice