[英]WSO2 ESB Mediation Retrieve user attributes (claims) in inSequence
我已经在API Publisher中发布了API。 该API有POST方法confirm
,它与这样的参数检索JSON数据:userUUID,APPNAME,版本。 在API Publisher中,此API仅采用两个参数:appName和version。
我不想从客户端发送userUUID,但我想以inSequence从accessToken(在用户声明中)检索userUUID,并将其作为新参数添加到发送的JSON中,然后将其全部发送到后端。
可能吗? 也许我至少可以从accessToken检索用户电子邮件?
我看到两种将用户信息传递到后端的方法。
一种是JWT令牌。 在api-manager.xml中,您可以使用声明检索器启用JWT令牌生成。 JWT令牌将作为HTTP标头发送到后端服务
按照顺序,您可以调用管理服务之一(请参阅https://docs.wso2.com/display/AM210/WSO2+Admin+Services )以获取分配的用户和应用程序
请参阅https:// localhost:9443 / services / OAuth2TokenValidationService?wsdl和validate或buildIntrospectionResponse操作
希望对您有所帮助
我发现了从https:// localhost:9443 / oauth2 / userinfo?schema = openid获取用户信息的解决方法
首先,变化值RemoveOAuthHeadersFromOutMessage
在OAuthConfigurations
文件[WSO2_AM]/repository/conf/api-manager.xml
其次,应该在服务提供商的WSO2 API Manager Carbon Server中配置从https://localhost:9443/oauth2/userinfo?schema=openid
获得的用户声明。
算法:
body_of_zero_call
urlPostfixZero
?schema=openid
为请求目标REST API方法 { "status": "Can't get user info"}
user_uuid
)从响应主体复制到属性user_uuid_first_call
body_of_zero_call
复制到主体 urlPostfixZero
复制源请求目标REST API方法以请求目标REST API方法 userUUID
添加到请求正文 userUUID
身体与属性值user_uuid_first_call
调解员:
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="token_to_user_uuid" trace="disable">
<!-- 1 -->
<enrich>
<source clone="true" type="body" />
<target action="child" property="body_of_zero_call" type="property" />
</enrich>
<!-- 2 -->
<property expression="$axis2:REST_URL_POSTFIX" name="urlPostfixZero" scope="default" type="STRING" />
<!-- 3 -->
<property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value="?schema=openid" />
<!-- 4 -->
<call blocking="true">
<endpoint>
<http method="get" trace="disable" uri-template="https://localhost:9443/oauth2/userinfo" />
</endpoint>
</call>
<!-- 5 -->
<filter regex="200" source="get-property('axis2', 'HTTP_SC')">
<then>
<!-- 6 -->
<property expression="$body//jsonObject//user_uuid" name="user_uuid_first_call" scope="default" type="STRING" />
<!-- 7 -->
<enrich>
<source clone="true" property="body_of_zero_call" type="property" />
<target type="body" />
</enrich>
<!-- 8 -->
<property expression="get-property('urlPostfixZero')" name="REST_URL_POSTFIX" scope="axis2" type="STRING" />
<!-- 9 -->
<enrich>
<source clone="true" type="inline">
<userUUID xmlns="" />
</source>
<target action="child" xpath="$body//jsonObject" />
</enrich>
<!-- 10 -->
<enrich>
<source clone="true" property="user_uuid_first_call" type="property" />
<target xpath="$body//jsonObject//userUUID" />
</enrich>
<!-- 11 -->
<call blocking="true">
<endpoint>
<http method="post" trace="disable" uri-template="https://localhost:9444/customAuth/services/regulations" />
</endpoint>
</call>
<!-- 12 -->
<respond />
</then>
<else>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500" />
<payloadFactory media-type="json">
<format>{ "status": "Can't get user info"}</format>
<args />
</payloadFactory>
<respond />
</else>
</filter>
</sequence>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.