OAUTH API testing with Jmeter - oauth

I need to test OAUTH 1.0 API testing with Jmeter.
Can anyone please guide me how to test OAUTH 1.0 API's testing with JMETER.
We are passing 4 static keys Consumer Key, Consumer secret, Token and Token Secret
Where do I need to pass these values?

You need to pass Consumer Key and Consumer Secret to OAuth Temporary Credentials Acquisition endpoint, you will get OAuth Token and Token Secret as the response
Once done you need to pass the aforementioned OAuth Token and Token Secret to the Authorization Endpoint - you will get the Access Token
Add HTTP Header Manager as a child of the request and configure it like:
Name: `Authorization`
Value: `Bearer ${Access Token from Step 2}`
You might also need to sign the requests by encrypting the message with one of the following mechanisms:
HMAC-SHA1
RSA-SHA1
or if you are lucky your server will accept plain text requests (unlikely)
References:
OAuth Authorization Flow
OAuth Core 1.0
How to Run Performance Tests on OAuth Secured Apps with JMeter

Related

AWS Cognito - Validate bearer token

Is there any endpoint in AWS Cognito to validate the bearer token?
I am using cognito as my oauth provider and I am able to get the bearer token successfully with app client id and secret.
Now I have to make a call to cognito, to cross verify if it really generated this token and validate the authenticity of the token from my application.
Cognito issues JWT tokens, so you must validate them via a library, which will download the token signing public key from Cognito's AWS endpoint.
Here is an API example in AWS, that validates access tokens using Node.js. A front end app could use similar validation for ID tokens:
JWT Validation Code
If you have particular technology preferences, post back and I'll recommend a library.

How JWT is different from OAuth 2.0?

I have done a sample application using Sprint Boot, Spring security and JWT and define my custom authentication & authorization filters. While performing basic authentication (passing username & password) I get JWT token in the format of xxxx.yyyy.zzzz where xxxx is header, yyyy is payload and zzzz is signature and each part is encoded using Base64URL encoder. What I do not understand is how JWT is different from OAuth 2.0. In OAuth 2.0, we can pass 2 types of grant_types as either 'username' or 'client credentials' & also needs to pass client id, secret id to get access & refresh tokens.
Please assist to clarify my following doubts:-
1) Is JWT lighter than OAuth 2.0 as it does not contain the refresh token but just access token?
2) Is JWT cannot be used to make a standalone authorization server like we can make a standalone authorization server using #EnableAuthorizationServer annotation when it comes to OAuth 2.0. Is my assumption correct?
3) JWT does not accept client id/secret client but just used as basic authentication to get bearer tokens?
4) Is the format of access token (or bearer) for both OAuth2.0 and JWT are different?
I have seen an example where both OAuth 2.0 and JWT were used. OAuth 2.0 was to make authorization server which returns JWT token only in the end but did not understand why JWT was used if OAuth2.0 can return a token by itself.
Thank you
JWT is a JSON-based token defined in RFC 7519. OAuth 2.0 is an authorization framework defined in RFC 6749. Comparing both is like asking "How Glucose is different from Apple Pie?".
However, it is possible to bring OAuth 2.0 and JWTs together as is defined in RFC 7523 – The JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants. It standardizes, how to use JWTs as bearer tokens within the OAuth 2.0 framework, which enables what I call stateless authentication.
Regarding your questions:
Whether or not you use JWTs as bearer tokens does not influence whether or not you want to hand out refresh tokens.
Not sure whether I get your questions. However, using JWT allows you to do decentral, stateless auth decisions as there is no necessity to store token state centrally. However, nobody prevents you from having a standalone authorization server.
How you want to do authentication has nothing to do with JWT. It is still OAuth 2.0.
In OAuth 2.0 bearer tokens are considered to be opaque tokens – the format does not matter. If you use JWTs as bearer tokens, you need to follow the corresponding RFC.

Oauth Consumer key/secret vs access_token/access_secret

I'm trying to understand what each string in the Oauth 1 scheme does.
As per my understanding, the consumer key and consumer secret are used to sign a request to the api, from the calling application, and the access_token and access_secret pair are used as a proxy for the user's login credentials.
Am I right in my understanding?
Not quite. The consumer key is a value that identifies the client application that is being used to access the user resources, and the access token is the value that provides the authorization to access those resources.
A combination of the consumer secret and token secret are used to sign the request which provides verification that the request is being sent by an authorized party.
You can read more about the definitions of the oauth 1.0a spec here.

Usage of response_type="code token" in OAuth 2?

The OpenID Connect Spec OAuth 2.0 Multiple Response Type Encoding Practices states that multiple response_type can be combined, e.g. response_type="code token". Now I'm wondering what it's good for to request an authorization code and the token. Isn't the auth code superfluous if you have the token already?
OAuth 2.0 is a protocol framework on top of which other protocols can be built and OpenID Connect is an example of such a protocol.
Especially for OpenID Connect it makes sense to use combined response types because there are 2 tokens in play: the access_token and the id_token. Using "response_type" the client can request how each of the tokens should be delivered.
In the example that that you give, the access_token will be delivered through the front channel as part of the authentication response but the id_token will be delivered when exchanging the "code" for an id_token at the token endpoint in a backchannel call.
A reason for doing this may be that the id_token, which is a signed JWT, does not have to be verified locally when obtained from a proper TLS protected token endpoint, so the client code can be simple. The access_token is opaque to the client anyhow and does not benefit from that.
I've never seen this used in practice. Yes, having the token already kind of diminishes the value of using the code flow.

Get OAuth 2.0 token via ACS

I have an application that understands OAuth 2.0 token (on passing a valid OAuth 2.0 token, it authenticates a user) returned by Live ID .
This OAuth toke looks like -
"78wcH%2by1t6avE8zhVCzXQndK2zWJbCWvoZbSKfAduQuyQETUG2FtN5FOw%2bKaj5uCwUfuOS/2J35NvhDkZaaqoOzOVuoTYUDZgAACNzcJuSyBR21CAE9LpBrltj0PljQ76Hd9aJXW8x8DtRsKZvOn76PN69oGDzrGIjXXPIyCGDii9TYmP92kmh50B05qTqhdLiAXcluriQWuEMKONPUVazSmFN2BXZVW3NDdk3vkos8m68SXf%2"
Now I have another application which is based on Azure ACS mechanism. I can get SAML or SWT token from there.
Sample SWT tokens can be found here
Is there any method I can convert the SAML/SWT tokens to the former OAuth 2.0 token?
Note: I tried fetching SWT tokens via OAuth v2-13 protocol, but this token is not validated by the service accepting OAuth token.
Found it.
ACS doesnot expose any API which converts a SAML token to an OAuth 2.0 token.
The possible alternative is that on receiving a SAML token, break open the token, verify the authenticity of the user and successively, fetch OAuth token for the user using live id APIs.
It will definitely double the latency for your signin process.

Resources