-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- @RedisHash 적용 - 토큰 만료 기간을 상수로 적용
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/com/j9/bestmoments/constants/TokenExpiration.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,11 @@ | ||
package com.j9.bestmoments.constants; | ||
|
||
public final class TokenExpiration { | ||
|
||
// 10분 | ||
public static final int ACCESS_TOKEN = 60 * 10; | ||
|
||
// 60분 | ||
public static final int REFRESH_TOKEN = 60 * 60; | ||
|
||
} |
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,13 @@ | ||
package com.j9.bestmoments.domain; | ||
|
||
import com.j9.bestmoments.constants.TokenExpiration; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@RedisHash(value = "AccessToken", timeToLive = TokenExpiration.ACCESS_TOKEN) | ||
public class AccessToken extends Token_ { | ||
|
||
public AccessToken(Member member, String token) { | ||
super(member, token); | ||
} | ||
|
||
} |
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,13 @@ | ||
package com.j9.bestmoments.domain; | ||
|
||
import com.j9.bestmoments.constants.TokenExpiration; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@RedisHash(value = "RefreshToken", timeToLive = TokenExpiration.REFRESH_TOKEN) | ||
public class RefreshToken extends Token_ { | ||
|
||
public RefreshToken(Member member, String token) { | ||
super(member, token); | ||
} | ||
|
||
} |
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,23 @@ | ||
package com.j9.bestmoments.domain; | ||
|
||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@RedisHash("Token") | ||
public class Token_ { | ||
|
||
@Id | ||
private String token; | ||
private UUID memberId; | ||
|
||
public Token_(Member member, String token) { | ||
this.token = token; | ||
this.memberId = member.getId(); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/j9/bestmoments/repository/Token_Repository.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 com.j9.bestmoments.repository; | ||
|
||
import com.j9.bestmoments.domain.Token_; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface Token_Repository extends CrudRepository<Token_, String> { | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/j9/bestmoments/service/Token_Service.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,13 @@ | ||
package com.j9.bestmoments.service; | ||
|
||
import com.j9.bestmoments.repository.Token_Repository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class Token_Service { | ||
|
||
private final Token_Repository tokenRepository; | ||
|
||
} |