Skip to content

Commit

Permalink
Merge pull request #35 from mju-likelion/feature/login-cookie-error-#24
Browse files Browse the repository at this point in the history
Feature/#24 로그인 시 Cookie 설정 문제
  • Loading branch information
Dh3356 authored Feb 28, 2024
2 parents 1e9d187 + 6389ae2 commit c0b5511
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.sameSite("None")
.maxAge(ZERO)
.path("/")
.domain("localhost")
.build();
response.addHeader("Set-Cookie", cookie.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import jakarta.servlet.http.HttpServletResponse;
import java.time.Duration;
import lombok.extern.slf4j.Slf4j;
import org.mjulikelion.baker.dto.request.auth.AuthLoginRequestDto;
import org.mjulikelion.baker.dto.response.ResponseDto;
import org.mjulikelion.baker.exception.AuthenticationException;
Expand All @@ -21,6 +22,7 @@
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AuthQueryServiceImpl implements AuthQueryService {
private final AuthenticationManagerBuilder authenticationManagerBuilder;
private final JwtTokenProvider jwtTokenProvider;
Expand Down Expand Up @@ -48,12 +50,14 @@ public ResponseEntity<ResponseDto<Void>> login(AuthLoginRequestDto authLoginRequ

ResponseCookie cookie = ResponseCookie.from(ACCESS_TOKEN, JwtEncoder.encodeJwtBearerToken(jwtToken))
.maxAge(Duration.ofMillis(cookieMaxAge))
.secure(true)
.sameSite("None")
.sameSite("None").secure(true)
.httpOnly(true)
.path(ROOT_PATH)
.domain("localhost")
.build();
response.addHeader("Set-Cookie", cookie.toString());
log.info("cookieString: {}", cookie);

response.addHeader("set-cookie", cookie.toString());
} catch (Exception e) {
throw new AuthenticationException(AUTHENTICATION_ERROR, e.getMessage());
}
Expand Down

0 comments on commit c0b5511

Please sign in to comment.