Skip to content

Commit

Permalink
πŸš€ [Deploy] - λ‘œκ·Έμ•„μ›ƒ μ‹œ μΏ ν‚€ μ‚­μ œ 반영 (#175)
Browse files Browse the repository at this point in the history
* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ • (#154)

* Chore: λΆˆν•„μš”ν•œ λΆ€λΆ„ μ‚­μ œ (#157)

* πŸ› [Fix] - μž‘μ—… λͺ©λ‘ API μˆ˜μ • (#158)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* πŸ› [Fix] - PeerReview 단계 μ˜ˆμ™Έμ²˜λ¦¬ (#160)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* fix: PeerReview일 경우 μΆ”κ°€

* Chore: discord command 이름 λ³€κ²½ (#163)

* Hotfix: λΉ„λ°€λ²ˆν˜Έ 인증 둜직 μΆ”κ°€ (#165)

* πŸ–ŠοΈ [Chore] - README μˆ˜μ • (#168)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* fix: PeerReview일 경우 μΆ”κ°€

* Chore: ν”„λ‘œμ νŠΈ readme κΎΈλ―ΈκΈ°

* πŸ–ŠοΈ [Chore] - README μˆ˜μ • (#169)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* fix: PeerReview일 경우 μΆ”κ°€

* Chore: ν”„λ‘œμ νŠΈ readme κΎΈλ―ΈκΈ°

* chore: README μˆ˜μ •

* πŸ› [Fix] - 백둜그 νƒ€μž„λΌμΈ API (#171)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* fix: PeerReview일 경우 μΆ”κ°€

* Chore: ν”„λ‘œμ νŠΈ readme κΎΈλ―ΈκΈ°

* chore: README μˆ˜μ •

* fix: R&R μ •λ ¬ 였λ₯˜ ν•΄κ²°

* πŸ› [Fix] - λ‘œκ·Έμ•„μ›ƒ μ‹œ μΏ ν‚€ μ‚­μ œ (#174)

* refactor: μ½”λ“œ μŠ€νƒ€μΌ μˆ˜μ •

* fix: Work 생성 λ‚ μ§œ κΈ°μ€€μœΌλ‘œ λ‚΄λ¦Όμ°¨μˆœ μ„€μ •

* fix: PeerReview일 경우 μΆ”κ°€

* Chore: ν”„λ‘œμ νŠΈ readme κΎΈλ―ΈκΈ°

* chore: README μˆ˜μ •

* Fix: λ‘œκ·Έμ•„μ›ƒ μ‹œ, μΏ ν‚€ μ‚­μ œ μ½”λ“œ μˆ˜μ •

---------

Co-authored-by: Lim jeong woo <[email protected]>
  • Loading branch information
JeongHeumChoi and dlawjddn authored May 3, 2024
1 parent 17fc76c commit 9fb042f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;
Expand All @@ -17,12 +18,17 @@
@Slf4j
@Component
public class CustomLogoutResultHandler implements LogoutSuccessHandler {

@Value("${server.domain}")
private String domain;

@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
if (authentication == null){
log.info("인증 정보가 μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. authentication is null..");
AuthenticationResponse.makeFailureResponse(response, ErrorCode.NOT_FOUND_USER);
}
CookieUtil.logoutCookie(request, response, domain);
CookieUtil.deleteCookie(request, response, Constants.ACCESS_COOKIE_NAME);
CookieUtil.deleteCookie(request, response, Constants.REFRESH_COOKIE_NAME);
AuthenticationResponse.makeSuccessResponse(response);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/goormthon/team28/startup_valley/util/CookieUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package goormthon.team28.startup_valley.util;

import goormthon.team28.startup_valley.constants.Constants;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand All @@ -17,6 +18,29 @@ public static void addCookie(HttpServletResponse response, String domain, String

response.addHeader("Set-Cookie", cookie.toString());
}

public static void logoutCookie(HttpServletRequest request, HttpServletResponse response, String domain) {
Cookie[] cookies = request.getCookies();
if (cookies == null)
return;

for (Cookie cookie : cookies) {
boolean isAccessCookie = cookie.getName().equals(Constants.ACCESS_COOKIE_NAME);
boolean isRefreshCookie = cookie.getName().equals(Constants.REFRESH_COOKIE_NAME);

if (isAccessCookie || isRefreshCookie) {
ResponseCookie tempCookie = ResponseCookie.from(cookie.getName(), cookie.getValue())
.path("/")
.domain(domain)
.secure(true)
.maxAge(0)
.httpOnly(isRefreshCookie)
.build();
response.addHeader("Set-Cookie", tempCookie.toString());
}
}
}

public static void addSecureCookie(HttpServletResponse response, String domain, String key, String value, Integer maxAge){
Cookie cookie = new Cookie(key, value);
cookie.setPath("/");
Expand All @@ -26,6 +50,7 @@ public static void addSecureCookie(HttpServletResponse response, String domain,
cookie.setMaxAge(maxAge);
response.addCookie(cookie);
}

public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name){
Cookie[] cookies = request.getCookies();
if (cookies == null){
Expand Down

0 comments on commit 9fb042f

Please sign in to comment.