将自定义处理程序添加到特定 API wso2 API-Manager
Adding custom handler to specific API wso2 API-Manager
我需要将自定义处理程序和 APIAuthenticationHandler 添加到特定 API,并且需要将其添加到
下面
处理程序class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
(注意这里调用了两次APIAuthenticationHandler,这是自定义需求)
如何通过编辑 velocity_template.xml
以编程方式执行此操作
我正在使用 API-Manager 2.00
谢谢
您可以为此使用 API custom properties。将自定义 属性(例如 auth_mode=Inhouse
)添加到 API,然后基于此,像这样更新速度模板中的处理程序部分。
<Handlers>
#foreach($handler in $handlers)
#if(($handler.className ==
"org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler") &&
($apiObj.additionalProperties.get('auth_mode') == "Inhouse"))
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties())
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
<handler class="org.wso2.apim.custom.extensions.CustomAuthHandler"/>
<Handlers>
如果不能使用自定义属性,可以使用$!apiName
变量。
if ($!apiName.toLowerCase().endsWith("basic"))
#别的
我需要将自定义处理程序和 APIAuthenticationHandler 添加到特定 API,并且需要将其添加到
下面处理程序class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
(注意这里调用了两次APIAuthenticationHandler,这是自定义需求)
如何通过编辑 velocity_template.xml
以编程方式执行此操作我正在使用 API-Manager 2.00
谢谢
您可以为此使用 API custom properties。将自定义 属性(例如 auth_mode=Inhouse
)添加到 API,然后基于此,像这样更新速度模板中的处理程序部分。
<Handlers>
#foreach($handler in $handlers)
#if(($handler.className ==
"org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler") &&
($apiObj.additionalProperties.get('auth_mode') == "Inhouse"))
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties())
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
<handler class="org.wso2.apim.custom.extensions.CustomAuthHandler"/>
<Handlers>
如果不能使用自定义属性,可以使用$!apiName
变量。
if ($!apiName.toLowerCase().endsWith("basic")) #别的