5.6. 创建策略链 JSON 配置文件

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

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

  • 带有 id 值的 services 对象,用于指定策略链按照数字应用到哪个服务
  • proxy 对象,其中包含 policy_chain 和后续对象
  • policy_chain 对象,其中包含定义策略链的值
  • 需要指定了 nameconfiguration 的独立 policy 对象,用于识别策略和配置策略的行为

以下是自定义策略 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 置于策略链中的位置将影响策略行为。