-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MATE-111 : [FEAT] 자체 서비스 로그아웃 기능 구현 (#100)
* MATE-111 : [CHORE] 로그아웃 시 블랙리스트 등록을 위한 redis 의존성 추가 * MATE-111 : [FEAT] 로그아웃 시 블랙리스트에 토큰을 등록하고 검증하는 서비스 구현 * MATE-111 : [FEAT] 로그아웃 컨트롤러 구현 * MATE-111 : [TEST] 로그아웃 redis 서비스 테스트 * MATE-111 : [TEST] 로그아웃 컨트롤러 테스트 * MATE-111 : [TEST] 로그아웃 통합 테스트 * MATE-111 : [TEST] 굿즈 채팅 테스트에 누락된 JwtCheckFilter MockBean 주입
- Loading branch information
Showing
9 changed files
with
261 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/example/mate/domain/member/service/LogoutRedisService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.example.mate.domain.member.service; | ||
|
||
import com.example.mate.common.error.CustomException; | ||
import com.example.mate.common.error.ErrorCode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class LogoutRedisService { | ||
|
||
private final RedisTemplate<String, String> redisTemplate; | ||
|
||
// 로그아웃 시 블랙리스트에 토큰 추가 | ||
public void addTokenToBlacklist(String token) { | ||
if (token == null || !token.startsWith("Bearer ")) { | ||
throw new CustomException(ErrorCode.INVALID_AUTH_TOKEN); | ||
} | ||
|
||
// TODO : 테스트용 1분 유효를 변경 | ||
redisTemplate.opsForValue().set("blacklist:" + token.substring(7), "blacklisted", 1, TimeUnit.MINUTES); | ||
} | ||
|
||
// 블랙리스트에 토큰 있는지 확인 | ||
public boolean isTokenBlacklisted(String accessToken) { | ||
return redisTemplate.hasKey("blacklist:" + accessToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.