1

我正在实施Spring Integration for REST服务。我遵循XPadro的githib示例 - https://github.com/xpadro/spring-integrationSpring集成安全性与REST服务示例

我已经创建了简单的读取,写入和更新操作。 示例取自int-http-dsl项目。

我想用誓言来实现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-integration(http)与spring-security(使用oauth)?

回答

1

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

相关问题