hotfix/#245 CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경#246
hotfix/#245 CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경#246
Conversation
Walkthrough스테이징 배포 워크플로우에서 SSH 인증 방식을 비밀번호에서 키 기반으로 변경했고, 애플리케이션 보안 설정의 CORS 허용 오리진 목록을 갱신했습니다. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Test Coverage Report
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## develop #246 +/- ##
==========================================
Coverage 91.42% 91.42%
Complexity 159 159
==========================================
Files 49 49
Lines 455 455
Branches 9 9
==========================================
Hits 416 416
Misses 29 29
Partials 10 10 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
aics-common/src/main/java/kgu/developers/common/config/SecurityConfig.java (3)
103-104: 포트 제거로 기존 8080 오리진이 CORS에서 거부될 수 있습니다.
http://203.249.22.207로 변경되면서 8080 포트에서 오는 요청(http://203.249.22.207:8080)은 매칭되지 않을 수 있습니다. allowedOriginPatterns는 정확 매칭(또는 와일드카드 패턴 매칭) 기준이라 포트가 다르면 다른 오리진으로 간주됩니다. 실제 접속 포트가 8080이라면 아래처럼 8080을 함께 허용하거나, 포트 와일드카드 패턴을 사용하는 방안을 고려해주세요.가능한 보수적 수정(8080 명시):
"http://203.249.22.207", + "http://203.249.22.207:8080", "http://13.125.230.147"대안(와일드카드 패턴 사용 — 프레임워크 버전에 따라 지원 여부 확인 필요):
"http://203.249.22.207:*"실제로 어떤 포트(80, 8080, 3000 등)에서 접근하는지 운영 환경을 한번 더 확인 부탁드립니다.
90-107: CORS 설정 강화 제안: 메서드 제한, Exposed-Headers, 프리플라이트 캐시
- 메서드: "*" 대신 필요 메서드만 허용해 표면적을 줄이는 것이 좋습니다.
- Exposed-Headers: 클라이언트에서 Authorization/Location 등을 읽어야 한다면 노출 필요.
- maxAge: 프리플라이트 결과를 캐시해 불필요한 OPTIONS 트래픽 감소.
- config.setAllowedMethods(Collections.singletonList("*")); + config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")); + config.setExposedHeaders(Arrays.asList("Authorization", "Location", "Link")); + config.setMaxAge(3600L);만약 응답에 Authorization 헤더를 포함하지 않는다면 Exposed-Headers는 생략해도 됩니다.
92-105: 허용 오리진 하드코딩 → 환경/배포별 설정 외부화 권장여러 IP/도메인을 코드에 하드코딩하면 환경 변경 시 재배포가 필요합니다. application.yml (또는 환경 변수)로 외부화해 운영 편의성과 안전성을 높이는 것을 권장합니다.
예시:
- application.yml
cors: allowed-origin-patterns: - http://localhost:3000 - https://aics-admin.ummdev.com - https://aics-client-dev.vercel.app - http://203.249.22.207 - http://203.249.22.207:8080 - http://13.125.230.147
- 구성 코드
@Value("#{'${cors.allowed-origin-patterns}'.split(',')}") private List<String> allowedOriginPatterns; CorsConfiguration config = new CorsConfiguration(); config.setAllowedOriginPatterns(allowedOriginPatterns);또는 @ConfigurationProperties를 사용해 타입 세이프하게 주입하는 방법도 좋습니다.
.github/workflows/staging-build-deploy.yml (2)
43-52: SSH 키 전환 잘하셨습니다. 호스트 키 검증(fingerprint)도 활성화해 MITM 위험을 줄여주세요.현재는 서버 신뢰성 검증 설정이 없어(기본값 의존) MITM 공격에 취약할 수 있습니다. 서버의 SSH 호스트 키 지문을 Secrets로 관리하고, 각 액션에
fingerprint를 추가하는 것을 권장합니다. 키가 암호화(Passphrase)되어 있다면passphrase입력도 함께 지정해야 합니다.- name: Upload Docker images to server uses: appleboy/scp-action@v1.0.0 with: host: ${{ secrets.STAGING_SERVER_HOST }} username: ${{ secrets.STAGING_SERVER_USERNAME }} key: ${{ secrets.STAGING_SERVER_KEY }} + fingerprint: ${{ secrets.STAGING_SERVER_FINGERPRINT }} port: ${{ secrets.STAGING_SERVER_PORT }} source: "deploy/*" target: ${{ secrets.STAGING_DEPLOY_PATH }}- name: Deploy on server uses: appleboy/ssh-action@v1.1.0 with: host: ${{ secrets.STAGING_SERVER_HOST }} username: ${{ secrets.STAGING_SERVER_USERNAME }} key: ${{ secrets.STAGING_SERVER_KEY }} + fingerprint: ${{ secrets.STAGING_SERVER_FINGERPRINT }} port: ${{ secrets.STAGING_SERVER_PORT }} script: | cd ${{ secrets.STAGING_DEPLOY_PATH }} chmod +x backend/deploy.sh ./backend/deploy.sh추가 확인 사항:
- Private key가 passphrase로 보호되어 있으면:
passphrase: ${{ secrets.STAGING_SERVER_KEY_PASSPHRASE }}입력 추가 필요.- 기존 비밀번호 기반 시크릿(
STAGING_SERVER_PASSWORD)은 사용 중지/삭제 권장.- 최초 연결 시 호스트 키 지문 값을 정확히 채택했는지 확인 부탁드립니다.
Also applies to: 53-64
1-10: 동시 실행으로 배포가 겹치는 것을 방지하기 위해 concurrency 그룹 추가를 권장합니다.수동 트리거(workflow_dispatch)라도 실수로 여러 번 실행하면 배포 경합이 발생할 수 있습니다. 아래처럼 그룹을 정의해 중복 실행을 방지할 수 있습니다.
YAML 상단에 추가:
concurrency: group: staging-deploy cancel-in-progress: true
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.github/workflows/staging-build-deploy.yml(2 hunks)aics-common/src/main/java/kgu/developers/common/config/SecurityConfig.java(1 hunks)
Summary
CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경
Tasks