简体   繁体   English

Azure ACS凭据混淆

[英]Azure ACS Credential Confusion

I downloaded the source for this project http://code.msdn.microsoft.com/windowsazure/MVC4-Web-API-With-SWT-232d69da#content because I am trying to understand ACS authentication and how to apply it in my MVC Web API. 我下载了这个项目的源代码http://code.msdn.microsoft.com/windowsazure/MVC4-Web-API-With-SWT-232d69da#content,因为我试图了解ACS身份验证以及如何在我的MVC中应用它Web API。

The code has this: 代码有这个:

// USE CONFIGURATION FILE, WEB.CONFIG, TO MANAGE THIS DATA
static string serviceNamespace = "<YOUR SERVICE NAMESPACE>";
static string acsHostUrl = "accesscontrol.windows.net";
static string realm = "<REALM>";
static string uid = "USERNAME";
static string pwd = "PASSWORD";
static string serviceUrl = "http://localhost:51388/api";
static string serviceAction = @"/values";

What USERNAME and PASSWORD is it requesting that I use? USERNAME和PASSWORD要求我使用什么? Does it want me to create a "Service Identity" and use the "password" option? 它是否要我创建“服务标识”并使用“密码”选项?

You need to read the associated article found at: http://blogs.msdn.com/b/alikl/archive/2011/06/05/how-to-request-swt-token-from-acs-and-how-to-validate-it-at-the-rest-wcf-service-hosted-in-windows-azure.aspx follow the steps to Configure ACS to Issue a SWT Token. 您需要阅读以下相关文章: http//blogs.msdn.com/b/alikl/archive/2011/06/05/how-to-request-swt-token-from-acs-and-how- to-validate-it-at-rest-wcf-service-hosted-in-windows-azure.aspx遵循配置ACS以发出SWT令牌的步骤。 The information you enter when completing the section "To configure a service identity for the REST web service" is what goes here. 您在完成“为REST Web服务配置服务标识”部分时输入的信息就在这里。

If you are using a Symmetric key for your password then you need the client to request a token from ACS in a different way than the example. 如果您使用对称密钥作为密码,则需要客户端以与示例不同的方式从ACS请求令牌。 The following code is an example of what that request looks like and was taken from http://msdn.microsoft.com/en-us/library/hh674475.aspx . 以下代码是该请求的示例,它来自http://msdn.microsoft.com/en-us/library/hh674475.aspx See the section "SWT token requests". 请参阅“SWT令牌请求”部分。

WebClient client = new WebClient();
client.BaseAddress = string.Format("https://mysnservice.accesscontrol.windows.net");

NameValueCollection values = new NameValueCollection();
// add the wrap_scope
values.Add("wrap_scope", "http://mysnservice.com/services");
// add the format
values.Add("wrap_assertion_format", "SWT");
// add the SWT
values.Add("wrap_assertion", "Issuer=mysncustomer1&HMACSHA256=b%2f%2bJFwbngGdufECFjQb8qhb9YH0e32Cf9ABMDZFiPPA%3d");
// WebClient takes care of the remaining URL Encoding
byte[] responseBytes = client.UploadValues("WRAPv0.9", "POST", values);

// the raw response from ACS
string response = Encoding.UTF8.GetString(responseBytes);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM