私は解決策を探していましたが、見つけられませんでした。ここで私が実行したいシナリオだWSO2からOAuthトークンを取得するためにPHPでSAML2トークンを取得する方法APIM
- https://docs.wso2.com/display/AM200/Exchanging+SAML2+Bearer+Tokens+with+OAuth2+-+SAML+Extension+Grant+Type
- https://github.com/simplesamlphp/simplesamlphp/issues/220
:
この質問
は直接に関係している- はSAML2を使用してSPへの認証します。 SimpleSamlPhpでPHPでコード化されています。
- SAML2アサーションを使用して、API mgrエンドポイントからOAuthトークンを取得します。 (URL http://api.gateway/tokenを使用)
- OAuthトークンを使用してAPI mgrのゲートウェイ経由でAPIを呼び出します。
私は命令で立ち往生しています:SAML2アサーショントークンを取得します。 このトークンはどこにありますか? SimpleSamlPhpでは、ユーザーの属性またはIDを取得できますが、アサーションは見つかりません。
最後のアサーションを取得するためにSSPをハッキングしましたが、その処理方法がわかりません。私は単一の値(トークンのような)を期待していましたが、それは複雑な構造です。上のリンクの1つに、私はそれにアクセスすべきではないと言います!
トークンURLに何をエンコードして送信しますか?
EDIT:いくつかのサンプルを追加します。 マイアサートXMLは、(編集済み):
<?xml version="1.0" encoding="UTF-8"?>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" ID="okdjgbm...jdbh" IssueInstant="2016-11-28T09:49:45.808Z" Version="2.0">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://g...p.com:9443/samlsso</saml2: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="#okd...kejdbh">
<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>RrGcR...cktFuH0=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>b91j/k...Z7d4=</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIICNT...Wq8uHSCo=</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">[email protected]</saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml2:SubjectConfirmationData InResponseTo="_80258326a1...cd4bbd" NotOnOrAfter="2016-11-28T09:54:45.807Z" Recipient="http://1.2.3.4/simplesamlphp/www/module.php/saml/sp/saml2-acs.php/wso2-sp" />
</saml2:SubjectConfirmation>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml2:SubjectConfirmationData InResponseTo="_8025832...d4bbd" NotOnOrAfter="2016-11-28T09:54:45.807Z" Recipient="https://my.wso2.apim:8243/token" />
</saml2:SubjectConfirmation>
</saml2:Subject>
<saml2:Conditions NotBefore="2016-11-28T09:49:45.808Z" NotOnOrAfter="2016-11-28T09:54:45.807Z">
<saml2:AudienceRestriction>
<saml2:Audience>mytestapp</saml2:Audience>
<saml2:Audience>https://my.wso2.apim:8243/token</saml2:Audience>
</saml2:AudienceRestriction>
</saml2:Conditions>
<saml2:AuthnStatement AuthnInstant="2016-11-28T09:49:45.815Z" SessionIndex="1f5192...b591">
<saml2:AuthnContext>
<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml2:AuthnContextClassRef>
</saml2:AuthnContext>
</saml2:AuthnStatement>
<saml2:AttributeStatement />
</saml2:Assertion>
エンコードをbase64でURLエンコードされたXMLとして:他からコピーした方法を使用して
PHNhbWwyO...dGlvbj4,
SOそれは程度だ
function base64_url_encode($input) {
return strtr(base64_encode($input), '+/=', '-_,');
}
を投稿します20行の長さです(そして、最後にコンマがあります)。それは動作しません
、私は、JSONの結果をトレースで
{"error":"invalid_grant","error_description":"Provided Authorization Grant is invalid."}
を得る:
TID: [0] [AM] [2016-11-29 11:04:50,297] DEBUG {org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler} - SAML Token Issuer verification failed or Issuer not registered {org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler}
TID: [0] [AM] [2016-11-29 11:04:50,298] DEBUG {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer} - Invalid Grant provided by the client, id=fkJa...Ohoa, user-name=null to application=myapp-subscriber_test_PRODUCTION {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer}
TID: [0] [AM] [2016-11-29 11:04:50,300] DEBUG {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer} - OAuth-Error-Code=invalid_grant client-id=fkJa...hoa grant-type=urn:ietf:params:oauth:grant-type:saml2-bearer scope=PRODUCTION {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer}
私はシステムのコンフィギュレータに周りに聞いていますのよ。私にはIDS、APIMとOAuthの間のリンクには何かがありません。いくつかの宣言があります。 (私はこれを検索し、私がしたアサーションの発行者IDを確認するためにstackoverflow交換を思いついたが、何か間違っているものは何も識別できない)
助けてくれてありがとう私は何か新しいことがあります。私が何かを見落としてしまった場合を除いて、もちろん!
は、http://stackoverflow.com/questions/19866021/how-to-get-saml2-bearer-assertion-profile-for-oauth-within-wso2-api-manager-to-w?rqに関連している可能性があります。 = 1 – JRobinss
は、http://stackoverflow.com/questions/34738716/wso2-saml2bearergranthandler-saml-token-issuer-verification-failed-or-issuer-notに関連している可能性があります。 – JRobinss