Notice
Requires the Data Collection add-on.
Integrate Apigee Proxy with Cortex Cloud to begin scanning the APIs for potential threats and vulnerabilities.
The integration uses the Apigee’s JavaScript (JS) policy, implemented within a shared flow and deployed as a pre-proxy and post-proxy flow-hook in selected environments. The JS policy is designed to capture both request and response data from all traffic entering and exiting the proxy.
In Cortex Cloud, set up the Apigee data source to integrate with the Apigee Gateway.
From Settings → Data Sources & Integrations , click +Add New, search for Apigee, then hover over it and click Add or Add Instance.
In the Apigee Collector wizard, enter a relevant name and then click Create and Proceed.
Copy the key and paste it somewhere so that you can access it for later.
If you forget to record the key and close the window, you must generate a new key and repeat this process.
Click the Download Configuration Script link to download the plugin, which you can then upload from the Apigee Gateway.
Click Close.
First, download the resource file and then select the method to set up the integration with Apigee.
Use the script for full deployment (with or without connecting a flow hook).
Note
The steps include the prerequisites that run the automated script that deploys files and configurations to Apigee. For manual configuration, refer to the section Manual deployment.
Edit
deploy.shand add values for the following:Variable
Description
PROJECT_ID
Google project ID where Apigee is provisioned.
ORG
Apigee organization. By default, this is the same as PROJECT_ID.
ENV
In Apigee, from the left-side menu, click Environments and copy the name of the environment you want to use.
TARGET_URL
Copy the URL for your Apigee Collector from the Custom Collectors page. For example,
https://api-{tenant external URL}/logs/v1/event.APIsec_API_KEY
Token generated from Cortex Cloud.
Check that the GCP user running the script has
IAMpermissions.apigee.resourcefiles.list apigee.resourcefiles.create apigee.resourcefiles.update apigee.sharedflows.get apigee.sharedflows.create apigee.deployments.create apigee.sharedflowrevisions.deploy apigee.flowhooks.attachSharedFlow apigee.keyvaluemaps.create apigee.keyvaluemaps.delete apigee.keyvaluemapentries.create
Run the
deploy.shscript:chmod +x ./deploy.sh
Verify that the JavaScript policies have been added to the shared flows:
Go to Apigee → Proxy development → Shared Flows and check that the following policies have been added.
sf-api-sec-extension-postflowsf-api-sec-extension-preflow
Validate data ingestion:
Send a request to the gateway and go to Apigee data source to validate that the data has been received from Apigee.
(Optional) Exclude unwanted domains from being tracked by APIsec:
Uncomment: DOMAIN_EXCLUSION_LIST.
Add the domains to exclude.
Edit
deploy.shand set the following variables:export DOMAIN_EXCLUSION_LIST="domain1,domain2"
Discontinue the integration:
Edit
undeploy.sh:export PROJECT_ID=example-project-id export ORG=$PROJECT_ID export ENVIRONMENT=example-env
Run the undeploy.sh script:
chmod +x ./undeploy.sh
Go to Apigee → Proxy development → Shared Flows and check that the following policies have been removed.
sf-api-sec-extension-postflowsf-api-sec-extension-preflow
You can customize the shared flow and apply it to an existing flow hook (pre-proxy, post-proxy).
Set up Apigee's JavaScript policy to send Apigee Collector's API data to Cortex Cloud.
Note
If you have an existing hookand would like to integrate with the shared flow, run the deploy.sh script, and select n' and exit at the prompt to create a new hook. Refer to the section Connect to existing hook.
Edit
panw-api-sec-extension-configuration.propertiesfile:Enter the
targetUrlandprojectID.You can update 127KB of
maxBodyInspectionSizeKB.For domain exclusion, uncomment the line and add the URL to exclude.
targetUrl=<Cortex collector url> projectID=<GCP project id of apigee> maxBodyInspectionSizeKB=127 // This is default and can be modified if needed. commonBinaryContentType=audio/,video/,image/, application/octet-stream,application/ogg,application/ pdf,application/zip,application/gzip,application/ vnd.rar,application/x-7z-compressed #domainExclusionList=example.com,example2.com/shopping
Upload the edited
property set:Get a token to upload updates via an API request. For more information, refer to property sets.
Input:
gcloud config config-helper --force-auth-refresh --format
Output:
configuration: active_configuration: properties: compute: region: zone: core: account: disable_usage_reporting: project: credential: access_token: <Copy this value> id_token: token_expiry: sentinels: config_sentinel:Copy the
<access_token>value from the output.
Upload the
property setto Apigee:curl --silent -X GET "https://apigee.googleapis.com/v1/organizations/ <ORG>/environments/<ENVIRONMENT>/resourcefiles/ properties" -H "Authorization: Bearer <access_token from above>"
Generate Key Value Map (KVM), which stores the Cortex API key that's encrypted
curl --silent -X POST "https://apigee.googleapis.com/v1/organizations/ <ORG>/environments/<ENVIRONMENT>/keyvaluemaps" -H "Authorization: Bearer <access_token from above>" -H "Content-Type: application/json" --data-raw '{"name": "'"APISec-KVM"'", "encrypted": true}'If there's an error when creating the KVM because of an existing name, delete the KVM and recreate.
curl --silent -X DELETE "https://apigee.googleapis.com/v1/organizations/ <ORG>/environments/<ENVIRONMENT>/keyvaluemaps/ $APISEC_KVM_NAME" -H "Authorization: Bearer <access_token from above>"
Add the Cortex API key entry to the created KVM.
curl --silent -X POST "https://apigee.googleapis.com/ v1/organizations/<ORG>/environments/<ENVIRONMENT>/ keyvaluemaps/$APISEC_KVM_NAME/entries" -H "Authorization: Bearer <access_token from above>" -H "Content-Type: application/json" --data-raw '{"name": "api-key","value": "'"<Generated key from cortex env>"'"}'Upload the shared flows:
Shared flows:
sf-api-sec-extension-postflowsf-api-sec-extension-preflow
Upload
Replace the
<sf>with the shared flows:curl --silent -X POST --data-binary "<sf>.zip" -H "Content-Type: application/octet-stream" -H "Authorization: Bearer <access_token from above>" "https://apigee.googleapis.com/v1/organizations/$ORG/ sharedflows?action=import&name=<sf>"
Deploy
Input:
curl --silent -X GET "https://apigee.googleapis.com/ v1/organizations/<ORG>/sharedflows/<sf>" -H "Authorization: Bearer <access_token from above>"
Output:
{ "metaData": { "createdAt": "1736952161610", "lastModifiedAt": "1736952161610", "subType": "SharedFlow" }, "name": "sf-api-sec-extension-postflow", "revision": [ "1" // This is the revision number ], "latestRevisionId": "1" }Deploy
<sf>:curl --silent -X POST -H "Authorization: Bearer <access_token from above>" "https://apigee.googleapis.com/ v1/organizations/$ORG/environments/<ENVIRONMENT>/ sharedflows/$sf/revisions/<REVISION>/ deployments?override=true"
Verify API security shared flows were created:
Go to Apigee → Proxy development → Shared Flows and check that the following policies have been added.
sf-api-sec-extension-postflowsf-api-sec-extension-preflow
Follow the steps if you have an existing hook and would like to integrate with a shared flow.
Check for existing flow hooks.
Go to Apigee → Management → Environments and select the environment to hook the shared flow.
In the Flow Hooks tab, select the relevant flow hook.
Configure policy for shared flow to the existing hook.
Go to Apigee → Proxy development → Shared Flows and select the flow hook from the relevant environment.
Note
Start with the hook in pre-proxy.
From the Develop tab, expand Policies and select Flow Callout.
Enter a meaningful name and select the Sharedflow:
sf-api-sec-extension-preflow, and then click Create.From the Develop tab, select Shared flows and expand Default.
From Select policy, select Select existing policy, and select the policy just created and then click Add.
Repeat the previous steps for the post-proxy hook. Select the Sharedflow:
sf-api-sec-extension-postflow.Click Save and Deploy.
The steps automatically run without linking to the hooks.
Important
This should only be done when there are already existing hooks, and API security shared flows can't be hooked as a standalone. Run the deployment script, but skip step 9 by passing
n. This step publishes API security shared flows to the desired Apigee environment without setting them to flow hooks.Limitations:
The API security extension deployment scripts currently do not support archive-deployment Apigee environments. Refer to Manage archive deployment for more information.
Note
Archive deployments are currently in preview and are subject to change.
The API security extension for Apigee relies on flow-hooks, which are available only with Intermediate or Comprehensive Apigee Environment types. Refer to Environments for more information.
For requests/responses with binary payloads, the binary payload is not sent to the collector for analysis; only the metadata (for example, HTTP headers, query parameters, etc.) is sent.