diff --git a/backend/src/main/java/com/carffeine/carffeine/auth/controller/AuthController.java b/backend/src/main/java/com/carffeine/carffeine/auth/controller/AuthController.java index f6973b612..ff8c4319c 100644 --- a/backend/src/main/java/com/carffeine/carffeine/auth/controller/AuthController.java +++ b/backend/src/main/java/com/carffeine/carffeine/auth/controller/AuthController.java @@ -10,6 +10,7 @@ import com.carffeine.carffeine.auth.service.dto.OAuthLoginRequest; import com.carffeine.carffeine.auth.service.dto.Tokens; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.GetMapping; @@ -21,6 +22,7 @@ import static org.springframework.http.HttpHeaders.SET_COOKIE; +@Slf4j @RestController @RequiredArgsConstructor public class AuthController { @@ -45,8 +47,10 @@ public ResponseEntity login( ) { OAuthMember oAuthMember = oAuthRequester.login(request, provider); Tokens tokens = authService.generateTokens(oAuthMember); + String cookie = refreshTokenCookieGenerator.createCookie(tokens.refreshToken()).toString(); + log.info("cookie ={}", cookie); return ResponseEntity.ok() - .header(SET_COOKIE, refreshTokenCookieGenerator.createCookie(tokens.refreshToken()).toString()) + .header(SET_COOKIE, cookie) .body(new TokenResponse(tokens.accessToken())); } diff --git a/backend/src/main/java/com/carffeine/carffeine/auth/controller/support/RefreshTokenCookieGenerator.java b/backend/src/main/java/com/carffeine/carffeine/auth/controller/support/RefreshTokenCookieGenerator.java index 8f98ca7af..5a12a928c 100644 --- a/backend/src/main/java/com/carffeine/carffeine/auth/controller/support/RefreshTokenCookieGenerator.java +++ b/backend/src/main/java/com/carffeine/carffeine/auth/controller/support/RefreshTokenCookieGenerator.java @@ -19,7 +19,7 @@ public class RefreshTokenCookieGenerator { public ResponseCookie createCookie(String refreshToken) { return ResponseCookie.from(REFRESH_TOKEN, refreshToken) - .maxAge(Duration.ofMillis(expireLength)) + .maxAge(Duration.ofHours(expireLength)) .path(VALID_COOKIE_PATH) .sameSite("None") .secure(true) diff --git a/backend/src/main/java/com/carffeine/carffeine/config/WebConfig.java b/backend/src/main/java/com/carffeine/carffeine/config/WebConfig.java index c09bc0a04..437190fb6 100644 --- a/backend/src/main/java/com/carffeine/carffeine/config/WebConfig.java +++ b/backend/src/main/java/com/carffeine/carffeine/config/WebConfig.java @@ -4,15 +4,13 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.servlet.Filter; -@Profile("!test") +//@Profile("!test") @Configuration public class WebConfig implements WebMvcConfigurer { - @Bean public FilterRegistrationBean corsFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>();