回答:
我发现在WindowsIdentityFoundation-SDK-4.0中的联合实用工具工具将其完成。您可以在http://www.microsoft.com/en-ca/download/details.aspx?id=4451上下载该工具。
实际上URL是
https://server/federationmetadata/2007-06/federationmetadata.xml
据我所知,目前没有可用的工具。
您可以使用Microsoft.IdentityModel.Protocols.WSFederation.Metadata类或参考动态生成联合元数据。
请查看Thinktecture.IdentityServer.v2中的“Thinktecture.IdentityServer.v2/src/Libraries/Thinktecture.IdentityServer.Protocols/FederationMetadata”。
或者,如果您的应用程序使用WIF,则在元数据目录中可以找到它。
更新:
在WIF中,除非您希望令牌被加密,否则您不需要证书。这更多是为了ADFS方面签署令牌和应用程序需要公钥进行验证。
示例:
<?xml version="1.0" encoding="utf-8"?>
<EntityDescriptor ID="_5b6cd05c-a5e3-470d-a2fc-6c6f66633d1b" entityID="http://localhost/app/" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
<RoleDescriptor xsi:type="fed:ApplicationServiceType" xmlns:fed="http://docs.oasis-open.org/wsfed/federation/200706" protocolSupportEnumeration="http://docs.oasis-open.org/wsfed/federation/200706" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fed:ClaimTypesRequested>
<auth:ClaimType Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" Optional="true" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" />
<auth:ClaimType Uri="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" Optional="true" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706" />
</fed:ClaimTypesRequested>
<fed:TargetScopes>
<EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://localhost/app/</Address>
</EndpointReference>
</fed:TargetScopes>
<fed:PassiveRequestorEndpoint>
<EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://localhost/app/</Address>
</EndpointReference>
</fed:PassiveRequestorEndpoint>
</RoleDescriptor>
</EntityDescriptor>
localhost\app\ 需替换为您的应用程序的URL。注意末尾斜杠!
最近我不得不这样做,以前从未使用过.Net或ADFS,只有我正在尝试集成的服务器(STS)元数据URL。我有一台基本的Windows 10 PC,并且正在尝试设置一个Node.js webapp作为RP。这是我所做的:
在Win 10 PC上,打开控制面板->程序和功能->打开或关闭Windows功能->启用Windows Identity Foundation 3.5
安装了Windows Identity Foundation SDK 4.0(正如原作者所提到的)。
创建了一个包含以下内容的基本Web.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
</system.web>
</configuration>
在SDK安装目录中,我找到了FedUtil.exe和FedUtilSampleUserInput.xml。示例文件解释了所有FedUtil.exe将要询问的参数,这非常有帮助。
以管理员身份启动FedUtil.exe(在文件资源管理器中右键单击),提供刚创建的Web.config文件、webapp URL、作为“现有STS”的服务器(STS)元数据URL,并选择创建一个新的默认证书。
看啊,生成了一个FederationMetadata.xml文件,并自动更新了我的Web.config文件。
然后我取消了更新后Web.config文件中的一些声明类型并重新运行了FedUtil.exe,然后从STS获取了我需要的其他声明类型(例如:电子邮件、名字、姓氏),并将它们添加到了FederationMetadata.xml中。
将FederationMetadata.xml提供给了STS管理员,终于成功了!
唯一的缺点是这需要一个Windows机器……我不确定如果在Mac或Linux上会怎么做!
创建“重放方信任”的元数据 XML 不是 ADFS 联合元数据,而是 SP(Saml 发行者)的元数据 XML。