Spring security Spring集成安全性与REST服务示例
我正在为REST服务实施Spring集成。我遵循XPadro的githib示例- 我创建了简单的读、写和更新操作。 示例取自Spring security Spring集成安全性与REST服务示例,spring-security,spring-integration,spring-security-oauth2,Spring Security,Spring Integration,Spring Security Oauth2,我正在为REST服务实施Spring集成。我遵循XPadro的githib示例- 我创建了简单的读、写和更新操作。 示例取自inthttpdsl项目 我想用oath2实现spring安全性。我是在参考 我无法将两者联系在一起。因为下面是他们映射请求的方式 @Bean public IntegrationFlow httpGetFlow() { return IntegrationFlows.from(httpGetGate()).channel("httpGetChann
inthttpdsl
项目
我想用oath2实现spring安全性。我是在参考
我无法将两者联系在一起。因为下面是他们映射请求的方式
@Bean
public IntegrationFlow httpGetFlow() {
return IntegrationFlows.from(httpGetGate()).channel("httpGetChannel").handle("personEndpoint", "get").get();
}
@Bean
public MessagingGatewaySupport httpGetGate() {
HttpRequestHandlingMessagingGateway handler = new HttpRequestHandlingMessagingGateway();
handler.setRequestMapping(createMapping(new HttpMethod[]{HttpMethod.GET}, "/persons/{personId}"));
handler.setPayloadExpression(parser().parseExpression("#pathVariables.personId"));
handler.setHeaderMapper(headerMapper());
return handler;
}
下面是我们如何整合安全性
@Bean
@SecuredChannel(interceptor = "channelSecurityInterceptor", sendAccess = "ROLE_ADMIN")
public SubscribableChannel adminChannel() {
return new DirectChannel();
}
在第一个示例中,我找不到创建频道的方法,所以如何集成它
我的方向是对的还是全错了?
有没有更好的教程来处理spring集成(http)和spring安全性(使用oauth)?spring集成Java DSL允许对来自流定义的消息通道使用外部
@Bean
s。因此,您的httpGetChannel
可以像以下那样声明和使用:
@Bean
@SecuredChannel(interceptor = "channelSecurityInterceptor", sendAccess = "ROLE_ADMIN")
public SubscribableChannel httpGetChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow httpGetFlow() {
return IntegrationFlows.from(httpGetGate())
.channel(httpGetChannel())
.handle("personEndpoint", "get")
.get();
}
请随意提出GitHub问题,以便直接从DSL的
.channel()
定义中在框架中使某些内容更加明显:您可以在Http.inboundGateway上使用此注释吗?什么注释<代码>@SecuredChannel?查看其用途:它只能在MessageChannel
bean上使用:我知道您可以将预授权与RequestMapping一起放在RestController端点上。您能在Http.InboundGateway或IntegrationFlow上实现同样的功能吗?好的。看起来你的请求与这个SO线程无关。请考虑增加一个新的信息。像这样在这里聊天会让社区感到困惑。好的,谢谢你会想一想。。。我想我需要弄清楚我想问什么lol