login.js
, you can see this scope specified in the parameters passed to auth.signin
:
index.js
: contains your main code;auth0-variables
: contains the code you need to update.package.json
file.
The code adds functionality to extract information from and validate the JWT. By default, Auth0 uses a symmetric key for signing the JWT, though you may opt to use asymmetric keys (if you need to allow third-party validation of your token, you should use an asymmetric key and share only your public key).
For more information about token verification, see Identity Protocols Supported by Auth0.
Update auth0-variables.js
with your secret key, which can be found on the Settings tab of your Application in the :
index.js
must be at the root of the zip), and upload it for use by the PurchasePet
Lambda function. If you test this, you should see an authorization failure, since the JWT is not in the message body.
Take a look at the logic in index.js
. You will see logic around line 60 that validates the token and extracts the decoded information that contains the identity information used for the purchase logic:
Authorization
header as a bearer token, and you can use this method by turning off IAM authorization and relying solely on the OpenID Token for authorization (you will also need to map the Authorization header into the event data passed to the AWS Lambda function).
If, however, you are using IAM, then the AWS API Gateway uses the Authorization
header to contain the signature of the message, and you will break the authentication by inserting the JWT into this header. To do this, you can either:
pets/purchase
.
To keep the validation process simple, pass the JWT in the body of the post to the AWS Lambda function. To do this, update the buyPet
method in home.js
by removing the userName
from the body, and adding authToken
as follows: