[✨ Feature] oauth 인증 구현 - 밸리데이션 로직 추가 - #17
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
juice119
left a comment
There was a problem hiding this comment.
GitHub OAuth callback 검증 로직 PR 올렸습니다. 리뷰 부탁드립니다 🙏
- callback으로 받은 accessToken/profile 검증 안 하고 바로 가입 처리되던 부분 → DTO 검증 추가
| if (validationErrors.length > 0) { | ||
| throw new InternalServerErrorException( | ||
| 'oauth 로그인 중 에러가 발생하였습니다. 고객센터에 문의 주세요.', | ||
| ); | ||
| } |
There was a problem hiding this comment.
에러 처리 원칙 중 매우 중요한 부분이 있는데요, Do not ignore error 입니다.
현재 코드는 validation 시에 error 가 생기면 InternalServerErrorException 으로 대체 (replace) 하는 코드 인데, 이 경우 어떤 에러가 최초에 발생되었는지 ignore 됩니다. Error.captureStackTrace 를 활용해 error 를 wrapping 하거나, error log 를 출력하거나 에러를 남겨야 합니다.
| import { describe, expect, it } from 'vitest'; | ||
| import { GithubOauthCallbackResponseDto } from './GithubOauthCallbackResponseDto'; | ||
|
|
||
| describe('GithubOauthCallbackResponseDto Unit Test', () => { |
There was a problem hiding this comment.
이 테스트 케이스는 (제기준에서) 불필요해 보입니다. class-validator 오픈소스의 @isnotempty() decorator 는 문제가 있을때 error 를 발생시키는데, 오픈소스에서 충분히 검증되었을텐데, 한번더 검증을 추가해야할 만큼 이유가 보이진 않습니다.
There was a problem hiding this comment.
맞는 것 같습니다 이쪽 테스트 정리할게요
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
InternalServerErrorException으로 대체되며 최초 validationErrors가 누락되던 문제 수정, logger.error로 남김 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
juice119
left a comment
There was a problem hiding this comment.
리뷰하신 내용 반영했습니다 @f-lab-namu 님
| import { describe, expect, it } from 'vitest'; | ||
| import { GithubOauthCallbackResponseDto } from './GithubOauthCallbackResponseDto'; | ||
|
|
||
| describe('GithubOauthCallbackResponseDto Unit Test', () => { |
There was a problem hiding this comment.
맞는 것 같습니다 이쪽 테스트 정리할게요
| if (validationErrors.length > 0) { | ||
| throw new InternalServerErrorException( | ||
| 'oauth 로그인 중 에러가 발생하였습니다. 고객센터에 문의 주세요.', | ||
| ); | ||
| } |



배경 및 목적
oauth 인증시 callback으로 받은 데이터를 검증하지 않고 회원가입하도록 설계되어 잘못된 데이터가 들어와도 회원가입이 발생
연관 이슈
Closes #16
작업 내용
테스트 결과
리뷰어 참고사항