获取本地进入基本授权的内容属性
Get content of local-entry into Basic Authorization property
我正在使用 esb 作为中介,基本上将 rest 转换为 soap。我正在调用的 soap 是安全的,因此我需要授权 属性。我使用此服务没有问题:
<resource methods="GET" uri-template="/getAllZones">
<inSequence>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"></property>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"></property>
<payloadFactory media-type="xml">
<format>
<zon:GetAllZones xmlns:zon="http://someUrl.xsd">
<Filter></Filter>
</zon:GetAllZones>
</format>
<args></args>
</payloadFactory>
<send>
<endpoint key="myEndpoint"></endpoint>
</send>
<log level="full"></log>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
<send></send>
</outSequence>
</resource>
但我想将用户和密码存储为 ESB 中的本地条目。我试过这个:
<property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode(get-property('user'):get-property('password')))" scope="transport"></property>
但它不起作用。有任何想法吗?
提前致谢
您可以将您的值存储在注册表中。然后使用带有范围注册表的 get-属性 访问它们。
例如,如果您在 conf:/creds/user
中存储了一些注册表资源并且它具有属性用户名和密码,您可以使用以下方式访问它们:
get-property('registry', 'conf:/creds/user@username')
和 get-property('registry', 'conf:/creds/user@password')
例如,为了访问属性设置如下:
你会使用类似这样的东西:
<inSequence>
<log level="custom">
<property name="Username" expression="get-property('registry', 'conf:/user@username')"/>
<property name="Password" expression="get-property('registry', 'conf:/user@password')"/>
<property name="Encoded" expression="fn:concat('Basic ', base64Encode(fn:concat(get-property('registry', 'conf:/user@username'), ':', get-property('registry', 'conf:/user@username'))))"/>
</log>
<respond/>
</inSequence>
但您可能要考虑对密码进行加密。在这种情况下,您应该使用 ESB 内的安全保险库。您可以使用别名 {wso2:vault-lookup('user')}
访问安全保险库中的内容。
https://docs.wso2.com/display/ESB490/Working+with+Passwords 中有更多详细信息。
我正在使用 esb 作为中介,基本上将 rest 转换为 soap。我正在调用的 soap 是安全的,因此我需要授权 属性。我使用此服务没有问题:
<resource methods="GET" uri-template="/getAllZones">
<inSequence>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"></property>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"></property>
<payloadFactory media-type="xml">
<format>
<zon:GetAllZones xmlns:zon="http://someUrl.xsd">
<Filter></Filter>
</zon:GetAllZones>
</format>
<args></args>
</payloadFactory>
<send>
<endpoint key="myEndpoint"></endpoint>
</send>
<log level="full"></log>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
<send></send>
</outSequence>
</resource>
但我想将用户和密码存储为 ESB 中的本地条目。我试过这个:
<property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode(get-property('user'):get-property('password')))" scope="transport"></property>
但它不起作用。有任何想法吗? 提前致谢
您可以将您的值存储在注册表中。然后使用带有范围注册表的 get-属性 访问它们。
例如,如果您在 conf:/creds/user
中存储了一些注册表资源并且它具有属性用户名和密码,您可以使用以下方式访问它们:
get-property('registry', 'conf:/creds/user@username')
和 get-property('registry', 'conf:/creds/user@password')
例如,为了访问属性设置如下:
你会使用类似这样的东西:
<inSequence>
<log level="custom">
<property name="Username" expression="get-property('registry', 'conf:/user@username')"/>
<property name="Password" expression="get-property('registry', 'conf:/user@password')"/>
<property name="Encoded" expression="fn:concat('Basic ', base64Encode(fn:concat(get-property('registry', 'conf:/user@username'), ':', get-property('registry', 'conf:/user@username'))))"/>
</log>
<respond/>
</inSequence>
但您可能要考虑对密码进行加密。在这种情况下,您应该使用 ESB 内的安全保险库。您可以使用别名 {wso2:vault-lookup('user')}
访问安全保险库中的内容。
https://docs.wso2.com/display/ESB490/Working+with+Passwords 中有更多详细信息。