From 11a541d8cf462134dfaf29f24c83e0d2125dddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Wed, 6 Dec 2023 14:11:44 -0600 Subject: [PATCH] Update REST request collection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates the REST request collection to add the authentication mechanism for the BNA API private endpoints. Signed-off-by: Rémy Greinhofer --- .gitignore | 1 + lambdas/.gitignore | 2 +- lambdas/requests.rest | 53 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dfd26b7..efbb559 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ dbml-error.log debug/ lambdas/tests/.hypothesis lambdas/tests/.venv +lambdas/.env target/ diff --git a/lambdas/.gitignore b/lambdas/.gitignore index c41cc9e..ea8c4bf 100644 --- a/lambdas/.gitignore +++ b/lambdas/.gitignore @@ -1 +1 @@ -/target \ No newline at end of file +/target diff --git a/lambdas/requests.rest b/lambdas/requests.rest index 15fdf30..c7c9125 100644 --- a/lambdas/requests.rest +++ b/lambdas/requests.rest @@ -72,3 +72,56 @@ content-type: application/json "region": "new mexico", "title": "CTO" } + +### +# https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html#API_InitiateAuth_ResponseSyntax +# @name cognito_auth +POST https://cognito-idp.us-west-2.amazonaws.com/ +content-type: application/x-amz-json-1.1 +X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth +Accept-Encoding: gzip, deflate, br +Connection: keep-alive + +{ + "AuthParameters" : { + "USERNAME" : "{{$dotenv USERNAME}}", + "PASSWORD" : "{{$dotenv PASSWORD}}" + }, + "AuthFlow" : "USER_PASSWORD_AUTH", + "ClientId" : "{{$dotenv CLIENT_ID}}" +} + +### +# https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RespondToAuthChallenge.html#CognitoUserPools-RespondToAuthChallenge-request-ChallengeResponses +# @name cognito_mfa +# @prompt mfa_code software MFA code +POST https://cognito-idp.us-west-2.amazonaws.com/ +content-type: application/x-amz-json-1.1 +X-Amz-Target: AWSCognitoIdentityProviderService.RespondToAuthChallenge + +{ + "ChallengeName": "SOFTWARE_TOKEN_MFA", + "ChallengeResponses": { + "USERNAME": "{{$dotenv USERNAME}}", + "SOFTWARE_TOKEN_MFA_CODE": "{{mfa_code}}" + }, + "ClientId": "{{$dotenv CLIENT_ID}}", + "Session": "{{cognito_auth.response.body.Session}}" +} + +### +@cognito_access = {{cognito_mfa.response.body.AuthenticationResult.AccessToken}} +@cognito_id = {{cognito_mfa.response.body.AuthenticationResult.IdToken}} +@cognito_refresh = {{cognito_mfa.response.body.AuthenticationResult.RefreshToken}} + +### +POST https://api.peopleforbikes.xyz/enqueue/city +content-type: application/json +Authorization: Bearer {{cognito_access}} + +{ + "city": "santa rosa", + "country": "usa", + "fips_code": "3570670", + "region": "new mexico" +}