Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -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
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions src/main/java/com/team4/giftidea/configuration/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: '여자친구', '남자친구')
Expand Down