簡體   English   中英

Azure ACS憑據混淆

[英]Azure ACS Credential Confusion

我下載了這個項目的源代碼http://code.msdn.microsoft.com/windowsazure/MVC4-Web-API-With-SWT-232d69da#content,因為我試圖了解ACS身份驗證以及如何在我的MVC中應用它Web API。

代碼有這個:

// 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";

USERNAME和PASSWORD要求我使用什么? 它是否要我創建“服務標識”並使用“密碼”選項?

您需要閱讀以下相關文章: 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令牌的步驟。 您在完成“為REST Web服務配置服務標識”部分時輸入的信息就在這里。

如果您使用對稱密鑰作為密碼,則需要客戶端以與示例不同的方式從ACS請求令牌。 以下代碼是該請求的示例,它來自http://msdn.microsoft.com/en-us/library/hh674475.aspx 請參閱“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