Skip to content

#18 로그아웃#42

Merged
yunjaeeun merged 4 commits intodevelopfrom
38-18-로그아웃
Dec 16, 2024

Hidden character warning

The head ref may contain hidden characters: "38-18-\ub85c\uadf8\uc544\uc6c3"
Merged

#18 로그아웃#42
yunjaeeun merged 4 commits intodevelopfrom
38-18-로그아웃

Conversation

@kingkang85
Copy link
Copy Markdown
Contributor

📋 요약

  • 토큰 블랙리스트를 이용한 로그아웃 기능 구현

🛠 변경 사항

  • 이번 Pull Request에서 작업한 주요 변경 사항은 다음과 같습니다:
    • 새로운 기능 추가 또는 버그 수정
    • 코드 리팩토링 또는 최적화
    • 문서 업데이트

🔗 관련 이슈

📸 스크린샷 또는 GIF (해당되는 경우)

  • 로그아웃
    image
    로그인 시 받은 토큰을 가지고 로그아웃을 합니다.

  • tbl_token_blacklist
    image
    그럼 해당 토큰은 블랙리스트에 등록이 됩니다.

  • 특정 경로 요청
    image
    특정 경로에 요청을 보내면, 401 에러(인증되지 않음)를 받습니다.

✅ 체크리스트

  • 코드가 정상적으로 동작하는지 테스트했습니다.
  • 관련 문서를 작성하거나 업데이트했습니다. (해당되는 경우)
  • 변경 사항을 반영한 테스트 코드를 추가했습니다.
  • 모든 테스트가 성공적으로 통과했습니다.

🛡 테스트 방법

.

📚 추가 참고 사항

로그아웃 시 토큰을 블랙리스트에 등록하는 방법으로는 DB를 이용하거나 Redis를 이용하는 것이 있습니다.
저는 일단 DB를 이용했는데, Redis가 속도도 빠르고 자동 만료 기능 등이 있다고 하더라구요. 나중에 Redis를 사용하는 것으로 코드 리팩토링 해보겠습니다..!

- TokenBlacklist 엔티티 및 Repository 생성
- LogoutFilter를 통한 로그아웃 처리 구현
- SecurityConfig에 로그아웃 설정 추가
- JWTFilter에 블랙리스트 토큰 검증 로직 추가

Resolves: #38
Copy link
Copy Markdown
Contributor

@MinFe4990 MinFe4990 left a comment

Choose a reason for hiding this comment

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

!check
블랙리스트까지 있네요

Copy link
Copy Markdown
Contributor

@KIM9909 KIM9909 left a comment

Choose a reason for hiding this comment

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

로그아웃 시 토큰을 블랙리스트에 넣는 이유가 있나요 ?

@kingkang85
Copy link
Copy Markdown
Contributor Author

로그아웃 시 토큰을 블랙리스트에 넣는 이유가 있나요 ?

@KIM9909
저희가 Django에서는 세션을 이용해서 로그아웃을 하면 바로 토큰을 삭제할 수 있었잖아요?
근데 JWT는 세션 기반처럼 저장된 상태를 삭제하는 이런 방식이 아니라, 만료 기간이 정해져 있어요!
그래서 로그아웃을 하더라도 JWT 자체는 유효하기 때문에 토큰이 재사용되는 문제가 있어요!
따라서 보안 강화를 위해 로그아웃을 하면 블랙리스트에 넣어버려서 무효화를 시키는 것입니다!!

Copy link
Copy Markdown
Contributor

@LeeGukgeon LeeGukgeon left a comment

Choose a reason for hiding this comment

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

장고처럼 딸깍해서 되는게 아니었네요 로그아웃 기능 구현 확인했습니다

@yunjaeeun
Copy link
Copy Markdown
Contributor

yml에 토큰 만료 시간도 설정하면 더 좋을 것 같습니다

@yunjaeeun yunjaeeun merged commit dcaf3eb into develop Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants