2013-06-05 5 views
5

मैं एसीएस में कॉन्फ़िगर किए गए विभिन्न पहचान प्रदाताओं से सुरक्षा टोकन (एसडब्ल्यूटी) को पुनर्प्राप्त करने में सक्षम था। अब मैं होना चाहिए - उदाहरण के अनुसार - यह ऐसा करने में सक्षम:एसएएमएल दावे के माध्यम से एसीएस से एक्सेस टोकन कैसे प्राप्त करें?

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(); 
} 

एक अर्थ यह उदाहरण के लिए एक गैर-मौजूद endpoint के लिए विफल रहता है में काम करता है। तो सेवा है (सुरक्षित), सर्वर पक्ष पर टोकन मॉड्यूल और टोकन सत्यापनकर्ता कहा जाता है, और टोकन गुजरता है। तो यह नहीं है। लेकिन फिर भी समस्या यह है कि प्रतिक्रिया में लॉगिन पृष्ठ का 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", 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> 
+0

हम माइक्रोसॉफ्ट समर्थन के साथ इसका समाधान कर लिया है, यह तथ्य की वजह से किया गया था, सेवा निष्क्रिय महासंघ से परे था, और इस प्रक्रिया स्पष्ट रूप से पसंद नहीं है। मैंने इसे SAML2 दावे टोकन के लिए लिफाफा बनाकर हल किया है, इस तरह यह "अनुकरण" ब्राउज़र गतिविधि है, और यह अच्छी तरह से काम करता है और निष्क्रिय संघ (डब्ल्यूएस-ट्रस्ट लिफाफे के कारण) के साथ भी अच्छी तरह से खेलता है। – SmartK8

+0

यहां एक और जवाब है जो दिखाता है कि पेलोड http://stackoverflow.com/a/17174563/31299 – Josh

+0

हाँ जैसा दिखना चाहिए, लेकिन मेरा प्रारूप सही था। जैसा कि मैंने कहा है कि मेरी समस्या यह थी कि यह निष्क्रिय संघ के पीछे थी। इसे पहले पास करने की आवश्यकता थी और फिर यह एसीएस से जुड़ा हुआ था। यह सब हल हो गया है और ठीक काम कर रहा है। – SmartK8

उत्तर

0

जैसा कि ऊपर बताया:

We've solved it with Microsoft Support, it was caused by the fact, the service was behind passive federation, and the process doesn't like obviously. I've solved it by creating a <RequestSecurityToken> envelope for the SAML2 assertion token, this way it "simulated" browser activity, and it works well and also plays well with passive federation (due to WS-TRUST envelope).

It needed to pass it first and then it connected to ACS.The problem wasn't in access token or SAML assertion at all. It was caused - as I've pointed out - by the fact that part of website was behind the custom STS federation. The WS Federation module was blocking reception of this token. When I enveloped it in RequestSecurityToken for WS Federation to chew on first. It then passed to ACS as presented in my question.

संबंधित मुद्दे

 संबंधित मुद्दे