Upgrade dependencies to the latest snapshots
* Fix HTTP & WebFlux for a new CORS logic when `*` pattern is used together with `allowCredentials` * Fix RSocket module for deprecated API in SF * The deprecated RMI API is left for the upcoming changes
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.integration.http.inbound;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -175,10 +176,19 @@ public final class IntegrationRequestMappingHandlerMapping extends RequestMappin
|
||||
for (RequestMethod requestMethod : crossOrigin.getMethod()) {
|
||||
config.addAllowedMethod(requestMethod.name());
|
||||
}
|
||||
config.setAllowedOrigins(Arrays.asList(crossOrigin.getOrigin()));
|
||||
config.setAllowedHeaders(Arrays.asList(crossOrigin.getAllowedHeaders()));
|
||||
config.setExposedHeaders(Arrays.asList(crossOrigin.getExposedHeaders()));
|
||||
config.setAllowCredentials(crossOrigin.getAllowCredentials());
|
||||
Boolean allowCredentials = crossOrigin.getAllowCredentials();
|
||||
config.setAllowCredentials(allowCredentials);
|
||||
List<String> allowedOrigins = Arrays.asList(crossOrigin.getOrigin());
|
||||
if (Boolean.TRUE.equals(allowCredentials)
|
||||
&& CollectionUtils.contains(allowedOrigins.iterator(), CorsConfiguration.ALL)) {
|
||||
config.setAllowedOriginPatterns(allowedOrigins);
|
||||
}
|
||||
else {
|
||||
config.setAllowedOrigins(allowedOrigins);
|
||||
}
|
||||
|
||||
if (crossOrigin.getMaxAge() != -1) {
|
||||
config.setMaxAge(crossOrigin.getMaxAge());
|
||||
}
|
||||
|
||||
@@ -85,7 +85,8 @@ public class CrossOriginTests {
|
||||
CorsConfiguration config = getCorsConfiguration(chain, false);
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "GET" });
|
||||
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins()).isNull();
|
||||
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getExposedHeaders()).isEmpty();
|
||||
@@ -116,7 +117,8 @@ public class CrossOriginTests {
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "GET" });
|
||||
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins()).isNull();
|
||||
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getExposedHeaders()).isEmpty();
|
||||
@@ -133,7 +135,8 @@ public class CrossOriginTests {
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins()).isNull();
|
||||
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
assertThat(config.getExposedHeaders()).isNull();
|
||||
@@ -149,7 +152,8 @@ public class CrossOriginTests {
|
||||
CorsConfiguration config = getCorsConfiguration(chain, true);
|
||||
assertThat(config).isNotNull();
|
||||
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedOrigins()).isNull();
|
||||
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
|
||||
assertThat(config.getAllowCredentials()).isTrue();
|
||||
assertThat(config.getExposedHeaders()).isNull();
|
||||
|
||||
Reference in New Issue
Block a user