我正在使用透明代理,是否可能将声明标识传递到另一个WebAPI?
我有两个WebAPI,一个是演示API,一个是应用API,它们都使用ADFS进行身份验证。
到目前为止,我的代码已经处理了演示API请求到应用API的过程。
//Obtain ClaimsIdentity (Contains claims)
ClaimsPrincipal icp = Thread.CurrentPrincipal as ClaimsPrincipal;
ClaimsIdentity claimsIdentity = (ClaimsIdentity)icp.Identity;
var baseAddress = ConfigurationManager.AppSettings["ApplicationalWebApiUrl"] + "/" + url;
var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
http.Accept = "application/json; charset=utf-8";
http.ContentType = "application/json; charset=utf-8";
http.Method = "GET";
//Doesn't pass the ClaimsIdentity
http.UseDefaultCredentials = true;
try
{
//Get the requested data
var response = http.GetResponse();
var stream = response.GetResponseStream();
var sr = new StreamReader(stream);
var contentResponse = sr.ReadToEnd();
return Request.CreateResponse(JsonConvert.DeserializeObject<Object>(contentResponse));
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
}