-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat] : 로그아웃 및 회원탈퇴 기능 구현 #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f2b816e
feat: CookieUtil을 개발서버용과 배포서버용으로 분리
yooooonshine be637e6
feat: 로그아웃기능 구현
yooooonshine 9996297
feat: 유저탈퇴 기능 구현
yooooonshine f83b904
Merge branch 'develop' of https://github.com/Modic-2025/modic_backend…
yooooonshine 34b5a19
feat: 로직 변경에 따른 테스트 코드 변경
yooooonshine f832a23
refactor: Cookie를 ResponseCookie로 변경
yooooonshine 564fba0
refactor: 탈퇴한 회원 로그인 막는 기능 구현
yooooonshine 58e0f6f
refactor: 회원탈퇴 시 토큰도 초기화
yooooonshine f499194
refactor: WITHDRAW 유저 Security 단에서 차단
yooooonshine d2d34d8
refactor: 로그아웃 로직 순서 변경
yooooonshine 9268fb8
refactor: jwtTokenProvider.extractAccessToken(request).get()에서orElse를…
yooooonshine 752481c
refactor: 코드 수정에 따른 테스트 코드 수정
yooooonshine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
18 changes: 4 additions & 14 deletions
18
src/main/java/hanium/modic/backend/domain/auth/util/CookieUtil.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,19 +1,9 @@ | ||
| package hanium.modic.backend.domain.auth.util; | ||
|
|
||
| import jakarta.servlet.http.Cookie; | ||
| import org.springframework.http.ResponseCookie; | ||
|
|
||
| public class CookieUtil { | ||
| public interface CookieUtil { | ||
| ResponseCookie createRefreshCookie(final String refreshToken); | ||
|
|
||
| private static final String REFRESH_TOKEN_COOKIE_NAME = "refreshToken"; | ||
|
|
||
| private static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 3; | ||
|
|
||
| public static Cookie createRefreshCookie(final String refreshToken) { | ||
| Cookie cookie = new Cookie(REFRESH_TOKEN_COOKIE_NAME, refreshToken); | ||
| cookie.setHttpOnly(true); | ||
| cookie.setPath("/"); | ||
| // cookie.setSecure(true); // Todo: https://github.com/Modic-2025/modic_backend/issues/39 | ||
| cookie.setMaxAge(COOKIE_MAX_AGE); | ||
| return cookie; | ||
| } | ||
| ResponseCookie deleteRefreshCookie(); | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/main/java/hanium/modic/backend/domain/auth/util/DevCookieUtil.java
This file contains hidden or 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,35 @@ | ||
| package hanium.modic.backend.domain.auth.util; | ||
|
|
||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.http.ResponseCookie; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| // 개발 환경용 쿠키 유틸리티 | ||
| @Component | ||
| @Profile({"local", "dev", "test"}) | ||
| public class DevCookieUtil implements CookieUtil { | ||
|
|
||
| private static final String REFRESH_TOKEN_COOKIE_NAME = "refreshToken"; | ||
|
|
||
| private static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 3; | ||
|
|
||
| public ResponseCookie createRefreshCookie(final String refreshToken) { | ||
| return ResponseCookie.from(REFRESH_TOKEN_COOKIE_NAME, refreshToken) | ||
| .httpOnly(true) | ||
| .secure(true) | ||
| .path("/") | ||
| .maxAge(COOKIE_MAX_AGE) | ||
| .sameSite("Lax") // 또는 "Strict" | ||
| .build(); | ||
| } | ||
|
|
||
| public ResponseCookie deleteRefreshCookie() { | ||
| return ResponseCookie.from(REFRESH_TOKEN_COOKIE_NAME, "") | ||
| .httpOnly(true) | ||
| .secure(true) | ||
| .path("/") | ||
| .maxAge(0) | ||
| .sameSite("Lax") | ||
| .build(); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
src/main/java/hanium/modic/backend/domain/auth/util/ProdCookieUtil.java
This file contains hidden or 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,37 @@ | ||
| package hanium.modic.backend.domain.auth.util; | ||
|
|
||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.http.ResponseCookie; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import jakarta.servlet.http.Cookie; | ||
|
|
||
| // Production 환경용 쿠키 유틸리티 | ||
| @Component | ||
| @Profile({"main"}) | ||
| public class ProdCookieUtil implements CookieUtil { | ||
|
|
||
| private static final String REFRESH_TOKEN_COOKIE_NAME = "refreshToken"; | ||
|
|
||
| private static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 3; | ||
|
|
||
| public ResponseCookie createRefreshCookie(final String refreshToken) { | ||
| return ResponseCookie.from(REFRESH_TOKEN_COOKIE_NAME, refreshToken) | ||
| .httpOnly(true) | ||
| .secure(true) | ||
| .path("/") | ||
| .maxAge(COOKIE_MAX_AGE) | ||
| .sameSite("Lax") // 또는 "Strict" | ||
| .build(); | ||
| } | ||
|
|
||
| public ResponseCookie deleteRefreshCookie() { | ||
| return ResponseCookie.from(REFRESH_TOKEN_COOKIE_NAME, "") | ||
| .httpOnly(true) | ||
| .secure(true) | ||
| .path("/") | ||
| .maxAge(0) | ||
| .sameSite("Lax") | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or 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
4 changes: 3 additions & 1 deletion
4
src/main/java/hanium/modic/backend/domain/user/enums/UserRole.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| package hanium.modic.backend.domain.user.enums; | ||
|
|
||
| public enum UserRole { | ||
| ADMIN, USER | ||
| ADMIN, | ||
| USER, | ||
| WITHDRAWN | ||
yooooonshine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모든 요청에 인증을 요구하면 로그인이 불가능합니다.
.anyRequest().authenticated()로 변경하면 로그인, 회원가입, 이메일 인증 등의 공개 엔드포인트도 인증을 요구하게 되어 사용자가 로그인할 수 없습니다.다음과 같이 공개 엔드포인트를 명시적으로 허용해야 합니다:
📝 Committable suggestion
🤖 Prompt for AI Agents