4.2.3. 在 JSON 配置文件中创建 3scale 策略链

如果使用 APIcast 的原生部署,您可以创建一个 JSON 配置文件来控制外部的策略链。

JSON 配置文件策略链包含一个由以下信息组成的 JSON 数组:

  • 带有 id 值的 services 对象,指定策略链按编号应用到哪个服务
  • proxy 对象,其中包含 policy_chain 对象和后续对象
  • policy_chain 对象,其中包含定义策略链的值
  • 单独的 policy 对象,用于指定策略和配置策略所需的 nameconfiguration 数据

以下是自定义策略 sample_policy_1 和 API 内省标准策略 token_introspection 的策略链示例:

{
  "services":[
    {
      "id":1,
      "proxy":{
        "policy_chain":[
          {
            "name":"sample_policy_1", "version": "1.0",
            "configuration":{
              "sample_config_param_1":["value_1"],
              "sample_config_param_2":["value_2"]
            }
          },
          {
            "name": "token_introspection", "version": "builtin",
            "configuration": {
              introspection_url:["https://tokenauthorityexample.com"],
              client_id:["exampleName"],
              client_secret:["secretexamplekey123"]
          },
          {
             "name": "apicast", "version": "builtin",
          }
        ]
      }
    }
  ]
}

所有策略链必须包含内置策略 apicast。在策略链中放置 apicast 策略会影响策略行为。