Skip to content

Conversation

@jsoonworld
Copy link
Member

📄 Work Description

작업 내용

회원가입(signUp) 로직에서, Authorization 헤더로 받은 authId에 포함될 수 있는 Bearer 접두사를 제거하는 기능을 추가했습니다. 이를 통해 데이터베이스에는 항상 순수한 소셜 인증 ID만 저장되도록 보장합니다.

작업 배경 (문제 상황)

기존 가입 유저가 로그인 시도 시 신규 유저로 잘못 인식되어 로그인이 불가능한 문제가 발생했습니다. 원인은 클라이언트가 전달한 Bearer {authId} 값을 서버가 파싱하지 않고 그대로 DB에 저장했기 때문입니다.

설계 고민

Bearer 접두사를 처리하는 로직의 위치에 대해 고민했습니다.

  1. AuthService (채택): 문제 상황이 signUp 로직에 한정되어 있고, 비즈니스 로직과의 응집도가 높아 가장 실용적이라고 판단했습니다.
  2. 별도 Resolver 객체: SRP 원칙을 지킬 수 있어 가장 이상적인 구조지만, 현 상황에서는 과엔지니어링이라고 보았습니다.
  3. Controller 계층: 계층 분리 원칙은 지킬 수 있으나 코드 중복의 우려가 있었습니다.

따라서 현재 구조에서 가장 효율적인 AuthService에 로직을 추가하는 것으로 결정했습니다.


💬 To Reviewers

  • 회원가입 시 authId를 처리하는 로직의 위치에 대해 다른 의견이 있으시면 편하게 공유해주세요!
  • 중요: 이 PR이 머지되어도, 스테이징 DB에 이미 Bearer 접두사와 함께 잘못 저장된 유저 데이터는 수동으로 수정해야 정상 로그인이 가능합니다.
  • 제가 이 부분은 개선해 둔 상태입니다!

⚙️ ISSUE

@jsoonworld jsoonworld requested a review from Copilot August 12, 2025 13:18
@jsoonworld jsoonworld self-assigned this Aug 12, 2025
@jsoonworld jsoonworld added the ♻️ refactor 코드 리팩토링 ex) 형식변경 label Aug 12, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an authentication issue where the signUp method incorrectly stored the Bearer prefix along with the social authentication ID in the database, causing existing users to be treated as new users during login attempts.

  • Adds logic to remove the Bearer prefix from authId during user registration
  • Ensures only the pure social authentication ID is stored in the database
  • Resolves login failures for existing users affected by this issue

String resolvedAuthId = authId;
if (resolvedAuthId != null && resolvedAuthId.startsWith(TOKEN_PREFIX)) {
resolvedAuthId = resolvedAuthId.substring(TOKEN_PREFIX.length());
}
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the Bearer prefix removal logic into a separate private method like 'removeBearer(String authId)' to improve code readability and enable potential reuse in other methods.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

@jsoonworld jsoonworld Aug 12, 2025

Choose a reason for hiding this comment

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

리뷰 감사합니다! 좋은 제안을 주셨네요.

말씀해주신 것처럼 로직을 별도 메소드로 추출하는 것의 장점에 대해 충분히 공감합니다. 다만, 현재 이 로직이 매우 간단하고 signUp 메소드 내에서만 사용되고 있어서, 전체적인 흐름을 한눈에 파악하기 위해 메소드 내부에 두는 편이 더 낫다고 판단했습니다.

재사용 가능성에 대해서도 고려했지만, YAGNI(You Ain't Gonna Need It) 원칙에 따라 지금 당장 필요하지 않은 재사용을 위해 코드를 분리하기보다는 현재의 단순성을 유지하는 쪽을 선택했습니다.

물론 로직이 더 복잡해지거나 다른 곳에서도 필요해진다면, 말씀해주신 대로 메소드로 분리하는 것이 분명 좋은 리팩토링이 될 것 같습니다. 따라서 이 제안은 좋은 의견으로 참고하되, 현재 상태를 그대로 유지하도록 하겠습니다. 의견 감사합니다! 🙏

@jsoonworld jsoonworld merged commit 7a75cc4 into develop Aug 12, 2025
1 check passed
@jsoonworld jsoonworld added 🔀 merge 다른 브랜치와 병합 🦊장순🦊 and removed 🔀 merge 다른 브랜치와 병합 labels Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ refactor 코드 리팩토링 ex) 형식변경 size/S 🦊장순🦊

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor : authorization 헤더 수정

2 participants