Skip to content

feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2 - #207

Merged
PHJ2000 merged 37 commits into
mainfrom
feat/PB-104-congestionclient-lambda-url-sigv4
Apr 28, 2026
Merged

PHJ2000 merged 37 commits into
mainfrom
feat/PB-104-congestionclient-lambda-url-sigv4

Conversation

@geonusp

@geonusp geonusp commented Mar 28, 2026 •

Copy link
Copy Markdown
Collaborator

✨ Feature PR

🔗 이슈 링크 (필수)

PR 제목: feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2


🧩 이 PR의 변경사항 (필수)

전체 중 위치 (Stacked PR 시)

이 PR에서 변경한 것

  • CongestionClient에 AWS SigV4 인증 적용: Lambda Function URL 호출 시 AwsSigV4Interceptor로 요청 서명
  • AwsSigV4Interceptor: Content-Length·Transfer-Encoding을 canonical request에서 제외해 SignatureDoesNotMatch 수정
  • AwsSigV4Interceptor: 빈 safe method(GET/HEAD/OPTIONS/TRACE)에는 body stream을 붙이지 않도록 수정, 디버그 로그에 signing scope/핵심 헤더 추가(민감 정보
    마스킹)
  • AwsConfig: app.aws.profile 지정 시 ProfileCredentialsProvider, 미지정 시 DefaultCredentialsProvider를 사용하도록 정리
  • AwsConfig / application.yml: CONGESTION_SIGV4_ENABLED 기반 NoOp 인터셉터 분기 추가, app.aws.profile 환경변수 바인딩 추가
  • build.gradle: AWS SDK v2 sso, ssooidc 의존성 추가로 SSO 프로파일 자격증명 로드 지원
  • 테스트: AwsSigV4InterceptorTest, AwsConfigTest 보강
  • 가이드/트러블슈팅 문서 추가:
    • docs/guides/aws-credentials-setup.md
    • docs/troubleshooting/lambda-function-url-sigv4-signature-mismatch.md
    • docs/troubleshooting/aws-sso-credentials-spring.md
  • 다이어그램 추가:
    • docs/diagrams/sigv4-content-length-bug.md
    • docs/diagrams/sigv4-diagnostics-structure.md

✅ 이 PR이 커버하는 AC (필수)

Covers (이 PR에서 완료)

  • AC1: SignatureDoesNotMatch 수정 — Lambda Function URL GET 요청이 403 없이 정상 응답
  • AC3: 진단 도구 활성화 시 signed→spring→apache 레이어별 헤더 스냅샷이 WARN 로그로 출력됨

Not covered (후속 작업)


🧪 테스트 결과 (필수)

로컬

./gradlew test
  • ✅/❌ 결과: ✅

CI

  • (자동 첨부)

Smoke 테스트

  • 시나리오:
  • 결과:

🧭 영향 범위 체크 (필수)

  • API 변경 (요약: )
  • DB 변경 (마이그레이션: )
  • 설정 변경 (항목: )
  • Breaking change (무엇: )

💬 리뷰 포인트 (필수)

  • 집중해서 볼 파일/라인:
    • AwsSigV4Interceptor.java — shouldSkipTransportManagedHeader(), shouldAttachBodyForSigning(): 서명 입력 필터링 정책
    • AwsConfig.java — AWS 자격증명 정책
    • SigV4Diagnostics.java — ThreadLocal Scope 패턴: try-with-resources로 remove() 보장
    • docs/troubleshooting/lambda-function-url-sigv4-signature-mismatch.md — 버그 원인 분석 전체 흐름
  • 트레이드오프/대안:
    • 진단 도구는 임시 코드(// 이후 제거 예정). 이슈 해결 확인 후 별도 커밋으로 제거 예정

- AWS SDK BOM 2.42.23 의존성 추가 (auth, regions)
- AwsSigV4Interceptor: Lambda Function URL AWS_IAM 인증용 SigV4 서명 인터셉터 구현
- CongestionInterceptor: 구체 구현 대신 인터페이스에 의존하도록 추상화 (마커 인터페이스)
- AwsConfig: DefaultCredentialsProvider Bean 등록
- CongestionClient: SigV4 인터셉터 주입, base-url 환경변수(CONGESTION_BASE_URL)로 관리
- application.yml: app.congestion.base-url, app.aws.region 환경변수 주입 구조로 변경
- NoOpRequestInterceptor: 테스트용 Null Object 패턴 구현체 추가
- CongestionClientTest: NoOpRequestInterceptor로 생성자 인자 수정
@geonusp geonusp self-assigned this Mar 28, 2026
@geonusp geonusp added docs Improvements or additions to documentation feat fix refactor test labels Mar 28, 2026
@coderabbitai

coderabbitai Bot commented Mar 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dd47e445-db9d-4889-81b9-299ca440f7e6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/PB-104-congestionclient-lambda-url-sigv4

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

Comment @coderabbitai help to get the list of available commands and usage tips.

geonusp added 10 commits March 29, 2026 01:23
- troubleshooting-lambda-secrets.md 추가
- Content-Length, Transfer-Encoding을 canonical request에서 제외
- 빈 safe method(GET/HEAD/OPTIONS/TRACE)에 body stream 미부착
- SigV4 서명 헤더 디버그 로그 추가 (logSignedRequest, maskedDiagnosticHeaders)
    민감 정보(Credential, Signature, Security-Token)는 마스킹 후 출력
- AwsConfig: AWS_PROFILE 지정 시 ProcessCredentialsProvider로 SSO 자격증명 사용
    AWS CLI export-credentials를 통해 SSO 임시 자격증명을 Java SDK에 전달
- application.yml: app.aws.profile, app.aws.cli-command 환경변수 바인딩 추가
- 빈람다 허용 규칙 추가
- TC1-1: 빈 GET 요청에서 SignedHeaders에 content-length가 포함되지 않는지 검증
- TC3: 세션 자격증명 사용 시 X-Amz-Security-Token 헤더가 추가되는지 검증
signed → spring → apache 레이어별 요청 스냅샷 비교로
SignatureDoesNotMatch 원인을 특정하기 위한 임시 진단 도구.

- SigV4Diagnostics: ThreadLocal 기반 스냅샷 수집 및 레이어 간 diff 로그
- SigV4DiagnosticHttpClient: Spring request factory 경계 스냅샷 캡처 (데코레이터)
- SigV4DiagnosticApacheRequestInterceptor: Apache 실행 체인 스냅샷 캡처
- CongestionClientConfig: 진단 도구 조립용 HttpComponentsClientHttpRequestFactory 구성
- CongestionClient: 진단용 requestFactory 주입 경로 추가
@geonusp
geonusp marked this pull request as ready for review April 6, 2026 11:05

@PHJ2000 PHJ2000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

전체적으로 문제 해결 방향과 디버깅 과정은 이해했습니다. 다만 현재 PR은 단일 PR로 리뷰하기에는 범위가 너무 큽니다.

SigV4 적용 + AWS credential / 설정, signature mismatch 수정 + 테스트, 이후 제거 예정인 diagnostics, 트러블슈팅 문서가 한 PR에 함께 들어 있어 리뷰 질문이 서로 다릅니다. 이 상태에서는 기능 변경 검토와 버그 수정 검토, 임시 diagnostics 코드의 필요성 판단, 문서 검토가 한 번에 섞여 리뷰 초점이 흐려집니다.

특히 diagnostics는 본 기능 수정과 분리해서 보는 편이 적절해 보여, 현재는 Request changes로 남깁니다.

가능하면 이 PR은 단일 PR로 진행하지 말고 아래 3개의 stacked PR로 분리해서 다시 올려주세요.

  1. SigV4 적용 + AWS credential / 설정
  2. Signature mismatch 수정 + 테스트
  3. Diagnostics + 트러블슈팅 문서

추가로 checkstyle 변경도 가능하면 별도 PR로 분리해 주세요. 이렇게 나뉘면 각 PR의 리뷰 포인트가 훨씬 선명해져 더 빠르고 정확하게 리뷰할 수 있을 것 같습니다.

geonusp added 4 commits April 7, 2026 17:15
- AWS SDK BOM 2.42.23 의존성 추가 (auth, regions)
- AwsSigV4Interceptor: Lambda Function URL AWS_IAM 인증용 SigV4 서명 인터셉터 구현
- CongestionInterceptor: 구체 구현 대신 인터페이스에 의존하도록 추상화 (마커 인터페이스)
- AwsConfig: DefaultCredentialsProvider Bean 등록
- CongestionClient: SigV4 인터셉터 주입, base-url 환경변수(CONGESTION_BASE_URL)로 관리
- application.yml: app.congestion.base-url, app.aws.region 환경변수 주입 구조로 변경
- NoOpRequestInterceptor: 테스트용 Null Object 패턴 구현체 추가
- CongestionClientTest: NoOpRequestInterceptor로 생성자 인자 수정
- troubleshooting-lambda-secrets.md 추가
@geonusp geonusp added the chore label Apr 7, 2026
@geonusp geonusp changed the title feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용 feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2 Apr 7, 2026
@geonusp
geonusp changed the base branch from main to feat/PB-104-sigv4-auth April 7, 2026 08:31
@geonusp geonusp changed the title feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2 feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2(pr1 머지되면 pr Conversation 수정 예정 Apr 7, 2026
@geonusp geonusp changed the title feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2(pr1 머지되면 pr Conversation 수정 예정 feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2(pr1 머지되면 pr Conversation 수정 예정) Apr 7, 2026
geonusp added 4 commits April 7, 2026 18:17
- CONGESTION_SIGV4_ENABLED=false 시 NoOp 인터셉터 등록 (기본값 true)
- AwsConfig에서 CongestionInterceptor 빈 생성 책임 이전 (기존 @component 제거)
- 운영/로컬 통합 테스트는 기존과 동일하게 SigV4 서명 유지
@geonusp geonusp changed the title feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2(pr1 머지되면 pr Conversation 수정 예정) feat: PB-104 CongestionClient Lambda Function URL SigV4 인증 적용2 Apr 13, 2026
@PHJ2000
PHJ2000 self-requested a review April 14, 2026 00:58

@PHJ2000 PHJ2000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다.
디버깅 용도를 지워내고 최종본이 되었을 떄 한 번 추가로 리뷰한 뒤에 머지하도록 하겠습니다.

Comment thread config/checkstyle/checkstyle.xml Resolved
Comment thread src/main/resources/application.yml Resolved
@geonusp
geonusp changed the base branch from feat/PB-104-sigv4-auth to main April 14, 2026 09:00
@PHJ2000
PHJ2000 self-requested a review April 23, 2026 03:36
@PHJ2000

PHJ2000 commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

현재 PR 본문이 최신 코드 상태와 조금 맞지 않는 것 같습니다. diagnostics 관련 클래스, CongestionClientConfig, checkstyle 완화, app.aws.cli-command, STS dependency 등은 지금 diff 기준으로는 이미 제거되었거나 보이지 않는데 본문에는 그대로 남아 있어 리뷰 범위를 오해하기 쉬워 보입니다. 최종 상태 기준으로 본문을 한 번 정리해 주시면 리뷰 포인트가 더 선명해질 것 같습니다.

@PHJ2000 PHJ2000 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다. 정리만 부탁드립니다.

Comment thread src/main/resources/application.yml Outdated
aws:
region: ${AWS_REGION:us-east-1}
profile: ${AWS_PROFILE:}
cli-command: ${AWS_CLI_COMMAND:aws}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

app.aws.cli-command는 현재 AwsConfig 구현에서는 더 이상 사용되지 않는 설정으로 보입니다. 이전 ProcessCredentialsProvider 경로의 흔적으로 보이는데, 지금 credential 전략이 ProfileCredentialsProvider / DefaultCredentialsProvider 기준으로 정리된 상태라면 함께 제거해서 설정과 실제 구현을 맞춰두는 편이 좋겠습니다.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

피드백주신대로 application.yml에 있는 app.aws.cli-command 를 제거 하였습니다.

@PHJ2000
PHJ2000 merged commit ab987d8 into main Apr 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore docs Improvements or additions to documentation feat fix refactor test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] PB-104 CongestionClient Lambda Function URL 연동 및 SigV4 인증 적용

2 participants