The IBM DataPower API gateway acts as a proxy between consumer applications and backend APIs. The API gateway secures, protects, and manages APIs by intercepting API requests and applying policies, such as throttling and security.
You can extend the gateway's functions to change the API flow by implementing custom gateway scripts and global policies in order to meet the requirements of your specific use case.
In order to integrate with the Cequence Unified API Protection (UAP) platform, the IBM DataPower API gateway must send all request and response data to a Cequence API Edge server. This process uses synchronously triggered custom scripts to process request and response data, then asynchronously format and post that data to the Cequence Bridge, which transmits the data to the Cequence Edge server. The Edge server analyzes the transaction data to provide actionable insights into your API traffic. Configuration of traffic filtering and sensitive data masking for the Cequence Bridge is discussed in a separate article.
Using the procedures in this article requires a bundle of files provided by Cequence. You can download this bundle from this page.
High level architecture
- The client sends a request to the IBM DataPower API Gateway.
- The request script intercepts the request and captures the request payload and metadata.
- The request script forwards the request to the Backend/Target Applications.
- The backend or target application generates a response, and any subsequent policies are executed.
- The response script intercepts the response in order to capture the response payload and metadata.
- The response script forwards the response to the clients or caller.
- The script posts the combined request and response payload, along with the associated metadata, to the Cequence Bridge.
- The Cequence Bridge forwards this information to the Cequence UAP Edge server for threat analysis, detection, and mitigation.
Integration setup
Setting up the Cequence UAP platform to integrate with the IBM DataPower API gateway is a multistep process.
- Create a Cequence policy
- Upload your TLS certificate
- Create a TLS client profile for Cequence
- Configure the TLS client profile for the gateway
Pre-Requisites
- IBM DataPower API gateway release 10.62 or later
- Cequence UAP platform release 7.3.X or later
- Client ID (Key) and Client Secret generated from the Cequence UAP platform UI
- Cequence Sensor Bridge deployed in close proximity to the IBM DataPower API Gateway
- Endpoints for the Cequence Bridge.
Generating a Client ID and Client Secret
Several Cequence components must authenticate to the Cequence UAP platform in order to transmit and receive data. Create authentication credentials in the Cequence UAP platform to enable this authentication.
- Log in to the UAP management portal UI.
The URL for the management portal is typically of the form https://ui.<your-tenant-name>.<domain>. Replace <your-tenant-name> with the name of your Cequence tenant organization. Replace <domain> with your domain name. - Select General Settings > User Management.
The User Management pane appears. - Click the Clients tab.
- Click Add New Client.
The new client dialog box appears. - Type the client name in the Client Name field.
This name is the client ID. Note the client ID for later use. - Enable the Traffic Ingestion toggle.
- (Optional) To change the token lifespan from the default of 1800 seconds, type a whole number of seconds in Token Lifespan.
- Click Save.
A dialog box with the client secret appears. - Click the blue Copy icon to copy the secret to the clipboard, then click Close.
The client is now set up. Note the client name for future use.
The client list appears. - Note the value of the client secret for later use. This value will not be shown again later on the UI for security reasons.
Installing the integration
This procedure installs the software to integrate the Cequence UAP platform with the IBM DataPower API gateway. Other procedures later in this article configure the integration.
- Download the archive file cequence-datapower-v1.zip from the Downloads page.
- Copy the downloaded archive file to a directory named cequence. Create this folder if necessary.
cp <$DOWNLOAD_DIR>/cequence-datapower-v1.zip $CEQUENCE_DP_HOME
mkdir -p $HOME/cequence && cd "$_" - Uncompress the archive file, then navigate to the cequence-datapower-v1 directory.
The directory name may vary to match changes in the file name.
unzip cequence-datapower-v1.zip
cd cequence-datapower-v1 - Set the current directory as the value of the CEQUENCE_DP_HOME variable.
export CEQUENCE_DP_HOME=$(pwd)
- Copy the environment template to a new file.
cd $CEQUENCE_DP_HOME
cp .env_example .env - Open the .env file in a text editor and set the value of the CEQUENCE_BRIDGE_URL variable to the URL of the Bridge endpoint.
- Skip this step unless you require x-cequence performance headers that show latency. Set the value of the CEQUENCE_ENABLE_CUSTOM_RESPONSE_HEADERS variable to true.
- Run the setup script.
cd $CEQUENCE_DP_HOME/scripts
The setup script generates the gateway scripts required for the Cequence Policy. The scripts are written to the $CEQUENCE_DP_HOME/generated folder
chmod +x *.sh
./setup.sh
The integration software is now installed. The directory structure and contents of the generated folder are as follows.
└── generated
├── cequence-policy.zip
├── cequence-tls-client-profile.zip
├── cequence.crt
├── cequence.js
└── postman-echo.crt
Creating a Cequence Policy
You can create a policy for the Cequence UAP platform by importing a compressed file with the necessary items or with manual configuration. The cequence-policy.zip file is generated by the setup script in the CEQUENCE_DP_HOME/generated/ directory.
Importing the compressed file
- Log in to the IBM DataPower API gateway.
- From the left sidebar, click Import, then select Import Configuration.
- Click Choose file.
- Select the cequence-policy.zip file and click Next.
- Click Import.
- Click Done.
You can confirm successful file import by checking the Multi-protocol Gateway policy section of the Gateway Policy page for the new policy.
Manually configuring the policy
Skip this procedure if you have successfully imported the compressed file.
- In the left sidebar, click File Management.
- Only perform this step if the cequence directory does not exist. Click Actions > Create subdirectory.
- In the Name field, type cequence, then click Confirm Create.
- Click Continue.
- Expand the local section.
- Next to the cequence directory, click Actions > Upload Files.
- Select the cequence.js file in the $CEQUENCE_DP_HOME/generated directory.
- Click Upload.
- Click Continue.
- In the left sidebar, click Multi-Protocol Gateway Policy.
- Click Add New Policy.
- In the Name field, type cequence-policy, then click New Rule.
- In the Name field, type cequence_rule, then double-click Match action of the rule.
- Select __default-accept-service-providers__ from the dropdown, then click Done.
- Drag a GatewayScript to the right of the Match rule.
The GatewayScript icon is a set of braces, {}. - Double-click the GatewayScript.
- From the dropdown, select INPUT.
- Select local:///cequence, then select the uploaded script.
- In the Output field, type CEQUENCE_SCRIPT_OUTPUT, then click Done.
- Click Apply Policy.
The IBM DataPower API Gateway automatically adds a Results Action to the end of the policy action queue. - At the right side of the queue, double-click the last Results Action.
- From the dropdown, select INPUT, then Done.
- Click Apply Policy.
- Drag an Advanced action to the right of the GatewayScript action.
The Advanced action icon is a black diamond with a white curved vertical line. - Double-click the Advanced action.
- Select Set Variable, then click Next.
- In the context field, type NULL.
- In the Variable name field, type the following.
context/CEQUENCE_BRIDGE_OUTPUT/_roottree
- In the Variable value field, type the following.
var://context/cequence/bridgePayload
- Click Done.
- Drag an Advanced action to the right of the Advanced action you configured previously.
- Double-click the Advanced action.
- Select Set Variable, then click Next.
- In the context field, type NULL.
- In the Variable name field, type the following.
context/CEQUENCE_BRIDGE_OUTPUT/_extension/header/Content-Type
- In the Variable value field, type the following.
application/json
- Click Done.
- Drag an Advanced action to the right of the Advanced action you configured previously.
- Double-click the Advanced action.
- Select Conditional, then click Next.
- From the Input drop-down, select CEQUENCE_SCRIPT_OUTPUT
- In the Match Condition field, type the following.
/cequence/processResultsAction/text() = 'true'
- From the Action drop-down, select Results Asynchronous.
- Click Create Action.
- From the Input drop-down, select CEQUENCE_BRIDGE_OUTPUT.
- From the Destination drop-down, select var://.
- In the Destination field, type the following.
context/cequence/bridgeUrl
- Click Done.
- In the Match Condition field, type the following.
/cequence/processParseAction/text() = 'true'
- From the Action drop-down, select Parse.
- Click Create Action.
- From the Input drop-down, select INPUT.
- From the Output drop-down, select OUTPUT.
- Click Done, then click Done again.
- Click Apply Policy.
- Click Save Config.
- Click Close.
Uploading the Cequence security certificate
The IBM DataPower API gateway cannot import the Cequence TLS certificate from an archive file. This procedure uploads the security certificate.
If the settings of your existing TLS client profile's validation credentials are set to Disable Server Certificate Validation, you can skip this procedure and go directly to Configuring the Cequence Plugin.
When you change the security certificate, perform this procedure again to add the new certificate.
When the validation credential settings for your existing TLS profile are configured to check for dates, renew the Cequence certificate before expiry, then re-upload the certificate.
When you renew or update the Cequence Bridge security certificate, run the setup.sh script to generate a new cequence.crt file. Alternately, you can export the certificate from your browser.
- In the left sidebar, click File Management.
- Next to the certificate, click Actions, then Upload Files.
- Choose the following file and click Upload.
CEQUENCE_DP_HOME/generated/cequence.crt
- If you are renewing or changing an existing certificate, click Overwrite Existing Files. Otherwise, skip this step.
- Click Continue.
- Click Save Config.
- Click Close.
Creating the Cequence TLS Client Profile
You can create a Cequence TLS client profile manually or by importing a compressed archive file.
Before you begin
Confirm that a valid Cequence security certificate is present.
Configure the TLS client profile by importing a compressed archive file
- On the left sidebar, click Import Configuration.
- Click Choose File.
- Select the following file, then click Next.
CEQUENCE_DP_HOME/generated/cequence-tls-client-profile.zip
- Click Import
- Click Done
Display the list of TLS client profiles to confirm that the profile exists.
Manually configuring the TLS client profile
Skip this procedure if you have successfully configured a TLS client profile by importing a compressed archive file.
- On the left sidebar, click TLS client profile.
- Click Add.
- In the Name field, type cequence-tls-client-profile.
- Toggle Validate server certificate to off.
- Click Apply.
- Click Save Config.
- Click Close.
Configuring the TLS client profile for the gateway
The asynchronous actions configured in the Cequence policy rule send payloads to Cequence over HTTPS. Using HTTPS requires a TLS client profile to establish secure connection.
Gateway APIs without an existing TLS client profile use HTTP. Configure these APIs to use the cequence-tls-client-profile configured previously.
Configuring existing TLS client profiles
This procedure is only necessary when an API is using an existing TLS profile with server certificate validation. This procedure adds the Cequence certificate to the existing validation credentials of the existing TLS profile.
- In the IBM DataPower API gateway dashboard, navigate to the TLS profile in use.
- Click Edit.
- From the Certificates dropdown, select cequence-cert.
- Click Add.
- (Optional) To enable expired certificates, disable the Use CRL and Check Dates toggles.
- Click Apply.
- Click Apply.
- Click Apply.
- Click Save Config.
- Click Close.
Configuring the Cequence plugin
When you use the default policy for your gateway, set the processing policy as cequence-policy. When you have an existing policy you want to use for the gateway, update the rules.
For example, a gateway with a default, non-custom policy appears similar to the following image.
By contrast, a gateway with an existing custom policy appears similar to the following image.
Replacing a default policy
These steps assume you are logged in to the IBM DataPower console.
- Click Control Panel > Multi-Protocol Gateway.
- Click the name of the gateway with the default policy you want to change.
- From the dropdown, select cequence-policy.
- Click Apply.
Repeat these steps for each multi-protocol gateway without an existing custom policy.
Modifying an existing custom policy
- Click Control Panel > Multi-Protocol Gateway.
- Click the name of the Gateway with the default policy you want to change.
- Click the three-dot icon next to the existing processing policy.
The configuration window appears. - When the policy has request and response rules, edit each rule. For each request rule, place the Cequence Processing rule at the start of the request rule, after the matching action. For each response rule, place the Cequence Processing rule at the end of the response rule. For each Both Directions rule, add the Cequence Processing rule at the start of the rule.
These placements enable the capture of the request and response payloads as received by the Datapower gateway. - Double click Advanced.
- Click Call Processing Rule, then click Next.
- From the Input dropdown, select Input.
- From the Processing rule dropdown, select cequence_rule.
- From the Output dropdown, select NULL.
- Click Done.
- Click Apply.
Clearing a "PIPE Output not followed by PIPE Input" error
When the end of the response rule does not contain a default results action, you may see an error message similar to PIPE Output not followed by PIPE Input on action. To clear this error, set the output for the script before the Processing rule.
- Click Control Panel > Multi-Protocol Gateway.
- Click the name of the Gateway with the default policy you want to change.
- Click the three-dot icon next to the existing processing policy.
The configuration window appears. - Double click Advanced.
- Double-click the double braces ({}) icon.
The script editor pane appears. - From the Output dropdown, select OUTPUT.
- Click Done.
A new Default Results action appears at the end of the rule timeline. - Delete the new Default Results action.
- Click Apply Policy, then close the popup.
- Click Apply.
Testing the Plugin Setup
To test that the integration is operating correctly, first send some traffic through the system.
- Log in to the Cequence UAP platform.
The dashboard appears. - In the left hand navigation, in the Runtime Inventory section, click API Inventory.
The API Inventory page appears in the Dashboard main area. - At the top of the API Inventory page, click the Active API Endpoints tab.
Typically this is the active tab by default, so you may not need to perform this step. - At the top of the list of endpoints, click the vertical three-dot menu next to More.
A list of other time frames appears. - Select 15 Min.
The API Inventory displays API endpoints that have been active in the last 15 minutes.
Check the displayed results to confirm the traffic you sent appears in the inventory of active API endpoints.
Rolling back an integration
To roll back DataPower integration for APIs that did not have a previous custom policy, revert the policy to default.
- Log in to the DataPower gateway.
- Click Control Panel > Multi-Protocol Gateway.
- Select the gateway to roll back.
- Set the Processing Policy to default.
- Click Apply.
Repeat for all applicable gateways.
For APIs that had an existing custom policy, delete the call processing rule for each rule in the policy.
- Log in to the DataPower gateway.
- Click Control Panel > Multi-Protocol Gateway.
- Select the gateway to roll back.
- Click the three-dot icon next to the existing processing policy.
The configuration window appears. - Double click Advanced.
- Double click the Call Processing Rule.
- Click Delete.
- Click Apply.
Rolling back the TLS client profile
When a gateway has an HTTP backend and uses the Cequence TLS profile, you can roll back the TLS profile.
- Log in to the DataPower gateway.
- Click Control Panel > Multi-Protocol Gateway.
- Select the gateway to roll back.
- Set the TLS client profile to none.
- Click Apply.
Rolling back HTTPS backend gateways
For gateways with HTTPS backends that have had their validation credentials modified by adding the Cequence certificate, rolling back involves removing this certificate.
- Log in to the DataPower gateway.
- Click Control Panel > Multi-Protocol Gateway.
- Select the gateway to roll back.
- Click the three dots next to the validation credentials.
The credential configuration window appears. - Click X next to the Cequence certificate.
- Click Apply.
The view returns to the credential profile. - Click Apply.
The view returns to the gateway profile. - Click Apply.
Deleting the Cequence policy
- Log in to the DataPower gateway.
- Click Control Panel > Multi-Protocol Gateway Policy.
- Click cequence-policy.
- Click Delete Policy.
Deleting the Cequence TLS Client Profile
- Log in to the DataPower gateway.
- Search for the TLS client profile.
- Select the TLS profile.
- Click the Cequence profile.
- Click Delete.
Deleting the Cequence validation credentials
- Log in to the DataPower gateway.
- Search for the Validation credentials.
- Select the credentials.
- Select cequence-creds.
- Click Delete.
Delete the Cequence certificate
- Log in to the DataPower gateway.
- Search for the Cequence certificate.
- Select the certificate.
- Click cequence-cert.
- Click Delete.
Removing the Cequence files
- Log in to the DataPower gateway.
- Search for file management.
- Enter the file management page.
- Select cequence.crt and cequence.js.
- Delete the selected files.
- Delete the cequence directory.