Skip to content

Commit 95ee4da

Browse files
committed
Refactor(Auth): client 주소 분리
1 parent c786cb9 commit 95ee4da

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/wonjun/stiky/auth/config/OAuth2SuccessHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.UUID;
99
import java.util.concurrent.TimeUnit;
1010
import lombok.RequiredArgsConstructor;
11+
import org.springframework.beans.factory.annotation.Value;
1112
import org.springframework.data.redis.core.RedisTemplate;
1213
import org.springframework.security.core.Authentication;
1314
import org.springframework.security.oauth2.core.user.OAuth2User;
@@ -23,6 +24,9 @@ public class OAuth2SuccessHandler extends SimpleUrlAuthenticationSuccessHandler
2324
private final JwtTokenProvider jwtTokenProvider;
2425
private final RedisTemplate<String, Object> redisTemplate;
2526

27+
@Value("${openapi.client-url}")
28+
private String url;
29+
2630
@Override
2731
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
2832
Authentication authentication) throws IOException, ServletException {
@@ -34,9 +38,10 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
3438
redisTemplate.opsForValue().set("RT:" + email, tokenDto.getRefreshToken(), 7, TimeUnit.DAYS);
3539

3640
String code = UUID.randomUUID().toString();
37-
redisTemplate.opsForValue().set("LOGIN_CODE:" + code, tokenDto.getAccessToken(), 60, TimeUnit.DAYS.SECONDS);
41+
redisTemplate.opsForValue().set("LOGIN_CODE:" + code, tokenDto.getAccessToken(), 60, TimeUnit.SECONDS);
42+
redisTemplate.opsForValue().set("LOGIN_CODE:" + code + ":RT", tokenDto.getRefreshToken(), 60, TimeUnit.SECONDS);
3843

39-
String targetUrl = UriComponentsBuilder.fromUriString("http://localhost:3000/login/callback") // TODO: 변경하기
44+
String targetUrl = UriComponentsBuilder.fromUriString(url + "/login/callback")
4045
.queryParam("code", code)
4146
.build().toUriString();
4247

src/main/resources/application-prod.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ spring:
3131
- profile
3232

3333
openapi:
34-
server-url: https://www.stiky.site
34+
server-url: https://api.stiky.site
35+
client-url: https://www.stiky.site
3536

3637
jwt:
3738
secret: ${JWT_SECRET}

0 commit comments

Comments
 (0)