Skip to content

hotfix/#245 CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경#246

Merged
LeeHanEum merged 2 commits intodevelopfrom
fix/#245-ssh-pem
Aug 19, 2025
Merged

hotfix/#245 CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경#246
LeeHanEum merged 2 commits intodevelopfrom
fix/#245-ssh-pem

Conversation

@LeeHanEum
Copy link
Copy Markdown
Member

Summary

CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경

Tasks

  • CORS 추가 및 GitHub Actions AWS 접근 시 pem key로 접근하도록 변경

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

스테이징 배포 워크플로우에서 SSH 인증 방식을 비밀번호에서 키 기반으로 변경했고, 애플리케이션 보안 설정의 CORS 허용 오리진 목록을 갱신했습니다.

Changes

Cohort / File(s) Change Summary
CI/CD: Staging Deploy Workflow
.github/workflows/staging-build-deploy.yml
scp/ssh 액션의 인증을 password에서 key(secrets.STAGING_SERVER_KEY)로 변경. 기타 호스트/계정/포트/소스/타깃/스크립트는 동일.
Security: CORS 설정
aics-common/src/main/java/kgu/developers/common/config/SecurityConfig.java
허용 오리진에서 http://203.249.22.207:8080http://203.249.22.207로 교체하고 http://13.125.230.147 추가. 다른 설정 및 시그니처 변경 없음.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

🐞bug

Suggested reviewers

  • minjo-on
  • LeeShinHaeng

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#245-ssh-pem

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

Test Coverage Report

Overall Project 94.32% 🍏

There is no coverage information present for the Files changed

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c23aa85...f73c117. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LeeHanEum LeeHanEum added the 🐞bug Something isn't working label Aug 19, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between c23aa85 and f73c117.

📒 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)

Copy link
Copy Markdown
Contributor

@JangYeongHu JangYeongHu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍👍

@LeeHanEum LeeHanEum merged commit 68c2a70 into develop Aug 19, 2025
5 checks passed
@LeeHanEum LeeHanEum deleted the fix/#245-ssh-pem branch August 19, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open SSH 접속 PEM 키를 사용한 방식으로 GitHub Actions 스크립트 변경

2 participants