Configuring Amazon API Gateway for PingOne Authorize integration
Configure a request parameter-based Lambda authorizer and integrate it with PingOne Authorize and a backend REST API.
Before you begin
Ensure you have:
-
A comfortable level of knowledge of the following interfaces and technologies (or access to developers as needed):
-
Sufficient permissions to create, edit, and publish Lambda functions and modify API endpoints.
-
The Amazon API Gateway integration kit downloadable
.zip
archive. Download the integration kit from the Ping Identity Integration Directory.
About this task
The Amazon API Gateway works with Lambda authorizer to manage access to your API resources. When a client makes a request to the backend API, Amazon API Gateway calls the configured Lambda authorizer to create a sideband request for the runtime authorization service. Lambda authorizer then translates the policy response into an IAM policy document for Amazon API Gateway to use in enforcement. If access is permitted, the gateway executes the backend endpoint; if access is denied, the gateway returns a suitable status code and a reason for the denial to the client.
Amazon API Gateway provides PingOne Authorize with client API request metadata, such as The Lambda authorizer has the following limitations:
|
Upload the integration kit in AWS and configure it to integrate with PingOne Authorize.
Steps
-
Create the Lambda function:
-
Open the AWS Lambda Service.
-
Click Create function.
-
Click Author from scratch.
-
In the Function name field, enter a name.
-
In the Runtime list, select Node.js 20.x.
-
In the Architecture section, click x86_64.
-
Click Create function.
-
-
Upload the Amazon API Gateway integration kit
.zip
archive and configure the environment variables:-
On the page for your newly created Lambda function, in the Code source pane, select .zip file in the Upload from list.
-
In the Upload a .zip file modal, click Upload. Select the integration kit
.zip
archive. -
Click Save.
After saving, your Lambda code source should appear with these files uploaded:
-
Scroll down, and in the Runtime settings pane, click Edit.
-
In the Runtime list, select Node.js 20.x.
-
In the Handler field, enter
aws-lambda-authorizer/src/aws-lambda-authorizer.handler
. -
Click Save.
-
Scroll up and click the Configuration tab.
-
In the left navigation pane, click Environment variables. Click Edit.
-
Add the following environment variables.
Environment variable Value IS_DEBUG_ENABLED
true
orfalse
depending on whether debugging is required. Generally, in a production environment, this variable is set tofalse
.SECRET_HEADER_VALUE
The Gateway Credential from the PingOne console that you saved earlier.
SERVICE_URL
The Service URL from the PingOne console that you saved earlier.
-
Click Save.
If you have already configured your backend API in AWS, skip to step 4.
Transient network or service issues can cause API gateway requests to fail with 5xx errors, and connection resets can cause requests to fail with client network errors. To control the number of retries before a failed response is returned to the client, use the
maxRetries
setting inconfig.js
. The default is1
.
-
-
Configure a backend REST API:
-
Open the AWS API Gateway service.
-
Click Create API.
-
In the REST API menu, click Build.
-
In the API name field, enter a name. Leave the rest of the default selections.
-
Click Create API.
Lambda authorizer supports integration with both REST and HTTP APIs. For more information, see Using AWS Lambda with Amazon API Gateway.
-
-
Configure Lambda authorizer using the Lambda function:
-
On the page of your backend API, click Authorizers in the left navigation pane.
-
Click Create New Authorizer.
-
In the Name field, enter a name.
-
For the Type, click Lambda.
-
In the Lambda Function section, select your region and enter the name of the Lambda function that you created earlier.
-
Leave the Lambda Invoke Role field blank.
By default, the Amazon API Gateway console sets a resource-based policy that grants the API Gateway permissions to invoke Lambda authorizer.
-
For Lambda Event Payload, click Request.
-
For Authorization Caching, clear the Enabled check box.
-
Click Create.
You must repeat this Lambda configuration for each backend API that you want to protect with Lambda authorizer.
-
-
Assign an API method to Lambda authorizer and configure the integration point:
-
On the page of your newly created backend API, click Resources in the left navigation pane.
-
In the Actions list, select Create Resource.
-
Enter a name and path for your resource.
-
Click Create Resource.
-
In the Actions list, select Create Method.
-
In the list for your newly created resource path, select a REST API method and click the check mark button.
Resources in your API define one or more methods, such as
GET
orPOST
. Integrating these methods with Lambda authorizer means that any client API request of this method type is forwarded to the configured Lambda function.You can define each resource and method individually, or use special resource and method types that apply to all incoming requests of a certain form. For example, the
ANY
method applies to all incoming requests. -
For the Integration type, click HTTP.
-
In the HTTP method list, select a method corresponding to the method that you selected in step 5e.
-
In the Endpoint URL field, enter the endpoint to which the client API request is sent.
-
Keep the other default values and click Save.
-
In the method exeuction graphic, click Method Request.
-
Click the pencil icon next to Authorization and select your configured Lambda authorizer from the list. Click the check mark.
-
-
Deploy the API Gateway:
-
On the page for your API, click Resources in the left navigation pane.
-
In the Actions list, select Deploy API.
-
In the Deployment stage list of the Deploy API modal, do one of the following.
Choose from:
-
Select an existing stage to deploy to.
-
Select [New Stage]. Enter a name and optional description for the stage.
-
-
Click Deploy.
-
Next steps
Define API services to represent your APIs so that PingOne Authorize can help your API gateway enforce access control. For more information, see Defining your API in PingOne Authorize.
You can only define API services configured with PingOne SSO to integrate with Lambda authorizer. |