In this step-by-step guide, we are demonstrating exact steps of how Client ID Enforcement Policy can be applied in Mule4 using Autodiscovery and API Manager.
There are five parts in this tutorial. After completing all of these parts, we will end up having a Client ID Enforcement Policy implemented on the API.
Details of each part are given below.
Create RAML in Design Center with a single Get resource and a client-id-enforcement trait
Client-id-enforcement trait includes client_id and client_secret to be filled in headers of request.
YAML
#%RAML 1.0
title: client-id-enforcement-project
description: client-id-enforcement-project
version: v1
baseUri: https://localhost/{version}
protocols: [ HTTP, HTTPS ]
mediaType: application/json
documentation:
- title: client-id-enforcement-project documentation
content: some documentation
traits:
client-id-required:
headers:
client_id:
type: string
description: Client ID provided by API Manager
required: true
client_secret:
type: string
description: Client Secret provided by API Manager
required: true
/getCustomer:
get:
is: client-id-required
description: |
Get Customer by passing customer_id
queryParameters:
customer_id:
displayName: customer_id
type: integer
description: Customer ID
example: 12345
required: true
responses:
200:
body:
application/json:
400:
body:
application/json:
500:
body:
application/json:
Publish that RAML in Exchange.
#deployment #mule 4 #raml #anypoint platform #cloudhub #api manager