feat(user-service): login 기능 및 cookie 생성 부분 변경

- login 시 refresh token parameter cookie 로 변경
- cookie 생성 시 secure false 로 변경
This commit is contained in:
bum12ark
2022-02-18 12:06:30 +09:00
parent 5cdb782870
commit d7dad90720
2 changed files with 3 additions and 6 deletions

View File

@@ -12,10 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseCookie;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
@@ -29,7 +26,7 @@ public class AuthController {
@GetMapping("/refreshToken") @GetMapping("/refreshToken")
public ResponseEntity<Result> refreshToken(@RequestHeader("X-AUTH-TOKEN") String accessToken, public ResponseEntity<Result> refreshToken(@RequestHeader("X-AUTH-TOKEN") String accessToken,
@RequestHeader("REFRESH-TOKEN") String refreshToken) { @CookieValue("refresh-token") String refreshToken) {
JwtTokenDto jwtTokenDto = refreshTokenServiceImpl.refreshJwtToken(accessToken, refreshToken); JwtTokenDto jwtTokenDto = refreshTokenServiceImpl.refreshJwtToken(accessToken, refreshToken);

View File

@@ -15,7 +15,7 @@ public class CookieProvider {
public ResponseCookie createRefreshTokenCookie(String refreshToken) { public ResponseCookie createRefreshTokenCookie(String refreshToken) {
return ResponseCookie.from("refresh-token", refreshToken) return ResponseCookie.from("refresh-token", refreshToken)
.httpOnly(true) .httpOnly(true)
.secure(true) .secure(false)
.path("/") .path("/")
.maxAge(Long.parseLong(refreshTokenExpiredTime)).build(); .maxAge(Long.parseLong(refreshTokenExpiredTime)).build();
} }