如何通过SAML断言从ACS获取访问令牌?

Sma*_*tK8 5 wcf token saml assertion acs

我能够从ACS中配置的各种身份提供程序中检索,解码安全令牌(SWT).现在我应该 - 根据例子 - 能够做到这一点:

String headerValue = string.Format("WRAP access_token=\"{0}\"", securityToken);

WebClient client = new WebClient();
client.Headers.Add("Authorization", headerValue);

using (Stream stream = client.OpenRead(@"http://xxx.cloudapp.net/xxx.svc/users"))
using (StreamReader reader = new StreamReader(stream))
{
    String response = reader.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud)

从某种意义上说,它适用于不存在的端点,例如.因此服务在那里(安全),服务器端的令牌模块和令牌验证器被调用,并且令牌通过.所以不是那样的.但无论如何问题是响应包含登录页面的HTML(其中包含身份提供者列表).看起来好像令牌验证没问题,但仍然不够安全.

我现在该怎么做才能从服务中接收我的数据?任何提示?

场景:http://tinyurl.com/WcfRestSaml

更新:我已经包含了我想要实现的场景图片的链接.

更新2:好的,我已切换到Saml2,但发生了同样的错误.然后我发现我需要断言来接收访问令牌.所以我做了:

WebClient client = new WebClient { BaseAddress = string.Format("https://{namespace}.accesscontrol.windows.net") };
NameValueCollection parameters = new NameValueCollection
{
    { "wrap_assertion_format", "SAML" },
    { "wrap_assertion", securityToken },
    { "wrap_scope", "http://{our}.cloudapp.net/" }
};

Byte[] responseBytes = client.UploadValues("WRAPv0.9", parameters);
String response = Encoding.UTF8.GetString(responseBytes);
Run Code Online (Sandbox Code Playgroud)

这也会返回另一个错误:

错误:代码:401:SubCode:T0:详细信息:ACS50008:SAML令牌无效.:TraceID:1d3774fa-a5e6-3e3b-a5e5-5a0bde6e0771:TimeStamp:2013-06-06 16:18:05Z

但似乎这应该返回我想要的访问令牌.

更新3:没有任何帮助,无处收集信息,该死的.我在盲目的机会上发布了一个完整的令牌,至少有人会注意到一些错误(我已经删除了敏感的信息).

<Assertion ID="_541a71ba-1e00-478c-8d2b-0beac3a35d35" IssueInstant="2013-06-07T11:38:31.741Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
  <Issuer>https://{removed}.accesscontrol.windows.net/</Issuer>
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
      <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
      <ds:Reference URI="#_541a71ba-1e00-478c-8d2b-0beac3a35d35">
        <ds:Transforms>
          <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
        <ds:DigestValue>{removed}</ds:DigestValue>
      </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue>{removed}</ds:SignatureValue>
    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <X509Data>
        <X509Certificate>{removed}</X509Certificate>
      </X509Data>
    </KeyInfo>
  </ds:Signature>
  <Subject>
    <NameID>https://www.google.com/accounts/o8/id?id={removed}</NameID>
    <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer" />
  </Subject>
  <Conditions NotBefore="2013-06-07T11:38:31.694Z" NotOnOrAfter="2013-06-07T12:38:31.694Z">
    <AudienceRestriction>
      <Audience>http://{removed}.cloudapp.net/</Audience>
    </AudienceRestriction>
  </Conditions>
  <AttributeStatement>
    <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
      <AttributeValue>{removed}</AttributeValue>
      <AttributeValue>https://www.google.com/accounts/o8/id?id={removed}</AttributeValue>
      <AttributeValue>{removed}</AttributeValue>
    </Attribute>
    <Attribute Name="http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider">
      <AttributeValue>Google</AttributeValue>
    </Attribute>
  </AttributeStatement>
</Assertion>
Run Code Online (Sandbox Code Playgroud)

Pau*_*tte 0

如上所述:

我们已经通过 Microsoft 支持解决了这个问题,这是由于该服务位于被动联合之后,并且该过程明显不喜欢造成的。我通过为 SAML2 断言令牌创建一个信封解决了这个问题<RequestSecurityToken>,这样它就可以“模拟”浏览器活动,并且它可以很好地工作,并且可以很好地与被动联合配合(由于 WS-TRUST 信封)。

它需要先通过它,然后连接到 ACS。问题根本不在于访问令牌或 SAML 断言。正如我所指出的,这是由于网站的一部分是自定义 STS 联盟背后的事实造成的。WS 联合模块阻止接收此令牌。当我将其封装在 RequestSecurityToken 中供 WS Federation 首先咀嚼时。然后按照我的问题中所述将其传递给 ACS。