WSO2 API Manager 1.9 - 附加固定的 header 信息

WSO2 API Manager 1.9 - Append fixed header information

我需要将固定授权 header 附加到 API 端点。这是我的端点系统的应用程序特定令牌,因此我不需要 API 订阅者输入此信息,也不想让他们知道。

之前提出了一个几乎相似的question,但没有得到答复。 文档 here 没有提供具体细节,而且有点晦涩难懂,所以我不知道如何实现这一点。有人做过吗?

感谢任何帮助,干杯!

是否要将此设置为自定义 HTTP header 并将其发送到后端?如果是,那么您可以使用 属性 中介将其设置为传输范围 属性,就在 API 的 inSequence 内的发送中介之前,如下所示。查看发送中介之前设置的 属性 Fixed-Authorization。

<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
     name="admin--Hello"
     context="/hello"
     version="1.0.0"
     version-type="url">
   <resource methods="POST GET OPTIONS DELETE PUT"
             url-mapping="/*"
             faultSequence="fault">
      <inSequence>
         <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
            <then>
            <property name="Fixed-Authorization" value="yourAppToken" scope="transport"/>
               <send>
                  <endpoint name="admin--Hello_APIproductionEndpoint_0">
                     <http uri-template="http://echo.jsontest.com/key/value/one/two"/>
                  </endpoint>
               </send>
            </then>
            <else>
               <sequence key="_sandbox_key_error_"/>
            </else>
         </filter>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </resource>
   <handlers>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
         <property name="id" value="A"/>
         <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
         <property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
   </handlers>
</api>

如果您访问 API,此 属性 将作为 HTTP header 发送到您的后端端点。更详细的解释可以参考this post

如果您只想将此应用程序令牌传递给后端(而不是作为 HTTP header),那么您可以使用 JWT 将其传递给后端。有关详细信息,请参阅 this document