Single sign on 使用OAuth+SAML承载流进行身份验证(无效断言)
我正在尝试使用OAuth+SAML承载流进行身份验证http://help.salesforce.com/help/doc/en/remoteaccess_oauth_SAML_bearer_flow.htm 但是我被困在了一个点上,我得到了无效的断言错误:Single sign on 使用OAuth+SAML承载流进行身份验证(无效断言),single-sign-on,saml,Single Sign On,Saml,我正在尝试使用OAuth+SAML承载流进行身份验证http://help.salesforce.com/help/doc/en/remoteaccess_oauth_SAML_bearer_flow.htm 但是我被困在了一个点上,我得到了无效的断言错误: {"error":"invalid_grant","error_description":"invalid assertion"} 以下是我的主张: <?xml version="1.0"?> <saml:Asser
{"error":"invalid_grant","error_description":"invalid assertion"}
以下是我的主张:
<?xml version="1.0"?>
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="C625490D-C2B9-15BE-6DFA-7286288D9655" IssueInstant="2012-04-04T06:54:14Z" Version="2.0">
<saml:Issuer>3MVG9Y6d_Btp4.....d0jnN</saml: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/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#C625490D-C2B9-15BE-6DFA-7286288D9655">
<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/2000/09/xmldsig#sha1"/>
<ds:DigestValue>f187DeCiwFhhH2etlU+5byskey4=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
MIID6zCCAtOgAwI...........4qbvd3sxAQmkhR98FSsQixMI+bTHq9zRgeFu6W5GWsun3tmqNE=
</ds:SignatureValue>
</ds:Signature>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">org2@dot.com
</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData Recipient="https://login.salesforce.com/services/oauth2/token" NotOnOrAfter="2012-11-20T06:35:42Z"/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2012-11-19T06:34:42Z" NotOnOrAfter="2012-11-20T06:35:42Z">
<saml:AudienceRestriction>
<saml:Audience>https://login.salesforce.com/services/oauth2/token</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2012-11-20T06:35:42Z" SessionIndex="ED868FE5-841D-5192-766C-941A60D6602F">
<saml:AuthnContext>
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
</saml:Assertion>
我已经将断言正确地编码到base64url,之前我在断言中遇到了关于无效字符的错误,我已经修复了这个错误
请告知我可以进一步检查的内容/位置,以了解我的断言无效的原因!
PS:所有内容都是从上面url的示例断言中复制的,用户名、颁发者和证书都由我更改。此外,我还将NotBefore设置为用户的准确登录时间。发送时,还需要对授权类型值进行编码。 urn%3 IETF%3参数%3 OAuth%3授权类型%3 SAML2承载 Saml断言需要是单个断言。它需要像您那样进行Base64编码,然后再次删除填充或urlencode 断言参数的值必须包含单个SAML 2.0 断言。SAML断言XML数据必须使用 base64url,其中编码遵循第5节中的定义 RFC 4648[RFC4648]的,其中填充位设置为零。到 避免按应用程序执行后续编码步骤/ x-www-form-urlencoded[W3C.REC-html401-19991224],例如 base64url编码的数据不应为换行字符和填充字符 =不应包括在内 使用后编码值发送: 授权类型=urn%3AETF%3Params%3OAuth%3授权类型%3SAML2承载&
assertion=PHNhbWxwOl…[省略]…ZT4您是否能够解决此问题?我现在面临着同样的问题,这篇文章已经发表了将近一年了。我认为这不会奏效。urlencoding grant_类型引发grant type not SUPPORED错误。
curl https://login.salesforce.com/services/oauth2/token -H "Content-Type='application/x-www-form-urlencoded'" -d "grant_type=urn:ietf:params:oauth:grant-type:saml2-bearer" -d "assertion=`cat saml-assertion.base64`"