diff --git a/scripts/start.sh b/scripts/start.sh index 72d52de..7aa4c32 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -29,6 +29,6 @@ TIME_NOW=$(date +%c) echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE -# jar 파일 실행 +# jar 파일 실행 (prod 프로필 적용) echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG -nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & \ No newline at end of file +nohup java -jar $JAR_FILE --spring.profiles.active=prod > $APP_LOG 2> $ERROR_LOG & diff --git a/src/main/java/com/pitchain/common/aspect/GeneralExceptionLoggingAspect.java b/src/main/java/com/pitchain/common/aspect/GeneralExceptionLoggingAspect.java index bc7c137..2baddd9 100644 --- a/src/main/java/com/pitchain/common/aspect/GeneralExceptionLoggingAspect.java +++ b/src/main/java/com/pitchain/common/aspect/GeneralExceptionLoggingAspect.java @@ -35,7 +35,7 @@ public void logAfterThrowing(JoinPoint joinPoint, GeneralException exception) { ErrorStatus errorStatus = exception.getErrorStatus(); MDC.put("httpStatus", String.valueOf(errorStatus.getHttpStatus())); - log.error("[ERROR] POINT : {} || EXCEPTION : {} || ARGUMENTS : {}", + log.error("[ERROR] POINT : {} || ERROR CODE : {} || ARGUMENTS : {}", className, errorStatus.getCode(), parameterMessage ); log.error("[ERROR] FINAL POINT : {}", exception.getStackTrace()[0]); diff --git a/src/main/java/com/pitchain/common/aspect/UnintendedExceptionLoggingAspect.java b/src/main/java/com/pitchain/common/aspect/UndefinedExceptionLoggingAspect.java similarity index 98% rename from src/main/java/com/pitchain/common/aspect/UnintendedExceptionLoggingAspect.java rename to src/main/java/com/pitchain/common/aspect/UndefinedExceptionLoggingAspect.java index 2c9b7d5..15cb9ef 100644 --- a/src/main/java/com/pitchain/common/aspect/UnintendedExceptionLoggingAspect.java +++ b/src/main/java/com/pitchain/common/aspect/UndefinedExceptionLoggingAspect.java @@ -25,7 +25,7 @@ @Aspect @RequiredArgsConstructor @Component -public class UnintendedExceptionLoggingAspect { +public class UndefinedExceptionLoggingAspect { private final DiscordWebhookSender discordWebhookSender; diff --git a/src/main/java/com/pitchain/common/config/SecurityConfig.java b/src/main/java/com/pitchain/common/config/SecurityConfig.java index d5401cc..f993746 100644 --- a/src/main/java/com/pitchain/common/config/SecurityConfig.java +++ b/src/main/java/com/pitchain/common/config/SecurityConfig.java @@ -7,6 +7,7 @@ import com.pitchain.common.filter.JwtAuthenticationFilter; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; @@ -36,10 +37,28 @@ public class SecurityConfig { private final JwtAuthenticationFilter jwtAuthenticationFilter; private final RoleRequestCollector roleRequestCollector; - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); - } + @Value("#{'${spring.cors.allowed-origins}'.replaceAll(' ', '').split(',')}") + private List allowedOrigins; + + private static final String[] SWAGGER_PATTERNS = { + "/swagger-ui/**", + "/v3/api-docs/**", + }; + + private static final String[] STATIC_RESOURCES_PATTERNS = { + "/img/**", + "/css/**", + "/js/**", + "/favicon.ico", + }; + + private static final String[] PUBLIC_ENDPOINTS = { + "/health-check", // health check + "/oauth**", + "/members/tokens", "/members/emails", // 공통 유저 + "/companies", "/companies/login", // 회사 + "/dev/**", // 개발용 + }; @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { @@ -68,31 +87,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http.build(); } - private static final String[] SWAGGER_PATTERNS = { - "/swagger-ui/**", - "/v3/api-docs/**", - }; - - private static final String[] STATIC_RESOURCES_PATTERNS = { - "/img/**", - "/css/**", - "/js/**", - "/favicon.ico", - }; - - private static final String[] PUBLIC_ENDPOINTS = { - "/health-check", // health check - "/oauth**", - "/members/tokens", "/members/emails", // 공통 유저 - "/companies", "/companies/login", // 회사 - "/dev/**", // 개발용 - }; - @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); - config.setAllowedOrigins(List.of("http://localhost:5173")); + config.setAllowedOrigins(allowedOrigins); config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")); config.setAllowedHeaders(List.of("*")); config.setExposedHeaders(Arrays.asList("Authorization", "Authorization-Refresh")); @@ -127,4 +126,9 @@ private static void writeErrorResponse(HttpServletResponse response, String mess response.setCharacterEncoding("UTF-8"); response.getWriter().write(new ObjectMapper().writeValueAsString(customResponse)); } + + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 5b9adf5..5e8a810 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,6 +9,8 @@ spring: fallback-to-system-locale: false encoding: UTF-8 cache-duration: 3600 + cors: + allowed-origins: ${CORS_ALLOWED_ORIGINS} datasource: master: driver-class-name: ${MASTER_DATASOURCE_DRIVER_CLASS_NAME} @@ -28,7 +30,6 @@ spring: host: ${REDIS_HOST} port: ${REDIS_PORT} channel: ${REDIS_CHANNEL} - cloud: aws: s3: