-
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.
[feat] : 로그아웃 api 구현 + 토큰 재발급 관리 로직 추가 (#73)
* [feat]: 로그 어노테이션 제거, auth 엔티티에 auditing 추가 * [feat]: AuthService 에서 로그아웃 구현과 테스트코드 * [feat]: BlacklistToken 엔티티와 레포지토리 구현 * [feat]: 로그아웃 api 와 테스트코드 구
- Loading branch information
1 parent
63d66d5
commit 2332c10
Showing
10 changed files
with
170 additions
and
13 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
35 changes: 35 additions & 0 deletions
35
core/src/main/java/dev/hooon/auth/domain/entity/BlacklistToken.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,35 @@ | ||
package dev.hooon.auth.domain.entity; | ||
|
||
import static jakarta.persistence.GenerationType.*; | ||
|
||
import dev.hooon.common.entity.TimeBaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(name = "blacklist_token_table") | ||
public class BlacklistToken extends TimeBaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
@Column(name = "blacklist_token_id") | ||
private Long id; | ||
|
||
@Column(name = "blacklist_token_refresh_token", nullable = false, unique = true) | ||
private String refreshToken; | ||
|
||
private BlacklistToken(String refreshToken) { | ||
this.refreshToken = refreshToken; | ||
} | ||
|
||
public static BlacklistToken of(String refreshToken) { | ||
return new BlacklistToken(refreshToken); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
core/src/main/java/dev/hooon/auth/domain/repository/BlacklistRepository.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,10 @@ | ||
package dev.hooon.auth.domain.repository; | ||
|
||
import dev.hooon.auth.domain.entity.BlacklistToken; | ||
|
||
public interface BlacklistRepository { | ||
|
||
boolean existsByRefreshToken(String refreshToken); | ||
|
||
void save(BlacklistToken blacklistToken); | ||
} |
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
9 changes: 9 additions & 0 deletions
9
core/src/main/java/dev/hooon/auth/infrastructure/BlacklistJpaRepository.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,9 @@ | ||
package dev.hooon.auth.infrastructure; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import dev.hooon.auth.domain.entity.BlacklistToken; | ||
|
||
public interface BlacklistJpaRepository extends JpaRepository<BlacklistToken, Long> { | ||
boolean existsByRefreshToken(String refreshToken); | ||
} |
25 changes: 25 additions & 0 deletions
25
core/src/main/java/dev/hooon/auth/infrastructure/adaptor/BlacklistRepositoryAdaptor.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,25 @@ | ||
package dev.hooon.auth.infrastructure.adaptor; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import dev.hooon.auth.domain.entity.BlacklistToken; | ||
import dev.hooon.auth.domain.repository.BlacklistRepository; | ||
import dev.hooon.auth.infrastructure.BlacklistJpaRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class BlacklistRepositoryAdaptor implements BlacklistRepository { | ||
|
||
private final BlacklistJpaRepository blacklistJpaRepository; | ||
|
||
@Override | ||
public boolean existsByRefreshToken(String refreshToken) { | ||
return blacklistJpaRepository.existsByRefreshToken(refreshToken); | ||
} | ||
|
||
@Override | ||
public void save(BlacklistToken blacklistToken) { | ||
blacklistJpaRepository.save(blacklistToken); | ||
} | ||
} |
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