This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/3_0_X by this push:
     new cd601aa627 Working around 
https://github.com/spring-projects/spring-framework/issues/33789
cd601aa627 is described below

commit cd601aa6270dbe1ecf46acbf1c62b264296caf7a
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Fri Nov 8 14:58:51 2024 +0100

    Working around 
https://github.com/spring-projects/spring-framework/issues/33789
---
 .../org/apache/syncope/sra/SecurityConfig.java     | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java 
b/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
index 5d486b7cd7..617fe42809 100644
--- a/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
+++ b/sra/src/main/java/org/apache/syncope/sra/SecurityConfig.java
@@ -49,11 +49,14 @@ import org.springframework.cache.CacheManager;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
 import org.springframework.core.annotation.Order;
 import org.springframework.core.convert.converter.Converter;
 import org.springframework.core.io.FileUrlResource;
 import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
 import 
org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
 import org.springframework.security.config.web.server.ServerHttpSecurity;
 import 
org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
@@ -76,12 +79,34 @@ import 
org.springframework.security.web.server.SecurityWebFilterChain;
 import 
org.springframework.security.web.server.util.matcher.NegatedServerWebExchangeMatcher;
 import 
org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
 import 
org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
+import org.springframework.web.server.WebFilter;
 import reactor.core.publisher.Mono;
 
 @EnableWebFluxSecurity
 @Configuration(proxyBeanMethods = false)
 public class SecurityConfig {
 
+    /**
+     * Workaround for 
https://github.com/spring-projects/spring-framework/issues/33789
+     *
+     * @return web filter with writable HTTP headers
+     */
+    @Bean
+    @Order(Ordered.HIGHEST_PRECEDENCE)
+    public WebFilter writeableHeaders() {
+        return (exchange, chain) -> {
+            HttpHeaders writeableHeaders = 
HttpHeaders.writableHttpHeaders(exchange.getRequest().getHeaders());
+            ServerHttpRequestDecorator writeableRequest = new 
ServerHttpRequestDecorator(exchange.getRequest()) {
+
+                @Override
+                public HttpHeaders getHeaders() {
+                    return writeableHeaders;
+                }
+            };
+            return 
chain.filter(exchange.mutate().request(writeableRequest).build());
+        };
+    }
+
     @Bean
     @Order(0)
     @ConditionalOnProperty(prefix = SRAProperties.PREFIX, name = 
SRAProperties.AM_TYPE, havingValue = "SAML2")

Reply via email to