Skip to content

Commit bdefd8a

Browse files
authored
Deprecate spring-integration-security module
The `SecurityContextPropagationChannelInterceptor` has been migrated to `spring-security-messaging`. Since it was only the class in the `spring-integration-security`, it is now fully considered as deprecated * Remove all the tests from `spring-integration-security` * Modify `HttpDslTests` to demonstrate the `spring-security-messaging` in action which has been replaced with whatever there was in `spring-integration-security` * Remove redundant `exclude group: 'org.springframework'` for security dependencies in `build.gradle` since all of them rely on the same SF deps as SI
1 parent 87a2ac5 commit bdefd8a

File tree

12 files changed

+48
-907
lines changed

12 files changed

+48
-907
lines changed

Diff for: build.gradle

+7-19
Original file line numberDiff line numberDiff line change
@@ -702,14 +702,10 @@ project('spring-integration-http') {
702702
optionalApi "com.rometools:rome:$romeToolsVersion"
703703
optionalApi 'org.springframework:spring-webflux'
704704

705-
testImplementation project(':spring-integration-security')
706705
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
707-
testImplementation('org.springframework.security:spring-security-config') {
708-
exclude group: 'org.springframework'
709-
}
710-
testImplementation('org.springframework.security:spring-security-test') {
711-
exclude group: 'org.springframework'
712-
}
706+
testImplementation 'org.springframework.security:spring-security-messaging'
707+
testImplementation 'org.springframework.security:spring-security-config'
708+
testImplementation 'org.springframework.security:spring-security-test'
713709
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
714710

715711
testRuntimeOnly "com.jayway.jsonpath:json-path:$jsonpathVersion"
@@ -916,13 +912,9 @@ project('spring-integration-security') {
916912
description = 'Spring Integration Security Support'
917913
dependencies {
918914
api project(':spring-integration-core')
919-
api('org.springframework.security:spring-security-messaging') {
920-
exclude group: 'org.springframework'
921-
}
915+
api 'org.springframework.security:spring-security-messaging'
922916

923-
testImplementation('org.springframework.security:spring-security-config') {
924-
exclude group: 'org.springframework'
925-
}
917+
testImplementation 'org.springframework.security:spring-security-config'
926918
}
927919
}
928920

@@ -1017,12 +1009,8 @@ project('spring-integration-webflux') {
10171009
testImplementation "jakarta.servlet:jakarta.servlet-api:$servletApiVersion"
10181010
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
10191011
testImplementation 'org.springframework:spring-webmvc'
1020-
testImplementation('org.springframework.security:spring-security-config') {
1021-
exclude group: 'org.springframework'
1022-
}
1023-
testImplementation('org.springframework.security:spring-security-test') {
1024-
exclude group: 'org.springframework'
1025-
}
1012+
testImplementation 'org.springframework.security:spring-security-config'
1013+
testImplementation 'org.springframework.security:spring-security-test'
10261014
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
10271015
testImplementation 'io.micrometer:micrometer-observation-test'
10281016
testImplementation('io.micrometer:micrometer-tracing-integration-test') {

Diff for: spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java

+25-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@
3636
import org.springframework.http.client.ClientHttpResponse;
3737
import org.springframework.integration.channel.DirectChannel;
3838
import org.springframework.integration.channel.FixedSubscriberChannel;
39+
import org.springframework.integration.channel.QueueChannel;
3940
import org.springframework.integration.config.EnableIntegration;
41+
import org.springframework.integration.dsl.DirectChannelSpec;
4042
import org.springframework.integration.dsl.IntegrationFlow;
43+
import org.springframework.integration.dsl.MessageChannels;
44+
import org.springframework.integration.dsl.QueueChannelSpec;
4145
import org.springframework.integration.dsl.context.IntegrationFlowContext;
4246
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
4347
import org.springframework.integration.http.multipart.UploadedMultipartFile;
4448
import org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler;
49+
import org.springframework.integration.scheduling.PollerMetadata;
4550
import org.springframework.messaging.Message;
46-
import org.springframework.messaging.MessageChannel;
4751
import org.springframework.messaging.PollableChannel;
4852
import org.springframework.messaging.support.ErrorMessage;
4953
import org.springframework.mock.web.MockPart;
@@ -56,6 +60,7 @@
5660
import org.springframework.security.core.userdetails.UserDetailsService;
5761
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
5862
import org.springframework.security.messaging.access.intercept.AuthorizationChannelInterceptor;
63+
import org.springframework.security.messaging.context.SecurityContextPropagationChannelInterceptor;
5964
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
6065
import org.springframework.security.web.SecurityFilterChain;
6166
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
@@ -330,21 +335,33 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
330335
.build();
331336
}
332337

338+
@Bean(PollerMetadata.DEFAULT_POLLER)
339+
PollerMetadata pollerMetadata() {
340+
return new PollerMetadata();
341+
}
342+
343+
@Bean
344+
public QueueChannelSpec securityPropagationChannel() {
345+
return MessageChannels.queue()
346+
.interceptor(new SecurityContextPropagationChannelInterceptor());
347+
}
348+
333349
@Bean
334-
public MessageChannel transformSecuredChannel() {
335-
DirectChannel directChannel = new DirectChannel();
336-
directChannel.addInterceptor(
337-
new AuthorizationChannelInterceptor(AuthorityAuthorizationManager.hasRole("ADMIN")));
338-
return directChannel;
350+
public DirectChannelSpec transformSecuredChannel() {
351+
return MessageChannels.direct()
352+
.interceptor(new AuthorizationChannelInterceptor(AuthorityAuthorizationManager.hasRole("ADMIN")));
339353
}
340354

341355
@Bean
342-
public IntegrationFlow httpInternalServiceFlow() {
356+
public IntegrationFlow httpInternalServiceFlow(QueueChannel securityPropagationChannel,
357+
DirectChannel transformSecuredChannel) {
358+
343359
return IntegrationFlow
344360
.from(Http.inboundGateway("/service/internal")
345361
.requestMapping(r -> r.params("name"))
346362
.payloadExpression("#requestParams.name"))
347-
.channel(transformSecuredChannel())
363+
.channel(securityPropagationChannel)
364+
.channel(transformSecuredChannel)
348365
.<List<String>, String>transform(p -> p.get(0).toUpperCase())
349366
.get();
350367
}

Diff for: spring-integration-security/src/main/java/org/springframework/integration/security/channel/SecurityContextPropagationChannelInterceptor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2019 the original author or authors.
2+
* Copyright 2015-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,10 @@
4343
* @since 4.2
4444
*
4545
* @see ThreadStatePropagationChannelInterceptor
46+
*
47+
* @deprecated since 6.2 in favor of {@link org.springframework.security.messaging.context.SecurityContextPropagationChannelInterceptor}
4648
*/
49+
@Deprecated(since = "6.2", forRemoval = true)
4750
public class SecurityContextPropagationChannelInterceptor
4851
extends ThreadStatePropagationChannelInterceptor<Authentication> {
4952

Diff for: spring-integration-security/src/test/java/org/springframework/integration/security/SecurityTestUtils.java

-56
This file was deleted.

Diff for: spring-integration-security/src/test/java/org/springframework/integration/security/TestHandler.java

-36
This file was deleted.

Diff for: spring-integration-security/src/test/java/org/springframework/integration/security/channel/ChannelAdapterSecurityIntegrationTests-context.xml

-67
This file was deleted.

0 commit comments

Comments
 (0)