18

我试图了解 WIF 中主动和被动联合之间的区别。如果依赖方 (RP) 是 WCF 服务而不是 ASP.NET 应用程序,则似乎可以使用主动联合;如果 RP 是 ASP.NET 应用程序,则使用被动联合。这是准确的吗?

因此,在 ASP.NET 应用程序在后端使用 WCF 的情况下,MS 文章建议使用由 ASP.NET 应用程序使用 ActAs STS 获取的“引导”安全令牌,该令牌用于身份验证与 WCF。在这种情况下,我们似乎正在组合 Active (user -> STS -> ASP.NET RP) 和 Passive (ASP.NET -> ActAs STS -> WCF) 联合?

4

4 回答 4

21

主动联合是关于使用 WSTrust 协议对用户进行身份验证,而您的依赖方是拥有登录窗口并向 STS 请求安全令牌的人。被动联合是指依赖方没有登录逻辑并且您被重定向到位于 STS 上的登录页面。在我看来,Active Federation 的配置更复杂(我正在使用 silverlight,所以它需要一些技巧)。我打算在我的博客上发布关于这个主题的帖子,因为互联网上关于它的信息很少。

于 2010-05-07T09:42:15.980 回答
2

简而言之,Passive Federation 只是一个短语,用于表示您的浏览器被重定向到 STS 托管的登录页面的场景。登录后,STS 将您重定向回带有一些 cookie 或其他内容的引用 URL,并且您在信任 STS 的站点上进行了身份验证(使用指纹、证书、加密等)。

你也不必那样做。例如,我喜欢我的 ASP.NET 站点使用用户提供的凭据主动联系 STS,但这意味着 ASP.NET 应用程序池必须使用 Windows Auth 在 STS 进行身份验证,以便将用户提供的凭据发送到获取一个令牌,然后我将令牌显式添加到会话中。换句话说,我没有使用被动联邦,但这只是一种选择。

于 2012-03-17T23:18:32.937 回答
1

您可以在此处阅读有关被动声明的更多信息:

http://garymcallisteronline.blogspot.co.uk/2012/11/claims-explained.html

主动调用是对 WSActive 端点的直接调用(它们支持多种身份验证类型)。以下代码显示了使用用户名活动端点的主动调用。

    private static GenericXmlSecurityToken GetToken(string username, string password, string url, string audienceUrl)
    {
        var factory = new WSTrustChannelFactory(new Microsoft.IdentityModel.Protocols.WSTrust.Bindings.UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), new EndpointAddress(url));
        factory.Credentials.UserName.UserName = username;
        factory.Credentials.UserName.Password = password;

        factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
        factory.TrustVersion = TrustVersion.WSTrust13;
        WSTrustChannel channel = null;

        var rst = new RequestSecurityToken
        {
            RequestType = WSTrust13Constants.RequestTypes.Issue,
            AppliesTo = new EndpointAddress(audienceUrl),
            KeyType = WSTrust13Constants.KeyTypes.Bearer,
        };
        channel = (WSTrustChannel)factory.CreateChannel();
        return channel.Issue(rst) as GenericXmlSecurityToken;
    }
于 2013-05-31T12:18:23.520 回答
0

即使我最初也有同样的问题,但这个博客对我帮助很大。

我建议您先浏览示例,然后再分析文档。

不过,WCF 联盟很棘手。

于 2015-05-12T12:08:01.400 回答