Nav

To Create the Custom Policy Definition File

In this procedure, you create a YAML file that contains the policy definition file. Next, to filter calls to the API, the policy definition includes a query parameter and a regular expression to filter the query parameter. Unmatched requests are rejected. Properties map to the elements in the UI when you apply the policy. At the end of this procedure, you can download the complete file.

  1. Open a new text file, and define the required properties for a policy in Anypoint Platform.

  2. Add the resourceLevelSupported: true property if you run Mule 3.8.1 or later. This property supports resource level policies.

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    id: query-param-filter
    name: Query Param Filter
    description: Filters query parameters
    category: Security
    type: custom
    standalone: true
    requiresConnectivity: false
    resourceLevelSupported: true
    providedCharacteristics: []
    requiredCharacteristics: []
  3. Add a configuration element and two propertyName fields having the values regexFilter and queryParam.

  4. Add properties to define the regular expression to filter the parameter and to name and define the query parameter that must be evaluated.

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    id: query-param-filter
    name: Query Param Filter
    description: Filters query parameters
    category: Security
    type: custom
    standalone: true
    requiresConnectivity: false
    resourceLevelSupported: true
    providedCharacteristics: []
    requiredCharacteristics: []
    configuration:
      - propertyName: regexFilter
        name: Regex Filter
        description: A regular expression to filter a query parameter. Rejects unmatched requests.
        type: string
        defaultValue:
        optional: true
        sensitive: false
        allowMultiple: false
      - propertyName: queryParam
        name: Query Parameter
        description: Name of a query parameter to filter by a regular expression.
        type: string
        defaultValue:
        optional: false
        sensitive: false
        allowMultiple: false
  5. Save the file using a .yaml extension. For example, save the file as mypolicy.yaml.

In this topic: