diff --git a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java index 9a20eeb9..ae027d64 100644 --- a/src/main/java/coffeemeet/server/admin/presentation/AdminController.java +++ b/src/main/java/coffeemeet/server/admin/presentation/AdminController.java @@ -25,7 +25,9 @@ import coffeemeet.server.report.service.dto.ReportDetailDto; import coffeemeet.server.report.service.dto.ReportListDto; import coffeemeet.server.report.service.dto.ReportSummary; +import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; import jakarta.validation.Valid; import java.util.List; @@ -61,12 +63,20 @@ public class AdminController { @PostMapping("/login") public ResponseEntity login( HttpServletRequest httpServletRequest, + HttpServletResponse httpServletResponse, @Valid @RequestBody AdminLoginHTTP.Request request ) { adminService.login(request.id(), request.password()); HttpSession session = httpServletRequest.getSession(); session.setAttribute(ADMIN_SESSION_ATTRIBUTE, request.id()); session.setMaxInactiveInterval(1800); + + Cookie sessionCookie = new Cookie("JSESSIONID", session.getId()); + sessionCookie.setPath("/"); + sessionCookie.setHttpOnly(true); + sessionCookie.setSecure(true); + sessionCookie.setDomain(".coffee-meet.com"); + httpServletResponse.addCookie(sessionCookie); return ResponseEntity.ok().build(); } diff --git a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java index 31513ca0..bca26f0d 100644 --- a/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java +++ b/src/test/java/coffeemeet/server/admin/presentation/AdminControllerTest.java @@ -106,7 +106,7 @@ void loginTest() throws Exception { @Test @DisplayName("관리자 로그아웃 할 수 있다.") - void name() throws Exception { + void logoutTest() throws Exception { // given, when, then mockMvc.perform(post(baseUrl + "/logout") .header(JSESSION, SESSION_VALUE)