|
20 | 20 |
|
21 | 21 | import com.fasterxml.jackson.databind.ObjectMapper; |
22 | 22 | import com.google.common.base.Strings; |
23 | | -import de.rwth.idsg.steve.SteveProdCondition; |
24 | 23 | import de.rwth.idsg.steve.web.api.ApiControllerAdvice; |
25 | 24 | import lombok.extern.slf4j.Slf4j; |
26 | | -import org.springframework.beans.factory.annotation.Qualifier; |
27 | 25 | import org.springframework.context.annotation.Bean; |
28 | | -import org.springframework.context.annotation.Conditional; |
29 | 26 | import org.springframework.context.annotation.Configuration; |
30 | 27 | import org.springframework.core.annotation.Order; |
31 | 28 | import org.springframework.http.HttpStatus; |
|
34 | 31 | import org.springframework.security.authentication.DisabledException; |
35 | 32 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
36 | 33 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
37 | | -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; |
38 | 34 | import org.springframework.security.config.http.SessionCreationPolicy; |
39 | 35 | import org.springframework.security.core.Authentication; |
40 | 36 | import org.springframework.security.core.AuthenticationException; |
|
52 | 48 | import jakarta.servlet.ServletException; |
53 | 49 | import jakarta.servlet.http.HttpServletRequest; |
54 | 50 | import jakarta.servlet.http.HttpServletResponse; |
| 51 | + |
55 | 52 | import java.io.IOException; |
56 | 53 |
|
57 | 54 | import static de.rwth.idsg.steve.SteveConfiguration.CONFIG; |
|
63 | 60 | @Slf4j |
64 | 61 | @Configuration |
65 | 62 | @EnableWebSecurity |
66 | | -@Conditional(SteveProdCondition.class) |
67 | 63 | public class SecurityConfiguration { |
68 | 64 |
|
69 | 65 | /** |
@@ -99,10 +95,15 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti |
99 | 95 | .requestMatchers( |
100 | 96 | "/static/**", |
101 | 97 | CONFIG.getCxfMapping() + "/**", |
| 98 | + WebSocketConfiguration.PATH_INFIX + "**", |
102 | 99 | "/WEB-INF/views/**" // https://github.com/spring-projects/spring-security/issues/13285#issuecomment-1579097065 |
103 | 100 | ).permitAll() |
104 | 101 | .requestMatchers(prefix + "/**").hasRole("ADMIN") |
105 | 102 | ) |
| 103 | + // SOAP stations are making POST calls for communication. even though the following path is permitted for |
| 104 | + // all access, there is a global default behaviour from spring security: enable CSRF for all POSTs. |
| 105 | + // we need to disable CSRF for SOAP paths explicitly. |
| 106 | + .csrf(c -> c.ignoringRequestMatchers(CONFIG.getCxfMapping() + "/**")) |
106 | 107 | .sessionManagement( |
107 | 108 | req -> req.invalidSessionUrl(prefix + "/signin") |
108 | 109 | ) |
|
0 commit comments