我知道可以将 @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();
}