我在主題行中提到的設置上苦苦掙扎,並且想知道是否有人可以幫助我。在WCF中處理REST SWT令牌WIF管道無法正常工作
本質上,我所擁有的是一個WCF服務,並且我想實現用戶可以使用自定義登錄頁面(使用JavaScript和ACS提供的所需信息使用JavaScript)對ACS進行身份驗證。
這樣做後,用戶應該使用提供的SWT令牌重定向到WCF服務。我使用SimpleWebTokenHandler作爲SWT令牌處理的基礎,但我不確定它在這方面發揮了什麼作用。
這裏是我跑
<configuration>
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral" />
</configSections>
...
<system.serviceModel>
<diagnostics>
</diagnostics>
<services>
<service name="WcfWifSwtAcs.Service1">
<endpoint address="xmlService" binding="webHttpBinding" bindingConfiguration="" behaviorConfiguration="restPoxBehaviour" name="xmlServiceEndpoint" contract="WcfWifSwtAcs.IService1" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restPoxBehaviour">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials useIdentityConfiguration="true">
...
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add scheme="http" binding="ws2007FederationHttpBinding" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<ws2007FederationHttpBinding>
<binding name="">
<security mode="Message">
<message
issuedTokenType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0">
<issuerMetadata address="https://xxxx.accesscontrol.windows.net/v2/wstrust/13/certificate/mex" />
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
...
</system.webServer>
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://localhost:56782/Service1.svc" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add thumbprint="XXX" name="xxx.accesscontrol.windows.net" />
</trustedIssuers>
</issuerNameRegistry>
<issuerTokenResolver type="SimpleWebToken.CustomIssuerTokenResolver, WcfWifSwtAcs" />
<securityTokenHandlers>
<clear/>
<add type="SimpleWebToken.SimpleWebTokenHandler, WcfWifSwtAcs"/>
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
</configuration>
現在我可以看到的Web.config,該認證是和瀏覽器重定向與人體的服務。我還可以看到SimpleWebToken處理程序得到了實例化,並且正在請求標記類型URI。但幾乎所有這一切都發生了。沒有實際的令牌處理驗證以及任何令人滿意的操作。
這是獲取發送到服務(解析後)的令牌。
wa=wsignin1.0&
wresult=
<t:RequestSecurityTokenResponse
xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<t:Lifetime>
<wsu:Created
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-02-13T23:14:30.159Z</wsu:Created>
<wsu:Expires
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-02-13T23:24:30.159Z</wsu:Expires>
</t:Lifetime>
<wsp:AppliesTo
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<EndpointReference
xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://localhost:56782/Service1.svc</Address>
</EndpointReference>
</wsp:AppliesTo>
<t:RequestedSecurityToken>
<wsse:BinarySecurityToken
wsu:Id="uuid:58e2fb15-dd1a-40bd-8ff0-ae24e22e6efe"
ValueType="http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0"
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
BASE64 DATA==
</wsse:BinarySecurityToken>
</t:RequestedSecurityToken>
<t:TokenType>http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
</t:RequestSecurityTokenResponse>
服務本身是braindead簡單,具有以下簽名。
[OperationContract]
[WebInvoke(UriTemplate = "/GetData/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetData(string id);
任何想法?我一直在驗證uri的主機名,拇指指紋等都是有效的。此外,服務跟蹤不會真正顯示與令牌處理或令牌驗證中的例外相關的任何內容。
不知何故,它似乎並沒有傳遞給處理程序。至少所有索賠和其他身份驗證信息都丟失(空)。
如果有人指出我可以在哪裏調試,或者如果我錯過了一些非常明顯的東西(這也可能總是如此),我將不勝感激。
P.S.我知道我可以通過自定義身份驗證模塊來實現它,無論如何,我寧願讓它與WIF一起運行(因爲我已經花了更多時間在這個上,因爲我真的很想,而且我非常固執:p)。
你從哪裏得到你正在使用的SimpleWebTokenHandler?請記住,當ACS通過XML協議(如WS-Trust)發佈SWT時,它將它包裝在元素中,您使用的令牌處理程序必須理解該元素。如果我不得不猜測,你使用的處理程序不會將其識別爲SWT。 –
2013-02-14 01:30:38
嗨,我一直在使用從這裏http://code.msdn.microsoft的示例。com/vstudio/Custom-Token-ddce2f55 現在有趣的部分是,實際用於比較令牌內容和令牌處理程序返回的內容的URI是什麼。 t:TokenType和ValueType都會讓我認爲它是我使用的http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0。 我一直無法獲得任何標記相關的跟蹤或調試都沒有:( – Laazik 2013-02-14 09:13:10