Skip to content

Commit

Permalink
fix: cookie ์„ค์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkenhw committed Oct 1, 2023
1 parent d4167fd commit 359f589
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,6 +22,7 @@

import static org.springframework.http.HttpHeaders.SET_COOKIE;

@Slf4j
@RestController
@RequiredArgsConstructor
public class AuthController {
Expand All @@ -45,8 +47,10 @@ public ResponseEntity<TokenResponse> 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()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Filter> corsFilter() {
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
Expand Down

0 comments on commit 359f589

Please sign in to comment.