私は、ACSで設定されているさまざまなIDプロバイダからセキュリティトークン(SWT)を取得、復号化できました。例によってこれを行うことができます:SAMLアサーション経由でACSからアクセストークンを取得するにはどうすればよいですか?
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();
}
たとえば、存在しないエンドポイントでは失敗します。したがって、サービスはそこにあり(セキュア)、サーバー側のトークン・モジュールとトークン・バリデーターが呼び出され、トークンが通過します。そうではありません。しかし、とにかく問題は、レスポンスにログインページのHTMLが含まれていることです(その中にアイデンティティプロバイダのリストを持つもの)。あたかもトークンの検証がOKだったかのように見えますが、それでもセキュリティは十分ではありません。
サービスからデータを受信するにはどうしたらよいですか?何かヒント?
シナリオ:http://tinyurl.com/WcfRestSaml
更新:私は私が達成しようとしているシナリオの画像へのリンクを含めました。
更新2:OK、私は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);
これはまた別のエラーにもかかわらず、返す:
Error:Code:401:SubCode:T0:Detail:ACS50008: SAML token is invalid.: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>
私たちは、マイクロソフトのサポートでそれを解決してきた、それは事実によって引き起こされた、サービスはパッシブフェデレーションを超えていた、そしてプロセスは明らかに好きではありません。私はSAML2アサーショントークンのエンベロープを作成することで解決しました。これはブラウザアクティビティを「シミュレート」し、うまく動作し、受動的なフェデレーション(WS-TRUSTエンベロープのため)でうまくいきます。 –
SmartK8
ペイロードの外観を示す別の回答があります。http://stackoverflow.com/a/17174563/31299 – Josh
ええ、フォーマットは正しいです。私の問題はパッシブ・フェデレーションの背後にあると言いました。それを最初に渡す必要があり、次にACSに接続しました。それはすべて解決され、現在は正常に動作しています。 – SmartK8