fix : batch에서 BO호출할 수 있도록 security 수정

This commit is contained in:
jazz
2026-01-14 15:21:01 +09:00
parent 73690055e2
commit eee0e423f8
5 changed files with 91 additions and 28 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.wb.domainserver.security.config;
import com.wb.domainserver.common.prop.PropertyService;
import com.wb.domainserver.domain.sopmal.oauth.service.CustomOAuth2UserService;
import com.wb.domainserver.exception.response.CustomOauthFailureException;
import com.wb.domainserver.realm.RealmResolver;
@@ -23,6 +24,7 @@ import com.wb.domainserver.response.CustomAuthenticationSuccessHandler;
import com.wb.domainserver.security.authentication.CustomAccessDeniedEntryPoint;
import com.wb.domainserver.security.authentication.CustomAuthenticationEntryPoint;
import com.wb.domainserver.security.authorization.WnbtAuthorizationManager;
import com.wb.domainserver.security.filter.BatchFilter;
import com.wb.domainserver.security.filter.CustomXssFilter;
import com.wb.domainserver.security.filter.JwtAuthenticationFilter;
import com.wb.domainserver.security.handler.CustomLogoutSuccessHandler;
@@ -55,7 +57,7 @@ import java.util.stream.Collectors;
import static org.springframework.beans.factory.config.BeanDefinition.ROLE_INFRASTRUCTURE;
@EnableWebSecurity(debug = false)
@EnableWebSecurity(debug = true)
@Configuration
//@EnableMethodSecurity
public class ResourceServerConfig {
@@ -113,7 +115,7 @@ public class ResourceServerConfig {
OrRequestMatcher resourceMatchers = new OrRequestMatcher(resourcePath);
return http
.securityMatcher("/sopmal/**", "/oauth2/**", "/login/oauth2/**","/file/*")
.securityMatcher("/*", "/sopmal/**", "/oauth2/**", "/login/oauth2/**","/file/*") ///gcone/** #배치호출처리
.headers((headers)->headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin))
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorize ->
@@ -205,6 +207,26 @@ public class ResourceServerConfig {
.build();
}
@Bean
@Order(3)
SecurityFilterChain batchSecurityFilterChain(HttpSecurity http, SecurityPathProperties securityProperties) throws Exception {
List<RequestMatcher> uriList = securityProperties.getBatch().getUri().stream()
.map(AntPathRequestMatcher::new)
.collect(Collectors.toList());
OrRequestMatcher uri = new OrRequestMatcher(uriList);
return http
.securityMatcher(uri)
.headers((headers)->headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin))
.csrf(AbstractHttpConfigurer::disable)
.addFilterBefore(new BatchFilter(securityProperties), RequestCacheAwareFilter.class) /*batch 호출된 주소 확인 후 주소가 아니면 제외*/
.exceptionHandling(exceptions -> exceptions
.accessDeniedHandler(accessDeniedEntryPoint)
)
.build();
}
//
// private String customBearerTokenResolver(HttpServletRequest request) {
// String authorization = request.getHeader("Authorization");