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.
2 changes: 1 addition & 1 deletion .github/workflows/main-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:

- name: Clean up
if: success()
run: rm -f private_key.pem
run: rm -f private_key.pem
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