-
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.
* chore: guava implements * refactor: delete redis code * feat: set time based InMemoryRepository * refactor: 토큰 재발급 코드 수정 * test: refreshToken test code * style: 주석 제거 * test: TokenService test
- Loading branch information
Showing
24 changed files
with
331 additions
and
255 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
32 changes: 32 additions & 0 deletions
32
...main/java/com/plzgraduate/myongjigraduatebe/auth/adaptor/out/InMemoryTokenRepository.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,32 @@ | ||
package com.plzgraduate.myongjigraduatebe.auth.adaptor.out; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import com.google.common.cache.Cache; | ||
import com.google.common.cache.CacheBuilder; | ||
import com.plzgraduate.myongjigraduatebe.auth.application.port.out.FindRefreshTokenPort; | ||
import com.plzgraduate.myongjigraduatebe.auth.application.port.out.SaveRefreshTokenPort; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class InMemoryTokenRepository implements FindRefreshTokenPort, SaveRefreshTokenPort { | ||
private static final Cache<String, Long> TOKEN_REPOSITORY = CacheBuilder.newBuilder() | ||
.expireAfterWrite(15, TimeUnit.DAYS) | ||
.build(); | ||
|
||
@Override | ||
public void saveRefreshToken(String refreshToken, Long userId) { | ||
TOKEN_REPOSITORY.put(refreshToken, userId); | ||
} | ||
|
||
@Override | ||
public Optional<Long> findByRefreshToken(String refreshToken) { | ||
return Optional.ofNullable(TOKEN_REPOSITORY.getIfPresent(refreshToken)); | ||
} | ||
|
||
} |
38 changes: 0 additions & 38 deletions
38
...a/com/plzgraduate/myongjigraduatebe/auth/adaptor/out/persistence/RefreshTokenAdaptor.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...va/com/plzgraduate/myongjigraduatebe/auth/adaptor/out/persistence/RefreshTokenMapper.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...m/plzgraduate/myongjigraduatebe/auth/adaptor/out/persistence/RefreshTokenRedisEntity.java
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
...om/plzgraduate/myongjigraduatebe/auth/adaptor/out/persistence/RefreshTokenRepository.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
.../java/com/plzgraduate/myongjigraduatebe/auth/application/port/in/AccessTokenResponse.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,23 @@ | ||
package com.plzgraduate.myongjigraduatebe.auth.application.port.in; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class AccessTokenResponse { | ||
private String accessToken; | ||
|
||
@Builder | ||
private AccessTokenResponse(String accessToken) { | ||
this.accessToken = accessToken; | ||
} | ||
|
||
public static AccessTokenResponse from(String accessToken) { | ||
return AccessTokenResponse | ||
.builder() | ||
.accessToken(accessToken) | ||
.build(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...n/java/com/plzgraduate/myongjigraduatebe/auth/application/port/in/token/TokenUseCase.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.plzgraduate.myongjigraduatebe.auth.application.port.in.token; | ||
|
||
import com.plzgraduate.myongjigraduatebe.auth.application.port.in.TokenResponse; | ||
import com.plzgraduate.myongjigraduatebe.auth.application.port.in.AccessTokenResponse; | ||
|
||
public interface TokenUseCase { | ||
TokenResponse createNewToken(TokenCommand tokenCommand); | ||
AccessTokenResponse createNewToken(TokenCommand tokenCommand); | ||
} |
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
3 changes: 1 addition & 2 deletions
3
...ava/com/plzgraduate/myongjigraduatebe/auth/application/port/out/SaveRefreshTokenPort.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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package com.plzgraduate.myongjigraduatebe.auth.application.port.out; | ||
|
||
import com.plzgraduate.myongjigraduatebe.auth.domain.RefreshToken; | ||
|
||
public interface SaveRefreshTokenPort { | ||
void saveRefreshToken(RefreshToken refreshToken); | ||
void saveRefreshToken(String refreshToken, Long userId); | ||
} |
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
27 changes: 0 additions & 27 deletions
27
...com/plzgraduate/myongjigraduatebe/auth/application/service/token/RefreshTokenService.java
This file was deleted.
Oops, something went wrong.
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
27 changes: 0 additions & 27 deletions
27
src/main/java/com/plzgraduate/myongjigraduatebe/auth/domain/RefreshToken.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.