WSO2 APIM 2.0 是否可以自定义或重定向到 /token url
WSO2 APIM 2.0 Is it possible to customize or redirect to the /token url
我正在将我的 APIs 从旧系统迁移到 WSO2 APIM 2.0.0,并试图让我的 API 用户可以透明地进行切换。我已经迁移了现有的 consumer_key/secrets.
是否可以将 /token API 自定义为其他内容?
在我的旧系统中,OAuth 令牌是通过如下路径管理的
/oauth/client_credential/accesstoken
也许可以将 /oauth/client_credential/accesstoken 映射到 /token 以便两者都可以使用?
如果您只想更改 /token 的基本路径 api,您可以在 api 管理器前使用一些反向代理(例如 nginx)或创建一个代理 api 在 api 管理器本身内部像这样。
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken">
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_">
<inSequence>
<property name="uri.var.portnum" expression="get-property('https.nio.port')"/>
<send>
<endpoint>
<http uri-template="https://localhost:{uri.var.portnum}/token">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
<handlers/>
</api>
您需要将其复制到 <APIM_HOME>/repository/deployment/server/synapse-configs/default/api/_WSO2AMTokenAPIProxy_.xml
Bhathiya 建议的解决方案有效,只需调整代理端点
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken">
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_">
<inSequence>
<send>
<endpoint>
<http uri-template="http://127.0.0.1:8280/token">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
我正在将我的 APIs 从旧系统迁移到 WSO2 APIM 2.0.0,并试图让我的 API 用户可以透明地进行切换。我已经迁移了现有的 consumer_key/secrets.
是否可以将 /token API 自定义为其他内容?
在我的旧系统中,OAuth 令牌是通过如下路径管理的 /oauth/client_credential/accesstoken
也许可以将 /oauth/client_credential/accesstoken 映射到 /token 以便两者都可以使用?
如果您只想更改 /token 的基本路径 api,您可以在 api 管理器前使用一些反向代理(例如 nginx)或创建一个代理 api 在 api 管理器本身内部像这样。
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken">
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_">
<inSequence>
<property name="uri.var.portnum" expression="get-property('https.nio.port')"/>
<send>
<endpoint>
<http uri-template="https://localhost:{uri.var.portnum}/token">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
<handlers/>
</api>
您需要将其复制到 <APIM_HOME>/repository/deployment/server/synapse-configs/default/api/_WSO2AMTokenAPIProxy_.xml
Bhathiya 建议的解决方案有效,只需调整代理端点
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken">
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_">
<inSequence>
<send>
<endpoint>
<http uri-template="http://127.0.0.1:8280/token">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>