Skip to content

Commit

Permalink
Update REST request collection
Browse files Browse the repository at this point in the history
Updates the REST request collection to add the authentication mechanism
for the BNA API private endpoints.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho committed Dec 6, 2023
1 parent 626a2f2 commit 11a541d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dbml-error.log
debug/
lambdas/tests/.hypothesis
lambdas/tests/.venv
lambdas/.env
target/
2 changes: 1 addition & 1 deletion lambdas/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
/target
53 changes: 53 additions & 0 deletions lambdas/requests.rest
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 11a541d

Please sign in to comment.