-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
security 기본 로그아웃 사용 저장된 refresh token 삭제하는 핸들러 추가 related to: #11
- Loading branch information
1 parent
d73ca78
commit 74afe97
Showing
3 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/_119/wepro/global/handler/CustomLogoutHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com._119.wepro.global.handler; | ||
|
||
import com._119.wepro.global.security.JwtTokenProvider; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.web.authentication.logout.LogoutHandler; | ||
|
||
@RequiredArgsConstructor | ||
public class CustomLogoutHandler implements LogoutHandler { | ||
|
||
private final JwtTokenProvider jwtTokenProvider; | ||
|
||
@Override | ||
public void logout(HttpServletRequest request, HttpServletResponse response, | ||
Authentication authentication) { | ||
|
||
String providerId = authentication.getName(); | ||
jwtTokenProvider.deleteInvalidRefreshToken(providerId); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/_119/wepro/global/handler/CustomLogoutSuccessHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com._119.wepro.global.handler; | ||
|
||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; | ||
|
||
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler { | ||
|
||
@Override | ||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, | ||
Authentication authentication) throws IOException, ServletException { | ||
|
||
response.setStatus(HttpServletResponse.SC_OK); | ||
response.getWriter().flush(); | ||
} | ||
} |