Skip to content

Conversation

@asn6878
Copy link
Member

@asn6878 asn6878 commented Nov 27, 2025

📋 작업 내용

JWT 블랙리스트 적용

현재 삭제된 사용자의 AT로 요청에 대한 핸들링이 되어있지 않다는 의견이 건의 되었습니다.

대부분의 경우 비즈니스 로직에서 userRepository.findOne({ where: { id: user.id } )를 수행하는 과정에서 막히겠지만, 개발자의 입장에서 이는 정상적인 흐름이 아니기에 매번 직접 예외 처리 하여 관리중이며, 잠재 위험이 유발되기 좋은 상황으로 보입니다.

이에 회원탈퇴 시

  • 해당 사용자의 AT를 블랙리스트(Redis내 USER_BLACKLIST_JWT_KEY 형태의 키를 가지는 해시맵에 추가
  • jwt.strategy.ts 측에서 요청 들어온 AT가 블랙리스트에 존재하는지 매번 확인하여 요청을 허가
    해주는 형태로 수정하였습니다.

OAuth callback 인증 정보 전달 방식 수정

기존에는 ${OAUTH_URL_PATH.BASE_URL}/oauth-success?token=${accessToken}를 사용해 OAuth 로그인을 통해 생성된 AT를 URL에 포함시켜 FE로 전달하였지만, 이는 여러가지 이유로 보안에 취약하다는 의견이 나와 AT 전달을 제거하였습니다.

변경 후에는 RT만 httpOnly Cookie로 안전하게 전달 후, 클라이언트 측에서 인증이 필요한 API 요청 시 AT를 재발급 받아 사용하도록 처리하였습니다.

oauth.service.ts -> oAuth.service.ts 파일명 변경

@asn6878 asn6878 self-assigned this Nov 27, 2025
@asn6878 asn6878 added ✨ Feature 기능 구현 👹 BugFix 버그 수정 labels Nov 27, 2025
Copy link
Member

@Jo-Minseok Jo-Minseok left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 리뷰 확인 부탁드립니다!

const isBlacklisted = await this.redisService.get(blacklistKey);

if (isBlacklisted) {
throw new UnauthorizedException('인증되지 않은 요청입니다.');
Copy link
Member

Choose a reason for hiding this comment

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

P5) refresh token도 지우게 cookie 설정해주는것도 좋을듯 합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

그렇네요, RT를 안막아주면 재발급으로 바로 우회가 가능할 것 같아요.
추가 해두겠습니다 👍

if (accessToken) {
await this.redisService.set(
`${REDIS_KEYS.USER_DELETE_ACCOUNT_KEY}:${token}`,
user.id.toString() + ':' + accessToken,
Copy link
Member

Choose a reason for hiding this comment

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

P5) 템플릿 리터럴 형식 추천드립니다!

Copy link
Collaborator

@CodeVac513 CodeVac513 left a comment

Choose a reason for hiding this comment

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

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👹 BugFix 버그 수정 ✨ Feature 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants