在我的Spring项目(使用Security使用基本授权)中,我试图访问主体对象以读取用户名。
这是入站网关的结构:
<int-http:inbound-gateway request-channel="gatewayRequests"
reply-channel="gatewayResponses"
supported-methods="POST"
path="/api/v1/myservice"
request-payload-type="java.lang.String" reply-timeout="100">
<int-http:request-mapping consumes="application/xml" produces="application/xml"/>
<int-http:header name="principal" expression="T(org.springframework.security.core.context.SecurityContextHolder).context.authentication.principal"/>
</int-http:inbound-gateway>
我从答复中得到了上述表达式:Spring Integration and http inbound adapter, how do I extract a principal user?
尽管身份验证成功,但我没有看到主体--我的语法是否正确地期望将表达式的结果映射到消息头?
与到标头的映射不同,如果我要使用以下内容,如何访问代码层中的主体值(假设它被添加到有效负载中)?
<payload-
expression="T(org.springframework.security.core.context.SecurityContextHolder).
context.authentication.principal">
有人能帮帮我吗?
真诚的,Bharath
发布于 2017-10-05 22:14:20
已经有一个标题,如:
.setHeader(org.springframework.integration.http.HttpHeaders.USER_PRINCIPAL,
servletRequest.getUserPrincipal())在发送给gatewayRequests的消息中。
为什么这对你不管用?
OTOH这个表达式也必须有效。如果你没有那个,你就不能假设你的身份验证是正确的.
https://stackoverflow.com/questions/46594965
复制相似问题