The WSO2 API Manager is an on-going project with continuous improvements and enhancements introduced with each new release to address new business challenges and customer expectations. WSO2 invites users, developers and enthusiasts to get involved or get the assistance of our development teams at many different levels through online forums, mailing lists and support options. We are committed to ensure you a fulfilling user experience at any level of involvement with the WSO2 API Manager. Reference and For more information : http://docs.wso2.org/wiki/display/AM130/About+API+Manager
I hope the intended reader of this post
has successfully installed WSO2 API Manager and has got an idea about
using API manager, OAuth2 token, JWT, client API calls and etc. If
not, please refer the documentation for installation and as a user
guide.
This blog post will be useful for anyone who wants to configure and test the authorization
header of the original client API call request in API manager.
Steps to follow
- Refer the User Guide (http://dist.wso2.org/products/api-manager/1.1.1/WSO2APIManager-v1.1-GettingStarted.pdf and follow the steps to create user roles, users, an application and take it up to publishing level.
- Before the above step, to view the header values, refer http://docs.wso2.org/wiki/display/AM130/Configure+JSON+Web+Token+%28JWT%29+Generation#ConfigureJSONWebTokenJWTGeneration-EnableTokenGeneration and set
<EnableTokenGeneration>true</EnableTokenGeneration>
as true. - Start the server and create an API, publish it and subscribe to it from the API Store.
- Invoke the API and capture the outgoing message from the API Gateway.
- To perform the above step, configure tcp mon to view the API client call request. This request should be configured to view the client call request goes from the WSO2 API Manager to respective interface.
- Once the app is published, make a GET, POST or a PUT request call using a curl or a Jmeter script or using a REST Client (Latest API manager has its own rest client. Or can use Chrome Advanced Rest Client Application). Read more : http://docs.wso2.org/wiki/display/AM140/REST+APIsToken generation is explained in Step 7.
E.g.,curl -v -X POST -H "Content-type: application/xml" -d @create.xml http://localhost:9280/app/1.0.0 -H "Authorization: Bearer <token> "curl -v -X PUT -H "Content-type: application/xml" -d @update.xml http://localhost:9280/app/1.0.0 -H "Authorization: Bearer <token>" - If you use the access the app as an application creator use the Access Token or else as a consumer, you have to follow the below steps (8-10) to generate the authorization bearer key using both Consumer key and the consumer secret in the API Store of the relevant application once you have successfully subscribed.Get the both keys and copy and paste on a text pad together separated by a colon as below.E.g.,<Consumer key> : <Consumer secret>3kaBCHnXCYX9wgS0sFV2zGWqnRQa:YGynxN1Y43LsXCOU4gjkVuwYfoUa
- Then encode it to Base64 format. Refer this site to perform it.E.g., Generated key : M2thQkNIblhDWVg5d2dTMHNGVjJ6R1dxblJRYTpZR3lueE4xWTQzTHNYQ09VNGdqa1Z1d1lmb1Vh
- Then using curl generate the login key. For more reference : http://docs.wso2.org/wiki/display/AM140/User+Tokens
curl -k -d "grant_type=password&username=admin&password=admin&scope=PRODUCTION" -H "Authorization :Basic M2thQkNIblhDWVg5d2dTMHNGVjJ6R1dxblJRYTpZR3lueE4xWTQzTHNYQ09VNGdqa1Z1d1lmb1Vh, Content-Type: application/x-www-form-urlencoded" http://localhost:8280/login
Response :
{"token_type":"bearer","expires_in":3600,"refresh_token":"401b9bca56c9afff8e9f8aece86181","access_token":"c822da634acba682187f17f32e6ed9e7"}
- Get the access token generated (E.g., c822da634acba682187f17f32e6ed9e7) and provide it for the above access token in Step 6 curl command or for the jmeter script's variable - TokenID. "Authorization: Bearer <token>"
- Now send a API call request using Jmeter or curl. (Step 6)
- Observe tcp mon.
- You will see something like below in tcpmon.GET http://10.100.2.115:12765/jaxrs_basic_44/services/customers/customerservice/customers/test1/123/test2 HTTP/1.1X-JWT-Assertion: eyJ0eXAiOiJKV1QiLCJhbGciOiJTSEEyNTZ3aXRoUlNBIiwieDV0IjoiTm1KbU9HVXhNelpsWWpNMlpEUmhOVFpsWVRBMVl6ZGhaVFJpT1dFME5XSTJNMkptT1RjMVpBPT0ifQ==.eyJpc3MiOiJ3c28yLm9yZy9wcm9kdWN0cy9hbSIsImV4cCI6MTM2MjczNDYxNjE1NywiaHR0cDovL3dzbzIub3JnL2NsYWltcy9zdWJzY3JpYmVyIjoiYXBpc3Vic2NyaWJlciIsImh0dHA6Ly93c28yLm9yZy9jbGFpbXMvYXBwbGljYXRpb25pZCI6IjYiLCJodHRwOi8vd3NvMi5vcmcvY2xhaW1zL2FwcGxpY2F0aW9ubmFtZSI6IkFhYmNkIiwiaHR0cDovL3dzbzIub3JnL2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JnL2NsYWltcy90aWVyIjoiVW5saW1pdGVkIiwiaHR0cDovL3dzbzIub3JnL2NsYWltcy9lbmR1c2VyIjoiYWRtaW4ifQ.Q4Q1ET1SECUT1+OT3AEkNXuUnRg3ssUnWWyOt2Us8boBwjA9AYjnKvDnMqqaOJUjRzWqGdZjoYXycTlTmqFBVdNNq+V4Ol4FMcL5zA3mat4JvYQlvhtqD/3zP0pM7SrLCPQ8uCTWWVlX/y+bUg1F1MoKUGvpmACDbgdLtRT9Btc=Content-Type: application/x-www-form-urlencoded; charset=UTF-8Host: 10.100.2.115:12765Connection: Keep-Alive
- Copy the above green colored key which in between 2 separators. (. - dots) in assertion. That is where the header values are included. Base64 decode the second part of the 'assertation' header. Note: The assertion header consists of 3 parts separated by the '.' (period) character.
- Use this site to decode it as below and it will generate the following. Now observe the header values.E.g.,{"iss":"wso2.org/products/am","exp":1362724733786,"http://wso2.org/claims/subscriber":"admin","http://wso2.org/claims/applicationname":"DefaultApplication",http://wso2.org/claims/apicontext":"/AAA","http://wso2.org/claims/version":"1.0.0","http://wso2.org/claims/tier":"Unlimited","http://wso2.org/claims/enduser":"admin"}
E.g.,
{"iss":"wso2.org/products/am","exp":1362724733786,
"http://wso2.org/claims/subscriber":"admin",
"http://wso2.org/claims/applicationname":"DefaultApplication",
"http://wso2.org/claims/apicontext":"/AAA",
"http://wso2.org/claims/version":"1.0.0",
"http://wso2.org/claims/tier":"Unlimited",
"http://wso2.org/claims/enduser":"admin"}
No comments:
Post a Comment