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.

Prerequisites

  • Must know how to write RAML and publishing it to Exchange
  • Must be familiar with Anypoint Studio
  • Must be familiar with Anypoint Platform

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.

  1. Designing API Specifications using Design Center
  2. Application implementation using Anypoint Studio
  3. Creating an API using API Manager
  4. Requesting Access to the API using Exchange
  5. Applying a Policy using API Manager

Details of each part are given below.

Designing API Specifications Using Design Center

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

Step-by-Step Guide on How to Apply Client ID Enforcement Policy in Mule 4
2.90 GEEK