[fix] prod 프로파일에서 lazy-initialization 제거로 SecurityFilterChain 미등록 문제 해결#190
Conversation
prod 프로파일에 설정된 spring.main.lazy-initialization=true 때문에 사용자 정의 SecurityFilterChain 빈이 lazy 초기화되어, Spring Boot의 SpringBootWebSecurityConfiguration이 @ConditionalOnMissingBean(SecurityFilterChain.class) 평가 시 빈을 감지하지 못하고 폴백 보안(inMemoryUserDetailsManager + HTTP Basic + CSRF)을 활성화. 결과적으로 우리 SecurityConfig의 permitAll 설정이 무시되어 /api/auth/* 경로가 모두 403을 반환했음. 메모리 스파이크 완화 의도는 lazy-init이 아닌 Hibernate plan cache 한도 / Tomcat 스레드 한도 / OSIV 비활성화 등으로 후속 대응한다.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
요약프로덕션 환경의 Spring Boot 설정에서 변경 사항Spring Security 설정 복원
예상 코드 리뷰 시간🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔖 관련 GitHub Issue
📝 변경 사항
주요 변경 내용
application-prod.properties에서spring.main.lazy-initialization=true설정 제거상세 설명
문제
2026-05-14 09:32 KST 프로덕션 EC2 재배포 이후, 모바일 앱의 카카오 로그인 및 Dev 로그인이 모두 실패. EC2에서 직접
curl로 호출해도 모든/api/auth/*엔드포인트가 빈 본문 403을 반환. 부팅 로그에 결정적 신호가 출력됨:→ Spring Boot가 우리
SecurityFilterChain빈을 감지하지 못하고 폴백 보안(HTTP Basic +inMemoryUserDetailsManager+ CSRF on)을 활성화한 상태. 결과적으로SecurityConfig의permitAll()설정이 무시되어 모든 POST 요청이 403.원인
application-prod.properties에 prod 전용으로 설정되어 있던:spring.main.lazy-initialization=true이 설정 때문에 사용자 정의
SecurityFilterChain빈이 lazy 초기화 상태로 등록되며, Spring Boot의SpringBootWebSecurityConfiguration이@ConditionalOnDefaultWebSecurity(=@ConditionalOnMissingBean(SecurityFilterChain.class)) 평가 시점에 사용자 정의 빈의 존재를 감지하지 못해 폴백 보안 체인을 활성화함.해당 설정은
application.properties/application-local.properties에는 없고 prod에만 존재했기 때문에 로컬에서는 정상 동작하고 프로덕션에서만 재현되었음.해결
prod 프로파일에서
spring.main.lazy-initialization=true설정을 제거.SecurityConfig.java등 코드는 변경하지 않음(코드 자체는 정상).원래 lazy-init을 도입한 의도(시작 시 Hibernate 6 ANTLR4 파서 메모리 스파이크 방지)는 별도 옵션으로 대응할 수 있도록 주석에 안내를 남김:
hibernate.query.plan_cache_max_size,plan_parameter_metadata_max_size)server.tomcat.threads.max,accept-count)spring.jpa.open-in-view=false)배포 후 EC2 staging에서 실제 메모리 스파이크가 관측되면 위 옵션들로 별도 PR 대응 예정.
✅ 체크리스트
./gradlew test --tests PayCheckApplicationTestsBUILD SUCCESSFUL)🔗 관련 PR
🧪 검증
자동 검증
배포 후 수동 검증
폴백 로그 부재 확인
로그인 동작 재현
인증 보호 경로
curl -i http://localhost:8080/api/users/me # → 401 + ApiResponse.error JSON (403 아님, JwtAuthenticationFilter 응답)🤖 Generated with Claude Code
Summary by CodeRabbit
버그 수정