我能够从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", …Run Code Online (Sandbox Code Playgroud) 我正在看几个使用ACS的例子,他们确实让我感到愚蠢.
我在网上查看了教程,似乎我需要的是配置中的以下行:
httpRuntime requestValidationMode="2.0"
Run Code Online (Sandbox Code Playgroud)
但是此示例项目 SimpleMVC4中的其他一些示例 在其配置中没有这样的行.更糟糕的是,我没有看到任何可能引用ACS库的内容.
另一方面,MVC3样本有一堆乱码,包括对javascript的ajax请求!?
public const string HrdPath = "v2/metadata/IdentityProviders.js";
/// <summary>
/// Gets the url with its query string representing this request
/// </summary>
/// <returns></returns>
public string GetUrlWithQueryString()
{
uriBuilder.Path = HrdPath;
uriBuilder.Query = parameters.ToQueryString();
return uriBuilder.Uri.AbsoluteUri;
}
Run Code Online (Sandbox Code Playgroud)
并在Raxor视图中
$("#signIn").click(function () {
//
// Explicit JSONP callback can be used to do client side caching of identity provider data.
//
$.ajax({
url: "@Html.Raw(Model.GetUrlWithQueryString())",
dataType: "jsonp",
Run Code Online (Sandbox Code Playgroud)
HUH !?
看,我可以得到一些简单的(白痴证明)指针吗?