In this tutorial you will learn how to protect your API Proxy with the “Verify API Key” Policy. This policy allows you to add a simple protection via a so called API Key. Only calls which send a valid API Key along with the main request will be allowed to call the API Proxy.
Step 1: Learn about the API call flow
It is important to understanding the API policy flow so you gain an understanding of why a policy is applied at a certain time in the flow. For instance, access policies should be verified before the API call to reduce using resources unnecessarily. The entire request/response cycle is divided up, first into segments, then within each segment, into processing stages.
Step 2: Learn about the Policy Editor
Step 3: Learn about how to assign a policy to a proxy
Step 4: Learn about assigning multiple policies
Step 5: Access the SAP API Management API Portal
Open the SAP API Management API Portal (you can get the URL from Enable the SAP Cloud Platform, API Management Service.
Step 6: View created APIs
From the Hamburger Menu in the upper left corner and click on Develop.
Step 7: Select an API
Select the API GWSAMPLE_BASIC
created in a previous step in the this tutorial series.
Step 8: View API Policies
In the upper right corner click on Policies to open the policy information for the API.
Step 9: Open the edit page for policies
In the Policy Editor, click on Edit.
Step 10: Edit the PreFlow policies
Select the PreFlow
from the ProxyEndpoint
on the left hand side.
Step 11: Add Verify API Key policy
On the right hand, find the Security Policies section under the Policies pane. Find the Verify API Key policy and click the + next to the policy name.
Step 12: Enter policy name
Enter the Policy Name CheckAPIKey
and click on Add.
Step 13: Update API Key tag
In the Code Editor found in the bottom pane, look for the <APIKey ... />
tag. Replace the string variable_containing_api_key
with request.header.APIKey
.
Step 14: Update and save changes
Click on Update to apply the new policies.
Click on Save to save the changes to the API and enforce the new policies.
Optional
- When you now open the API Proxy in a browser you will get an error message stating that you need to pass an API Key in the header
APIKey
.
Next Steps