diff --git a/wabi/src/main/kotlin/com/wap/wabi/auth/admin/repository/AdminRefreshTokenRepository.java b/wabi/src/main/kotlin/com/wap/wabi/auth/admin/repository/AdminRefreshTokenRepository.java index c83fc5a..6e9b2f7 100644 --- a/wabi/src/main/kotlin/com/wap/wabi/auth/admin/repository/AdminRefreshTokenRepository.java +++ b/wabi/src/main/kotlin/com/wap/wabi/auth/admin/repository/AdminRefreshTokenRepository.java @@ -1,13 +1,14 @@ package com.wap.wabi.auth.admin.repository; import com.wap.wabi.auth.admin.entity.AdminRefreshToken; -import org.apache.poi.sl.draw.geom.GuideIf; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; + @Repository public interface AdminRefreshTokenRepository extends JpaRepository { Optional findAdminRefreshTokenByAdminNameAndReissueCountLessThan(String name, long count); + Optional findAdminRefreshTokenByAdminName(String name); } diff --git a/wabi/src/main/kotlin/com/wap/wabi/auth/jwt/JwtTokenProvider.kt b/wabi/src/main/kotlin/com/wap/wabi/auth/jwt/JwtTokenProvider.kt index b2df493..80c73b8 100644 --- a/wabi/src/main/kotlin/com/wap/wabi/auth/jwt/JwtTokenProvider.kt +++ b/wabi/src/main/kotlin/com/wap/wabi/auth/jwt/JwtTokenProvider.kt @@ -92,25 +92,6 @@ class JwtTokenProvider( .build() .parseClaimsJws(token)!! - @Transactional - fun reissueAccessToken(refreshToken: String, oldAccessToken: String): String { - // 리프레시 토큰과 기존 액세스 토큰의 유효성 검사 - validateAndParseToken(refreshToken) - val subject = decodeJwtPayloadSubject(oldAccessToken) - val adminName = subject.split(':')[0] - - adminRefreshTokenRepository.findAdminRefreshTokenByAdminNameAndReissueCountLessThan(adminName, reissueLimit) - .ifPresentOrElse( - { it.validateRefreshToken(refreshToken) - it.increaseReissueCount() - }, - { throw ExpiredJwtException(null, null, "Refresh token expired or invalid.") } - ) - - // 새로운 액세스 토큰 발급 - return createAccessToken(subject) - } - private fun decodeJwtPayloadSubject(oldAccessToken: String) = objectMapper.readValue( Base64.getUrlDecoder().decode(oldAccessToken.split('.')[1]).decodeToString(),