-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from EFUB4-Jukebox/feat/auth
[Feat] 로그인/로그아웃/회원 탈퇴 기능 구현
- Loading branch information
Showing
17 changed files
with
238 additions
and
36 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
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
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
9 changes: 9 additions & 0 deletions
9
src/main/java/sws/songpin/domain/member/dto/request/ProfileDeactivateRequestDto.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,9 @@ | ||
package sws.songpin.domain.member.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record ProfileDeactivateRequestDto( | ||
@NotBlank(message = "INVALID_INPUT_VALUE-비밀번호는 한 글자 이상 입력해야 합니다.") | ||
String password | ||
) { | ||
} |
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
9 changes: 5 additions & 4 deletions
9
src/main/java/sws/songpin/domain/member/dto/response/LoginResponseDto.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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package sws.songpin.domain.member.dto.response; | ||
|
||
public record LoginResponseDto( | ||
String accessToken, | ||
String refreshToken | ||
) { } | ||
public record LoginResponseDto ( | ||
String accessToken | ||
){ | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/sws/songpin/domain/member/dto/response/TokenDto.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,13 @@ | ||
package sws.songpin.domain.member.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
public record TokenDto( | ||
String accessToken, | ||
String refreshToken, | ||
int refreshTokenMaxAge | ||
) { | ||
public TokenDto(String accessToken, String refreshToken){ | ||
this(accessToken,refreshToken,7*24*60*60); | ||
} | ||
} |
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
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
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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/sws/songpin/global/auth/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,33 @@ | ||
package sws.songpin.global.auth; | ||
|
||
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; | ||
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; | ||
import org.springframework.stereotype.Component; | ||
import sws.songpin.global.exception.CustomException; | ||
import sws.songpin.global.exception.ErrorCode; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class CustomLogoutHandler implements LogoutHandler { | ||
|
||
private final RedisService redisService; | ||
|
||
@Override | ||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { | ||
|
||
if(authentication!=null && authentication.getName() != null){ | ||
//Redis 에서 Refresh Token 삭제 | ||
redisService.deleteValues(authentication.getName()); | ||
|
||
// 기본 로그아웃 핸들러 기능 수행 | ||
SecurityContextLogoutHandler securityContextLogoutHandler = new SecurityContextLogoutHandler(); | ||
securityContextLogoutHandler.logout(request, response, authentication); | ||
} else{ | ||
throw new CustomException(ErrorCode.NOT_AUTHENTICATED); | ||
} | ||
} | ||
} |
Oops, something went wrong.