Skip to content

Commit 13045fe

Browse files
committed
[Fix]: 배포 관련 환경변수 수정 및 jwt필터 수정
1 parent 94c3a3b commit 13045fe

File tree

3 files changed

+86
-6
lines changed

3 files changed

+86
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ jobs:
235235
--restart unless-stopped \
236236
--network "${NET}" \
237237
-e TZ=Asia/Seoul \
238-
-v /bid_data:/data \
238+
-e SPRING_DATA_REDIS_PASSWORD="${SPRING_DATA_REDIS_PASSWORD}" \
239+
-e JWT_SECRET="${JWT_SECRET}" \
240+
-e SPRING_DATASOURCE_URL___DB_NAME="${SPRING_DATASOURCE_URL___DB_NAME}" \
241+
-v /bid_data:/data \1
239242
"${IMAGE}"
240243
241244
# ---------------------------------------------------------

src/main/java/com/backend/global/security/JwtAuthenticationFilter.java

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
2828
@Override
2929
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
3030

31-
// 테스트 API는 JWT 검증 건너뛰기
3231
String path = request.getRequestURI();
33-
if (path.startsWith("/api/v1/bids/") || path.startsWith("/notifications/") || path.startsWith("/api/test/")) {
32+
String method = request.getMethod();
33+
34+
// JWT 검증을 건너뛸 경로들
35+
if (shouldSkipFilter(path, method)) {
3436
filterChain.doFilter(request, response);
3537
return;
3638
}
@@ -55,4 +57,79 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
5557

5658
filterChain.doFilter(request, response);
5759
}
60+
61+
private boolean shouldSkipFilter(String path, String method) {
62+
// 정적 리소스
63+
if (path.startsWith("/static/") || path.startsWith("/public/") ||
64+
path.startsWith("/resources/") || path.startsWith("/META-INF/resources/")) {
65+
return true;
66+
}
67+
68+
// 토스 페이먼트 관련
69+
if (path.equals("/billing.html") || path.startsWith("/payments/") || path.startsWith("/toss/")) {
70+
return true;
71+
}
72+
73+
// 공개 API
74+
if (path.equals("/") || path.equals("/favicon.ico") ||
75+
path.startsWith("/h2-console/") || path.equals("/actuator/health")) {
76+
return true;
77+
}
78+
79+
// 인증 API
80+
if (path.startsWith("/api/v1/auth/")) {
81+
return true;
82+
}
83+
84+
// Swagger 및 API 문서
85+
if (path.startsWith("/swagger-ui/") || path.startsWith("/v3/api-docs/") ||
86+
path.equals("/swagger-ui.html") || path.startsWith("/webjars/")) {
87+
return true;
88+
}
89+
90+
// WebSocket 및 알림
91+
if (path.startsWith("/notifications/") || path.startsWith("/ws/")) {
92+
return true;
93+
}
94+
95+
// 테스트 API
96+
if (path.startsWith("/api/test/") || path.equals("/bid-test.html") ||
97+
path.equals("/websocket-test.html")) {
98+
return true;
99+
}
100+
101+
// GET 요청 중 공개 API
102+
if ("GET".equals(method)) {
103+
// 상품 조회 API
104+
if (path.matches("/api/[^/]+/products") ||
105+
path.matches("/api/[^/]+/products/\\d+") ||
106+
path.matches("/api/[^/]+/products/es") ||
107+
path.matches("/api/[^/]+/products/members/\\d+") ||
108+
path.matches("/api/[^/]+/products/es/members/\\d+")) {
109+
return true;
110+
}
111+
112+
// 회원 조회 API
113+
if (path.matches("/api/v1/members/\\d+")) {
114+
return true;
115+
}
116+
}
117+
118+
// 업로드 파일
119+
if (path.startsWith("/uploads/")) {
120+
return true;
121+
}
122+
123+
// 테스트 데이터 API
124+
if (path.matches("/api/[^/]+/test-data/.*")) {
125+
return true;
126+
}
127+
128+
// 입찰 API (기존 로직 유지)
129+
if (path.startsWith("/api/v1/bids/")) {
130+
return true;
131+
}
132+
133+
return false;
134+
}
58135
}

src/main/resources/application-prod.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring:
22
datasource:
3-
url: "jdbc:mysql://mysql_1:3306/${SPRING__DATASOURCE__URL___DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul"
3+
url: "jdbc:mysql://mysql_1:3306/${SPRING_DATASOURCE_URL___DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul"
44
username: lldjlocal
55
password: 1234
66
driver-class-name: com.mysql.cj.jdbc.Driver
@@ -15,12 +15,12 @@ spring:
1515
data:
1616
redis:
1717
host: redis_1
18-
password: ${SPRING__DATA__REDIS__PASSWORD}
18+
password: ${SPRING_DATA_REDIS_PASSWORD}
1919

2020
elasticsearch:
2121
uris: http://elasticsearch_1:9200
2222
username: elastic
23-
password: ${SPRING__DATA__REDIS__PASSWORD}
23+
password: ${SPRING_DATA_REDIS_PASSWORD}
2424

2525
jwt:
2626
secret: ${JWT_SECRET}

0 commit comments

Comments
 (0)