Spring 集成安全与 REST 服务示例
Spring Integration Security with REST service example
我正在实施 Spring REST 服务集成。我正在关注 XPadro 的 githib 示例 - https://github.com/xpadro/spring-integration.
我创建了简单的读取、写入和更新操作。
示例取自 int-http-dsl
项目。
我想用 oath2 实现 spring-security。我参考了 http://docs.spring.io/spring-integration/reference/html/security.html.
我无法将两者连接在一起。因为下面是他们如何映射请求
@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
用于流定义中的消息通道。因此,您的 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()
定义中变得更加明显:https://github.com/spring-projects/spring-integration-java-dsl/issues
我正在实施 Spring REST 服务集成。我正在关注 XPadro 的 githib 示例 - https://github.com/xpadro/spring-integration.
我创建了简单的读取、写入和更新操作。
示例取自 int-http-dsl
项目。
我想用 oath2 实现 spring-security。我参考了 http://docs.spring.io/spring-integration/reference/html/security.html.
我无法将两者连接在一起。因为下面是他们如何映射请求
@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
用于流定义中的消息通道。因此,您的 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()
定义中变得更加明显:https://github.com/spring-projects/spring-integration-java-dsl/issues