Skip to content

Commit ff5d805

Browse files
authored
Merge branch 'develop' into feature/#52-editUserProfile-cw
2 parents e40e4b7 + e4ac922 commit ff5d805

4 files changed

Lines changed: 49 additions & 13 deletions

File tree

.github/workflows/cd.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636
chmod +x ./gradlew
3737
chmod +x ./scripts/deploy.sh
3838
39+
- name: Replace application.properties secrets
40+
run: |
41+
sed -i "s|\${MYSQL_URL}|${{ secrets.MYSQL_URL }}|g" src/main/resources/application.properties
42+
sed -i "s|\${MYSQL_USERNAME}|${{ secrets.MYSQL_USERNAME }}|g" src/main/resources/application.properties
43+
sed -i "s|\${MYSQL_PASSWORD}|${{ secrets.MYSQL_PASSWORD }}|g" src/main/resources/application.properties
44+
sed -i "s|\${JWT_KEY}|${{ secrets.JWT_KEY }}|g" src/main/resources/application.properties
45+
3946
- name: Build with Gradle
4047
run: ./gradlew clean build -x test
4148

@@ -48,10 +55,10 @@ jobs:
4855

4956
- name: Create .env file from GitHub secrets
5057
run: |
51-
echo "mysql_url=${{ secrets.mysql_url }}" >> .env
52-
echo "mysql_username=${{ secrets.mysql_username }}" >> .env
53-
echo "mysql_password=${{ secrets.mysql_password }}" >> .env
54-
echo "jwt_key=${{ secrets.jwt_key }}" >> .env
58+
echo "MYSQL_URL=${{ secrets.MYSQL_URL }}" >> .env
59+
echo "MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }}" >> .env
60+
echo "MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> .env
61+
echo "JWT_KEY=${{ secrets.JWT_KEY }}" >> .env
5562
5663
- name: Prepare deployment package
5764
run: |

src/main/java/com/example/FixLog/config/SecurityConfig.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.example.FixLog.repository.MemberRepository;
44
import com.example.FixLog.util.JwtUtil;
5+
import com.example.FixLog.config.JwtAuthenticationFilter;
56
import jakarta.servlet.Filter;
67
import lombok.RequiredArgsConstructor;
78
import org.springframework.context.annotation.Bean;
@@ -10,6 +11,7 @@
1011
import org.springframework.security.authentication.AuthenticationManager;
1112
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
1213
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
14+
import org.springframework.security.config.Customizer;
1315
import org.springframework.security.web.SecurityFilterChain;
1416
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1517
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -26,10 +28,12 @@ public class SecurityConfig {
2628
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
2729
http
2830
.csrf(csrf -> csrf.disable())
31+
.cors(Customizer.withDefaults()) // CORS 설정 추가 (WebConfig와 연결됨)
2932
.authorizeHttpRequests(auth -> auth
30-
// 비로그인 허용 경로
33+
.requestMatchers(HttpMethod.GET, "/auth/**").permitAll()
34+
.requestMatchers(HttpMethod.POST, "/auth/**").permitAll()
35+
3136
.requestMatchers(HttpMethod.POST, "/members/signup").permitAll()
32-
.requestMatchers(HttpMethod.POST, "/auth/login").permitAll()
3337
.requestMatchers(HttpMethod.GET, "/members/check-email").permitAll()
3438
.requestMatchers(HttpMethod.GET, "/members/check-nickname").permitAll()
3539
.requestMatchers(HttpMethod.GET, "/search/**").permitAll()
@@ -39,6 +43,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3943
// 배포 확인용 임시 허용
4044
.requestMatchers(HttpMethod.GET, "/test", "/test/**").permitAll()
4145
// 그 외 모든 요청은 인증 필요
46+
.requestMatchers(HttpMethod.GET, "/test", "/test/**").permitAll() // 테스트용 허용
47+
4248
.anyRequest().authenticated()
4349
)
4450
.headers(headers -> headers.frameOptions(frame -> frame.disable())) // H2 콘솔
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.example.FixLog.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
5+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6+
7+
@Configuration
8+
public class WebConfig implements WebMvcConfigurer {
9+
10+
@Override
11+
public void addCorsMappings(CorsRegistry registry) {
12+
registry.addMapping("/**") // 모든 경로에 대해
13+
.allowedOriginPatterns("*") // 모든 도메인 허용 (개발용) → 배포 시 정확한 프론트 주소로 수정 권장
14+
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
15+
.allowedHeaders("*")
16+
.allowCredentials(true); // 인증정보(쿠키, Authorization) 허용
17+
}
18+
}
19+

src/main/resources/application.properties

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ spring.application.name=FixLog
1717
##### dev #####
1818
server.port=8083
1919

20-
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
21-
#spring.datasource.url=${mysql_url}
22-
#spring.datasource.username=${mysql_username}
23-
#spring.datasource.password=${mysql_password}
20+
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
21+
spring.datasource.url=${MYSQL_URL}
22+
spring.datasource.username=${MYSQL_USERNAME}
23+
spring.datasource.password=${MYSQL_PASSWORD}
24+
2425

2526
spring.datasource.url=jdbc:mysql://fixlog-db.c7cau8y2srl7.ap-northeast-2.rds.amazonaws.com:3306/fixlog?serverTimezone=Asia/Seoul
2627
spring.datasource.username=admin
@@ -37,7 +38,10 @@ cloud.aws.credentials.secret-key=${AWS_SECRET_ACCESS_KEY}
3738
cloud.aws.region.static=${AWS_REGION}
3839
cloud.aws.s3.bucket=${AWS_S3_BUCKET}
3940

40-
##### jwt #####
41-
jwt.secret=${jwt_key}
4241

43-
logging.level.org.springframework.security=DEBUG
42+
spring.jwt.secret=${JWT_KEY}
43+
44+
# 로그 레벨 설정
45+
logging.level.root=INFO
46+
logging.level.com.example.FixLog=DEBUG
47+
logging.file.name=logs/app.log

0 commit comments

Comments
 (0)