-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MARA-56 : Refresh Token을 위한 Redis 추가 (#24)
* feat: redis 도입을 위한 초기 세팅 * feat: refreshToken 시간 업데이트, request 추가, 메소드분리, validation 추가 * refactor: refresh-duration-mins 추가 * Revert "refactor: refresh-duration-mins 추가" This reverts commit 4ce43ea. * refactor: accessToken 만료시 refreshToken 확인 후 자동 연장 * refactor: Swagger refresh-token header 추가 * refactor: RefreshToken 연장 로직 제거 * refactor: RefreshToken 연장 로직 제거 * refactor: refresh-duration-mins 수치 변경, 만료 log 추가 --------- Co-authored-by: gwon188 <[email protected]>
- Loading branch information
Showing
11 changed files
with
166 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mara.server.config.redis | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.data.redis.connection.RedisConnectionFactory | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory | ||
import org.springframework.data.redis.core.RedisTemplate | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
class RedisConfig() { | ||
|
||
@Bean | ||
fun redisConnectionFactory(): RedisConnectionFactory { | ||
return LettuceConnectionFactory() | ||
} | ||
|
||
@Bean | ||
fun redisTemplate(): RedisTemplate<ByteArray, ByteArray> { | ||
val redisTemplate = RedisTemplate<ByteArray, ByteArray>() | ||
redisTemplate.connectionFactory = redisConnectionFactory() | ||
return redisTemplate | ||
} | ||
} |
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,19 @@ | ||
package mara.server.config.redis | ||
|
||
import org.springframework.data.annotation.Id | ||
import org.springframework.data.redis.core.RedisHash | ||
import org.springframework.data.redis.core.TimeToLive | ||
import org.springframework.data.redis.core.index.Indexed | ||
import java.util.concurrent.TimeUnit | ||
|
||
@RedisHash(value = "refreshToken") | ||
data class RefreshToken( | ||
@Id | ||
@Indexed | ||
val refreshToken: String, | ||
|
||
val userId: Long, | ||
|
||
@TimeToLive(unit = TimeUnit.MINUTES) | ||
val expiration: Int, | ||
) |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/mara/server/config/redis/RefreshTokenRepository.kt
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,7 @@ | ||
package mara.server.config.redis | ||
|
||
import org.springframework.data.repository.CrudRepository | ||
|
||
interface RefreshTokenRepository : CrudRepository<RefreshToken, String> { | ||
fun findByRefreshToken(refreshToken: String?): RefreshToken? | ||
} |
42 changes: 23 additions & 19 deletions
42
src/main/kotlin/mara/server/config/swagger/SwaggerConfig.kt
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
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