diff --git "a/.github/workflows/\bdevelop-ci.yml" b/.github/workflows/develop-ci.yml similarity index 100% rename from ".github/workflows/\bdevelop-ci.yml" rename to .github/workflows/develop-ci.yml diff --git a/.github/workflows/main-cd.yml b/.github/workflows/main-cd.yml index 21a87f9..56c5a30 100644 --- a/.github/workflows/main-cd.yml +++ b/.github/workflows/main-cd.yml @@ -68,4 +68,4 @@ jobs: - name: Clean up if: success() - run: rm -f private_key.pem + run: rm -f private_key.pem \ No newline at end of file diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 95a3759..84c852e 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties index a13904a..8bfd2aa 100644 --- a/.gradle/buildOutputCleanup/cache.properties +++ b/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Sat Feb 01 15:47:18 KST 2025 -gradle.version=8.4 +#Fri Feb 07 20:37:40 KST 2025 +gradle.version=8.10 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 659777e..8a2a32d 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index 7bd6729..9395b2d 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/build.gradle b/build.gradle index cbd1b84..bf18560 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,11 @@ dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' + implementation 'org.springframework.boot:spring-boot-starter-security' + // Testing testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.security:spring-security-test' } tasks.named('test') { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f86..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 6689b85..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/com/team4/giftidea/configuration/SecurityConfig.java b/src/main/java/com/team4/giftidea/configuration/SecurityConfig.java new file mode 100644 index 0000000..0662e75 --- /dev/null +++ b/src/main/java/com/team4/giftidea/configuration/SecurityConfig.java @@ -0,0 +1,84 @@ +package com.team4.giftidea.configuration; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import java.util.List; + +/** + * Spring Security 및 CORS 설정을 담당하는 설정 클래스입니다. + */ +@Configuration +public class SecurityConfig { + + /** + * HTTP 보안 설정을 구성하는 Bean입니다. + * + * - CORS 설정 적용 + * - CSRF 보호 비활성화 (JWT 사용 시 필요) + * - 특정 경로 보호 및 기본 요청 허용 설정 + * + * @param http Spring Security의 HTTP 보안 설정 객체 + * @return SecurityFilterChain 보안 필터 체인 + * @throws Exception 설정 과정에서 발생할 수 있는 예외 + */ + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http + // CORS 설정 적용 + .cors(cors -> cors.configurationSource(corsConfigurationSource())) + + // CSRF 보호 비활성화 (JWT 인증을 사용하는 경우 필요) + .csrf(csrf -> csrf.disable()) + + // 접근 제어 설정 + .authorizeHttpRequests(auth -> auth + .requestMatchers("/admin/**").authenticated() // "/admin/**" 경로는 인증 필요 + .anyRequest().permitAll() // 나머지 요청은 인증 없이 허용 + ); + + return http.build(); + } + + /** + * CORS 설정을 구성하는 Bean입니다. + * + * - 허용할 도메인(origin) 설정 + * - 허용할 HTTP 메서드(GET, POST 등) 지정 + * - 허용할 헤더 설정 + * - 쿠키 포함 요청 허용 + * + * @return CorsConfigurationSource CORS 설정 객체 + */ + @Bean + public CorsConfigurationSource corsConfigurationSource() { + CorsConfiguration configuration = new CorsConfiguration(); + + // 허용할 출처(Origin) 설정 + configuration.setAllowedOrigins(List.of( + "http://localhost:3000", // 로컬 개발 환경 + "https://presentalk.store", // 프론트엔드 배포 주소 + "https://app.presentalk.store" // 백엔드 API 주소 + )); + + // 허용할 HTTP 메서드 설정 + configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS")); + + // 허용할 요청 헤더 설정 + configuration.setAllowedHeaders(List.of("*")); // 모든 헤더 허용 + + // 쿠키 포함 요청 허용 + configuration.setAllowCredentials(true); + + // CORS 설정을 특정 경로에 적용 + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", configuration); // 모든 경로에 적용 + + return source; + } +} diff --git a/src/main/java/com/team4/giftidea/controller/GptController.java b/src/main/java/com/team4/giftidea/controller/GptController.java index 297aee0..612f6b1 100644 --- a/src/main/java/com/team4/giftidea/controller/GptController.java +++ b/src/main/java/com/team4/giftidea/controller/GptController.java @@ -38,14 +38,6 @@ public GptController(RestTemplate restTemplate, GptConfig gptConfig, ProductServ this.productService = productService; } - /** - * @param file 전송된 파일 (카카오톡 대화 내용) - * @param targetName 대상 이름 (ex: '여자친구', '남자친구') - * @param relation 관계 (ex: 'couple', 'friend', etc.) - * @param sex 대상 성별 ('male' 또는 'female') - * @param theme 선물의 주제 (ex: 'birthday', 'valentine', etc.) - * @return 추천된 상품 목록 - */ /** * @param file 전송된 파일 (카카오톡 대화 내용) * @param targetName 대상 이름 (ex: '여자친구', '남자친구')