Make sure that you have the following-
- Manage APIs or Activate or Deactivate API's functional privilege. If you
are an Administrator, you must have this privilege by default.
- Sample REST API file to create an API by using the importer. For example,
ConsumerAPI.
You want to enhance the security of your e-commerce API by implementing a custom security header,
X-Api-Consumer-Secret, in the incoming requests. This header must carry an API secret
key and be present in all requests. You can use this header to authorize API requests.
- Open the menu options and select APIs.
- Click Create API to create an e-commerce REST API. For example,
Consumer API.
- Select Import API from file. Click Browse
and select the ConsumerAPI file.
- Provide the following details.
- Name- ConsumerAPI
- Description- E-commerce API
- Version- 1.0
- Click Create.
- Click Edit to add the Request Transformation policy.
- Select Policies > Request Processing > Request Transformation. The
Request Transformation policy properties section appears.
- In the Condition section, select OR.
The configured transformation is applied when at least one of the conditions is
satisfied.
Note: The condition can also be set to AND operator. The configured transformation is
applied only when all the set conditions are satisfied.
- Click Add Condition to configure the conditions to evaluate the
contents on the request.
- Provide the following information.
- Variable- ${request.headers.X-API-Consumer-Secret}
- Operator- Equals
- Value- xyz
This condition checks for the presence of the X-Api-Consumer-Secret header with a specific
value. In this case, xyz.
- Click Add.
The condition to authorize the API request
is created.
- Select Transformation Configuration > Header/Query/Path
transformation.
The Header/Query/Path transformation section
appears.
- In the Add or Modify section, provide the following
information.
- Variable: X-Api-Provider-Secret
- Value: 123
- Click Add.
- Click Save.
If the condition to authorize the API
request is met, webMethods API Gateway transforms the request. webMethods API Gateway adds a new header,
X-Api-Provider-Secret with the API secret key value 123 and authorizes the API
request.