Skip to content

[Fix] /conversations api를 호출할 때 accesstoken을 전달하도록 보완#159

Merged
Ncs89 merged 1 commit intodevfrom
feat/155-ai-access-token
Feb 12, 2026
Merged

[Fix] /conversations api를 호출할 때 accesstoken을 전달하도록 보완#159
Ncs89 merged 1 commit intodevfrom
feat/155-ai-access-token

Conversation

@Ncs89
Copy link
Copy Markdown
Collaborator

@Ncs89 Ncs89 commented Feb 12, 2026

📌 관련 이슈

🏷️ PR 타입

  • 🐛 버그 수정 (Bug Fix)

📝 작업 내용

  • ProovyAiRequest에 authToken 필드 추가
  • ChatService의 ai api 호출 함수에 대해 accessToken 파라미터 추가
  • ChatServiceImpl에서 accessToken을 받아서 authToken 전달

✅ 체크리스트

  • 코드 리뷰를 받을 준비가 완료되었습니다
  • 코드 스타일 가이드를 준수했습니다
  • 셀프 리뷰를 완료했습니다

📎 기타 참고사항

  • 배포 후 테스트할 예정입니다.

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 대화 기능에 향상된 토큰 기반 인증이 추가되었습니다.
    • 실시간 스트리밍 대화에서 인증 토큰이 안전하게 처리됩니다.
  • Improvements

    • 대화 API 호출 시 인증 처리의 안정성이 개선되었습니다.

@Ncs89 Ncs89 self-assigned this Feb 12, 2026
@Ncs89 Ncs89 added bug Something isn't working 🗨️Conversations labels Feb 12, 2026
@Ncs89 Ncs89 linked an issue Feb 12, 2026 that may be closed by this pull request
3 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

HTTP 요청의 Authorization 헤더에서 추출한 accessToken을 ConversationController에서 ChatService를 통해 ProovyAiRequest DTO로 전달하는 토큰 스레딩 로직을 구현합니다. Bearer 토큰 파싱 헬퍼 메서드를 추가하고 메서드 시그니처를 업데이트합니다.

Changes

코호트 / 파일(s) 요약
ConversationController 통합
src/main/java/com/proovy/domain/conversation/controller/ConversationController.java
Authorization 헤더 파라미터를 createConversation에 추가하고, Bearer 토큰 추출 헬퍼 메서드(extractBearerToken)를 구현. 추출한 accessToken을 streamResponse 메서드에 전달하여 스트리밍 흐름에 통합.
ChatService 인터페이스 업데이트
src/main/java/com/proovy/domain/conversation/service/ChatService.java
streamConversationinvokeConversation 메서드 시그니처에 String accessToken 파라미터 추가 및 Javadoc 업데이트.
ChatServiceImpl 구현 업데이트
src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java
인터페이스 시그니처 변경에 맞춰 streamConversationinvokeConversation 구현 메서드 업데이트. streamConversation에서 accessToken을 ProovyAiRequest.authToken()으로 전달.
ProovyAiRequest DTO 확장
src/main/java/com/proovy/domain/conversation/dto/request/ProovyAiRequest.java
@JsonProperty("authToken") 어노테이션이 있는 선택적 필드 authToken 추가. Lombok @Builder를 통해 생성 및 JSON 직렬화에 자동 포함.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Sockbee
  • haein45
  • gaeunee2

Poem

🐰 Authorization 헤더에서 토큰을 쏘옥!
Bearer 문자를 빼내는 마법을 해볼게요,
컨트롤러에서 서비스로, DTO까지 흘러가는
accessToken의 여행, 차근차근 스레딩하니
AI 서버도 사용자를 제대로 알 수 있어요! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive PR의 변경사항이 #155의 주요 요구사항(accessToken 파라미터 추가, ChatService 인터페이스 업데이트, 구현 레벨 변경)을 부분적으로 충족하나, Bearer 토큰 추출 로직 구현이 불충분합니다. ConversationController에서 extractBearerToken 메서드를 추가했으나, HttpServletRequest에서 직접 토큰을 추출하는 완전한 유틸리티 메서드 구현 확인 필요 및 모든 요구사항 이행 검증 필요.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 accessToken을 AI API 호출 시 전달하는 기능을 명확하게 설명하며, 변경 사항의 핵심을 잘 나타냅니다.
Description check ✅ Passed PR 설명은 필수 섹션(관련 이슈, PR 타입, 작업 내용, 체크리스트)을 포함하고 있으며, 주요 변경 사항을 명확하게 기술하고 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #155 요구사항과 직접 관련되어 있으며, accessToken 전달 기능 구현에 필요한 범위 내 변경입니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/155-ai-access-token

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.

Copy link
Copy Markdown

@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

🤖 Fix all issues with AI agents
In
`@src/main/java/com/proovy/domain/conversation/dto/request/ProovyAiRequest.java`:
- Around line 47-49: The ProovyAiRequest DTO currently includes authToken which
will be printed by Lombok-generated toString() when ChatServiceImpl logs the
request; exclude this sensitive field by either adding Lombok's
`@ToString.Exclude` to the authToken field or switch the class to
`@ToString`(onlyExplicitlyIncluded = true) and explicitly include non-sensitive
fields, or implement a custom toString() that omits authToken; update the
ProovyAiRequest class (field authToken and class-level Lombok annotations) so
logs no longer expose the token while leaving other fields printable.
🧹 Nitpick comments (1)
src/main/java/com/proovy/domain/conversation/controller/ConversationController.java (1)

88-96: @AuthenticationPrincipal이 이미 인증을 처리하므로, 토큰이 없을 때의 동작을 확인하세요.

Spring Security 필터 체인이 이미 Authorization 헤더를 검증하여 UserPrincipal을 설정하므로, 이 엔드포인트에 도달했다면 토큰이 존재할 가능성이 높습니다. 그럼에도 required = false로 설정되어 있고, extractBearerTokennull을 반환할 수 있어 AI 서버에 authToken: null이 전달될 수 있습니다.

AI 서버에서 authToken이 필수라면 null 체크 후 적절한 에러를 반환하는 것이 안전합니다.

Comment on lines +47 to +49
// 선택: authToken - Spring 백엔드 인증 토큰 (크레딧 API 호출용)
@JsonProperty("authToken")
private String authToken;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

authToken이 로그에 노출될 수 있는 보안 위험

ChatServiceImpl Line 286에서 log.debug("Request payload: {}", request)로 이 객체를 로깅하고 있습니다. Lombok @Getter가 있으므로 기본 toString()authToken 값이 포함되어 로그에 민감한 토큰이 노출될 수 있습니다.

@ToString.Exclude를 추가하거나, 클래스 레벨에서 @ToString을 커스텀하여 authToken을 제외하세요.

🛡️ 수정 제안
+import lombok.ToString;
+
 `@Getter`
 `@Builder`
+@ToString
 public class ProovyAiRequest {
     // ... existing fields ...
 
     // 선택: authToken - Spring 백엔드 인증 토큰 (크레딧 API 호출용)
     `@JsonProperty`("authToken")
+    `@ToString.Exclude`
     private String authToken;
 }
🤖 Prompt for AI Agents
In
`@src/main/java/com/proovy/domain/conversation/dto/request/ProovyAiRequest.java`
around lines 47 - 49, The ProovyAiRequest DTO currently includes authToken which
will be printed by Lombok-generated toString() when ChatServiceImpl logs the
request; exclude this sensitive field by either adding Lombok's
`@ToString.Exclude` to the authToken field or switch the class to
`@ToString`(onlyExplicitlyIncluded = true) and explicitly include non-sensitive
fields, or implement a custom toString() that omits authToken; update the
ProovyAiRequest class (field authToken and class-level Lombok annotations) so
logs no longer expose the token while leaving other fields printable.

Copy link
Copy Markdown
Collaborator

@gaeunee2 gaeunee2 left a comment

Choose a reason for hiding this comment

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

오류 없는 거 확인했습니다. 머지해주세요!

@Ncs89 Ncs89 merged commit d5192bb into dev Feb 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 🗨️Conversations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] AI-server에 accessToken 전달

2 participants