-
Notifications
You must be signed in to change notification settings - Fork 4
✨ feat: jwt 블랙리스트 기능 추가 #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Jo-Minseok
left a comment
There was a problem hiding this 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('인증되지 않은 요청입니다.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P5) refresh token도 지우게 cookie 설정해주는것도 좋을듯 합니다!
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P5) 템플릿 리터럴 형식 추천드립니다!
CodeVac513
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
📋 작업 내용
JWT 블랙리스트 적용
현재 삭제된 사용자의 AT로 요청에 대한 핸들링이 되어있지 않다는 의견이 건의 되었습니다.
대부분의 경우 비즈니스 로직에서
userRepository.findOne({ where: { id: user.id } )를 수행하는 과정에서 막히겠지만, 개발자의 입장에서 이는 정상적인 흐름이 아니기에 매번 직접 예외 처리 하여 관리중이며, 잠재 위험이 유발되기 좋은 상황으로 보입니다.이에 회원탈퇴 시
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파일명 변경