从Silverlight访问索赔感知WCF

从Silverlight访问索赔感知WCF,silverlight,wcf,azure,claims-based-identity,Silverlight,Wcf,Azure,Claims Based Identity,我正在开发一个连接到claim ware WCF服务的Silverlight 4应用程序。我正在使用以下代码检索WCF中的索赔令牌以执行授权 IClaimsPrincipal principal = ( IClaimsPrincipal )Thread.CurrentPrincipal; IClaimsIdentity identity = ( IClaimsIdentity )principal.Identity; return string.Format( "You entered:

我正在开发一个连接到claim ware WCF服务的Silverlight 4应用程序。我正在使用以下代码检索WCF中的索赔令牌以执行授权

IClaimsPrincipal principal = ( IClaimsPrincipal )Thread.CurrentPrincipal;   
IClaimsIdentity identity = ( IClaimsIdentity )principal.Identity;
return string.Format( "You entered: {0} and you are {1}", value, identity.Name );
当我在WCF中使用wsHttpBinding并在控制台应用程序中试用时,效果很好。但由于Silverlight只支持Basichtp和customeBinding,所以我不能使用wsHttp、ws2007Http或任何其他绑定。因此,我没有从Silverlight获得WCF中的IClaimIdentity令牌

是否有任何方法我可以使用任何Silverlight支持的绑定,并且仍然可以在我的WCF中获得Claimienty。是否有任何教程/帮助文本,我可以阅读更多关于这方面的内容

我的WCF设置是:

<system.serviceModel>
    <services>
      <service name="ClainAwareWCF.Service" behaviorConfiguration="ClainAwareWCF.ServiceBehavior">
        <endpoint address="" binding="basicHttpBinding" contract="ClainAwareWCF.IService" bindingConfiguration="basicbind">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicbind">
          <security mode="TransportCredentialOnly"></security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ClainAwareWCF.ServiceBehavior" > 
          <federatedServiceHostConfiguration/>
          <serviceMetadata  httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>      
      <behaviorExtensions>
        <add name="federatedServiceHostConfiguration" type="Microsoft.IdentityModel.Configuration.ConfigureServiceHostBehaviorExtensionElement, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </behaviorExtensions>
    </extensions>
  </system.serviceModel>

由于绑定问题以及SL(Windows/Forms/WIF/etc)的客户端身份验证感知安全性,尝试直接从客户端调用此操作将永远不会发生,但是,一种方法是使用RIA服务域身份验证服务通过WCF RIA调用端点从服务器端对服务进行身份验证和调用。用户的安全上下文被代理给客户端,您可以直接通过网络传输数据

这可能会让你走上正确的方向:


Silverlight不支持基于声明的授权和现成的WS-Trust。微软本打算将此应用到Silverlight 5中,但不幸的是忘记了这么做

然而,在身份培训工具包中有一个非常优雅且可用的WIF IdentityModel“Silverlight”版本

该解决方案包括一个将WIF身份验证令牌转换到索赔服务器端的基本AuthenticationService,以及一个Silverlight客户端库“SL.IdentityModel”,其中包含构建块,如ClaimsPrincipal的Silverlight版本

获取身份培训包。查找示例Silverlight实现