【发布时间】:2020-07-22 14:09:28
【问题描述】:
我知道可以将 @PreAuthorize 注释添加到 Rest Controller...
@RestController
public class WebController {
@PreAuthorize("hasAuthority('Foo')")
@GetMapping("/restricted")
public ResponseEntity<String> restricted() {
return ResponseEntity.ok("Restricted section");
}
}
如何预授权对 Spring Integration Http.inbound 网关的访问?我知道我可以在集成流中添加一个组件,并在转换器或服务激活器方法上添加注释,但我宁愿没有单独的对象。
@Bean
//@PreAuthorize("hasAuthority('Foo')") ?
public HttpRequestHandlingMessagingGateway restrictedGateway() {
return Http.inboundGateway("/restricted")
...
.get();
}
@Bean
public IntegrationFlow myFlow(HttpRequestHandlingMessagingGateway restrictedGateway) {
return IntegrationFlows
.from(restrictedGateway)
.transform(source -> "Restricted section")
.get();
}
【问题讨论】:
-
在流程中的网关之后是否需要一个中间“securedChannel”来实现这一点?
标签: spring-security spring-integration spring-integration-dsl spring-integration-http