Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class TokenRefreshService {
@Value("${jwt.refresh.expiration}")
private Long refreshTokenExpiry;

public void putRefreshToken(String userId, String refreshToken) {
refreshTokenCache.put(userId, refreshToken, Duration.ofMillis(refreshTokenExpiry));
}

public TokenPair refreshAccessToken(String refreshToken) {
String userId;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.runimo.runimo.auth.jwt.JwtTokenFactory;
import org.runimo.runimo.auth.repository.SignupTokenRepository;
import org.runimo.runimo.auth.service.EncryptUtil;
import org.runimo.runimo.auth.service.TokenRefreshService;
import org.runimo.runimo.auth.service.dto.AuthResult;
import org.runimo.runimo.auth.service.dto.AuthStatus;
import org.runimo.runimo.auth.service.dto.TokenPair;
Expand All @@ -28,6 +29,7 @@ public class AppleLoginHandler {

private final AppleTokenVerifier appleTokenVerifier;
private final JwtTokenFactory jwtTokenFactory;
private final TokenRefreshService tokenRefreshService;
private final OAuthInfoRepository oAuthInfoRepository;
private final SignupTokenRepository signupTokenRepository;
private final EncryptUtil encryptUtil;
Expand Down Expand Up @@ -60,6 +62,8 @@ public AuthResult validateAndLogin(final String authCode, final String verifier)
}

TokenPair tokenPair = jwtTokenFactory.generateTokenPair(oAuthInfo.get().getUser());
tokenRefreshService.putRefreshToken(oAuthInfo.get().getUser().getPublicId(),
tokenPair.refreshToken());
return AuthResult.success(AuthStatus.LOGIN_SUCCESS, oAuthInfo.get().getUser(), tokenPair);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.runimo.runimo.auth.exceptions.UserJwtException;
import org.runimo.runimo.auth.jwt.JwtTokenFactory;
import org.runimo.runimo.auth.repository.SignupTokenRepository;
import org.runimo.runimo.auth.service.TokenRefreshService;
import org.runimo.runimo.auth.service.apple.KakaoUserInfo;
import org.runimo.runimo.auth.service.dto.AuthResult;
import org.runimo.runimo.auth.service.dto.AuthStatus;
Expand All @@ -28,6 +29,7 @@ public class KakaoLoginHandler {
private final KakaoTokenVerifier kakaoTokenVerifier;
private final OAuthInfoRepository oAuthInfoRepository;
private final JwtTokenFactory jwtTokenFactory;
private final TokenRefreshService tokenRefreshService;
private final SignupTokenRepository signupTokenRepository;

/**
Expand All @@ -51,6 +53,8 @@ public AuthResult validateAndLogin(final String rawToken) {
}

TokenPair tokenPair = jwtTokenFactory.generateTokenPair(oAuthInfo.get().getUser());
tokenRefreshService.putRefreshToken(oAuthInfo.get().getUser().getPublicId(),
tokenPair.refreshToken());
return AuthResult.success(AuthStatus.LOGIN_SUCCESS, oAuthInfo.get().getUser(), tokenPair);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ spring:
show-sql: true

jwt:
expiration: 300000
expiration: ${JWT_EXPIRATION:180000}
refresh:
expiration: 3600000
expiration: ${JWT_REFRESH_EXPIRATION:86400000}

---
spring:
Expand All @@ -119,9 +119,9 @@ spring:
mode: never

jwt:
expiration: 3600000
expiration: ${JWT_EXPIRATION:6000000}
refresh:
expiration: 604800000
expiration: ${JWT_REFRESH_EXPIRATION:604800000}

---
spring:
Expand Down