【问题标题】:How to delegate Facebook SecurityToken to WCF service如何将 Facebook SecurityToken 委托给 WCF 服务
【发布时间】:2013-01-06 23:45:01
【问题描述】:

我有以下组件: WPF 应用程序, 身份服务器, WCF 网络服务,

WPF 应用程序使用 WebBrowser 控件通过使用 WS-Federation 的 Thintecture Identity Server 进行身份验证。 Identity Server 已启用 Home Realm Discovery 并允许使用 Facebook、Live ID 和 Google 进行身份验证。身份验证后,我收到 ReqquestSecurityTokenResponse 消息,我将其转换为 SecurityToken。

得到这个 SecurityToken 后,我想调用 WebService。我想我需要创建 Thintecture Identity Server 再次发布的 ActAsToken,但我无法配置它。

var serviceAddress = "http://localhost:7397/Service1.svc";
var token3 = token2.ToSecurityToken();
var binding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.Message);
binding.Security.Message.IssuedKeyType = System.IdentityModel.Tokens.SecurityKeyType.SymmetricKey;
binding.Security.Message.IssuerAddress = new EndpointAddress("https://dev3.example.com/Identity/issue/wsfed");
binding.Security.Message.IssuerBinding = new WS2007HttpBinding();
var factory = new ChannelFactory<IService1Channel>(binding,
    new EndpointAddress(
        new Uri(serviceAddress),
        new DnsEndpointIdentity("dev3.example.com")));
factory.Credentials.SupportInteractive = false;
var proxy = factory.CreateChannelWithActAsToken(token3);
{

    try
    {
        var output = proxy.GetData(1);
        MessageBox.Show(output);
        proxy.Dispose();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

但我得到了例外。

WebService 是使用 Identity and access... VS 扩展配置的。

这种情况可能吗?

【问题讨论】:

    标签: wcf .net-4.5 wif smartclient identity-delegation


    【解决方案1】:

    您不需要 ActAs - 您可以使用 CreateChannelWithIssuedToken 方法来创建您的 WCF 代理。

    您还需要在 WCF 服务和客户端上配置不记名密钥(而不是 SymmetricKey)。

    【讨论】:

    • 感谢您的提示。原型版本运行良好,现在我必须清理解决方案,任务完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多