authorization
header of the request to access the API.iss
and aud
claims.300
seconds and the maximum length of caching is 3600
seconds (you can also set the value to 0 to disable caching).
To read more, visit What is Amazon API Gateway? in the Amazon Developer’s Guide. For more information on verification, review our JSON Web Token article.
Field | Description |
---|---|
Name | A friendly name for your API. This is the name you’ll see in your list of Auth0 APIs. |
Identifier | A logical identifier for your API. We recommend formatting this identifier like a URL https://your-api-gateway . |
Signing Algorithm | The algorithm you want Auth0 to use to sign the issued . To learn more, see Signing Algorithms. |
GET
and POST
). You can view the details of a method, modify its configuration, or test the method invocation by clicking the method name from the resource tree.
/pets
. This brings up the Method Execution window that provides an overview of the POST
method’s structure and behaviors:
/pets - POST - Method Test
page. Scroll to the bottom of the page, and provide the following snippet as the Request Body:
Parameter | Value |
---|---|
Deployment stage | Choose [New Stage] |
Stage name | Provide a name for your stage |
Stage description | Provide a description for your stage |
Deployment description | Provide a description for your API deployment |
GET
endpoint of your API. Click on the link to submit the GET / method
request in a browser. This should result in the following success response:
/pets/{petId}
.
{petID}
, stands for a path variable. Replace this variable with 1
, and navigate to the new URL using your browser. You should receive an HTTP 200 request with the following JSON payload:
npm install
to install the Node.js packages required for deployment; AWS requires that these files be included in the bundle you will upload to AWS during a later step.
.env
file. You can copy the .env.sample
file (while simultaneously renaming it .env
) using cp .env.sample .env
. Make the following changes:
Parameter | Value |
---|---|
TOKEN_ISSUER | The issuer of the token. If Auth0 is the token issuer, use https://{yourDomain}/ . Be sure to include the trailing slash. |
JWKS_URI | The URL of the JWKS endpoint. If Auth0 is the token issuer, use https://{yourDomain}/.well-known/jwks.json |
AUDIENCE | The identifier value of the API you created in the Create an Auth0 API section above. |
.env
file should look something like this when complete:
event.json
file containing the token. You can copy the sample file (run cp event.json.sample event.json
). Replace ACCESS_TOKEN
with your JWT token, and methodArn
with the appropriate ARN value for the GET
method of your API.methodArn
:
/pets
, select GET.npm test
.Effect
is Allow
, your authorizer would’ve allowed the call to API Gateway.
To learn more, visit Lambda-local at NPM.
Auth0Integration
. Leave the rest of the fields as is. Select Create role.
npm run bundle
. This generates a custom-authorizer.zip
bundle containing the source, configuration, and node modules required by AWS Lambda.
Parameter | Value |
---|---|
Name | A name for your Lambda function, such as jwtRsaCustomAuthorizer |
Description | A description for your Lambda function (optional) |
Runtime | Select Node.js 10.x |
custom-authorizer.zip
bundle you created earlier.
.env
file.
Parameter | Value |
---|---|
TOKEN_ISSUER | The issuer of the token. If Auth0 is the token issuer, use https://{yourDomain}/ |
JWKS_URI | The URL of the JWKS endpoint. If Auth0 is the token issuer, use https://{yourDomain}/.well-known/jwks.json |
AUDIENCE | The identifier value of the API you created in step 1. |
event.json
file into the Configure test event form. You can use the default “Hello World” event template.
Parameter | Value |
---|---|
Name | jwt-rsa-custom-authorizer |
Type | Select Lambda |
Lambda Region | Use the region for the Lambda function you created previously |
Lambda Function | jwtRsaCustomAuthorizer |
Lambda Invoke Role | The IAM Role ARN you copied above |
Lambda Event Payload | Select Token |
Token Source | Authorization |
Token Validation | ^Bearer [-0-9a-zA-z.]*$ |
TTL (seconds) | 3600 |
Bearer ey...
) you previously used.
If the test was successful, you’ll see a response similar to the following.
/pets
resource.
jwt-rsa-custom-authorizer
custom authorizer you created in step 3.
false
.
Parameter | Value |
---|---|
Deployment stage | Choose [New Stage] |
Stage name | Provide a name for your stage |
Stage description | Provide a description for your stage |
Deployment description | Provide a description for your API deployment |
GET
call to the Invoke URL you noted in the previous step. If this test fails, check that you obtained the JWT access token correctly.
For details, see Get Access Tokens.