Add Authentication to Portman API tests

ADD SECURITY TO API GATEWAY

ProductsAPI: 
Type: AWS::Serverless::Api
Properties:
StageName: Lambdaless
Auth:
ApiKeyRequired: true
UsagePlan:
CreateUsagePlan: PER_API
UsagePlanName: ProductsAPIUsagePlan
DefinitionBody:
'Fn::Transform':
Name: AWS::Include
Parameters:
Location: ./products-openapi.yaml
ApiKeyId:     
Description: API Key ApiKeyId
Value: !Ref ProductsAPIApiKey

GET THE API KEY

ADD SECURITY DEFINITIONS IN THE OPENAPI

securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-KEY
security:   
- ApiKeyAuth: []

CONFIGURE PORTMAN TO USE AN API KEY

{   
"securityOverwrites": {
"apiKey": {
"value": "INSERT THE API KEY HERE"
}
}
}

RECAP

--

--

Passionate software engineer focused on cloud development.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store