fix: 관리자 게시판 연관상품 이미지 및 로컬 인증 보정
This commit is contained in:
@@ -197,11 +197,12 @@ public class MngrLoginController {
|
||||
log.debug("리프레쉬 토큰이 없는 경우 realm :: {}", realm);
|
||||
|
||||
//엑세스토큰 삭제
|
||||
CookieUtils.deleteCookie("ACT","/"+realm, request, response);
|
||||
CookieUtils.deleteCookie("token_expire","/"+realm, request, response);
|
||||
CookieUtils.deleteCookie("ACT","/", request, response);
|
||||
CookieUtils.deleteCookie("RFT","/" + realm + "/tokens/refresh", request, response);
|
||||
CookieUtils.deleteCookie("token_expire","/", request, response);
|
||||
|
||||
response.sendRedirect("/"+realm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//리프레쉬 토큰 있을 경우(존재한다는 자체가 refresh토큰이 만료된 상태가 아님)
|
||||
|
||||
@@ -371,7 +371,9 @@ public class MngrLoggingInterceptor implements HandlerInterceptor {
|
||||
String cookieValue = agentId + ":" + md5(agentId + ":" + md5(System.currentTimeMillis() + ":" + random.nextInt())).substring(5, 10);
|
||||
Cookie agentIdCookie = new Cookie("agent_id", cookieValue);
|
||||
agentIdCookie.setMaxAge(86400 * 365 * 10); // 10년
|
||||
agentIdCookie.setDomain(domain);
|
||||
if (!request.getServerName().startsWith("loc.")) {
|
||||
agentIdCookie.setDomain(domain);
|
||||
}
|
||||
// agentIdCookie.setHttpOnly(true);
|
||||
agentIdCookie.setPath("/mngr");
|
||||
// agentIdCookie.setSecure(true);
|
||||
|
||||
@@ -44,9 +44,12 @@ public abstract class CookieUtils {
|
||||
Cookie cookie = new Cookie(name, null);
|
||||
cookie.setMaxAge(0);
|
||||
cookie.setPath(path);
|
||||
cookie.setDomain(originHost);
|
||||
setCookieDomain(cookie, request, originHost);
|
||||
cookie.setHttpOnly(true);
|
||||
response.addCookie(cookie);
|
||||
|
||||
// loc 환경에서는 이전에 상위 도메인으로 저장된 쿠키도 함께 삭제한다.
|
||||
deleteLegacyDomainCookie(name, path, request, response, originHost);
|
||||
}
|
||||
|
||||
public static void createCookie(String name, String value, String path, int maxAge, boolean httpOnly, HttpServletRequest request, HttpServletResponse response) {
|
||||
@@ -58,10 +61,12 @@ public abstract class CookieUtils {
|
||||
|
||||
String originHost = UrlExtractor.getOriginalHost(host);
|
||||
|
||||
deleteLegacyDomainCookie(name, path, request, response, originHost);
|
||||
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setMaxAge(maxAge);
|
||||
cookie.setPath(path);
|
||||
cookie.setDomain(originHost);
|
||||
setCookieDomain(cookie, request, originHost);
|
||||
cookie.setHttpOnly(httpOnly);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
@@ -77,7 +82,7 @@ public abstract class CookieUtils {
|
||||
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setPath(path);
|
||||
cookie.setDomain(originHost);
|
||||
setCookieDomain(cookie, request, originHost);
|
||||
cookie.setHttpOnly(httpOnly);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
@@ -96,4 +101,30 @@ public abstract class CookieUtils {
|
||||
return Map.of("ACTPath", ACTPath, "RFTPath", RFTPath);
|
||||
}
|
||||
|
||||
private static void setCookieDomain(Cookie cookie, HttpServletRequest request, String domain) {
|
||||
if (!request.getServerName().startsWith("loc.")) {
|
||||
cookie.setDomain(domain);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteLegacyDomainCookie(String name, String path, HttpServletRequest request, HttpServletResponse response, String domain) {
|
||||
if (request.getServerName().startsWith("loc.")) {
|
||||
addDomainDeleteCookie(name, path, domain, response);
|
||||
|
||||
int firstDot = domain.indexOf('.');
|
||||
if (firstDot > 0) {
|
||||
addDomainDeleteCookie(name, path, domain.substring(firstDot + 1), response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addDomainDeleteCookie(String name, String path, String domain, HttpServletResponse response) {
|
||||
Cookie domainCookie = new Cookie(name, null);
|
||||
domainCookie.setMaxAge(0);
|
||||
domainCookie.setPath(path);
|
||||
domainCookie.setDomain(domain);
|
||||
domainCookie.setHttpOnly(true);
|
||||
response.addCookie(domainCookie);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user