-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 회원 로그아웃을 구현한다. (#80) * feat: Test Container 의존성 추가 (#73) * feat: RedisTestContainerConfig 구현 (#73) * feat: IntegrationTest 적용 (#73) * test: 회원 탈퇴 API 통합 테스트 진행 (with redis) (#73) * fix: SonarCloud 에러 수정 (#73) * fix: SonarCloud 에러 수정 (#73) * feat: 통합 테스트 RedisService 의존성 추가 및 Repository Redis 관련 메소드 추가 (#73) * refactor: SecurityService clearSecurityContext 메소드 추가 (#73) * feat: 회원 로그아웃 API 구현 (#52) * test: 회원 로그아웃 통합 테스트 구현 (#52) * refactor: UserService 코드 리팩토링 (코드 리뷰 반영) (#52) * feat: Security 관련 클래스 추가 구현 및 기타 코드 수정 (#84) * feat: static 경로 설정 (#83) * chore: jwt 관련 binding 의존성 추가 (#83) * chore: 라이브러리 버전 추가 (#83) * refactor: 인증 관련 코드 리팩토링 (#83) * feat: ErrorResponse static 메서드 추가 (#83) * feat: SecurityConfig 추가 구현 (#83) * refactor: 기존 API & 코드 리팩토링 및 누락된 테스트 코드 구현 (#82) * refactor: 유저 관련 API url 리팩토링 (#81) * refactor: 기존 테스트 관련 클래스 리팩토링 (#81) * refactor: 기존 코드 리팩토링 (#81) * feat: Redis Test Container 구성 및 회원 탈퇴 테스트 진행 (#79) * feat: Test Container 의존성 추가 (#73) * feat: RedisTestContainerConfig 구현 (#73) * feat: IntegrationTest 적용 (#73) * test: 회원 탈퇴 API 통합 테스트 진행 (with redis) (#73) * fix: SonarCloud 에러 수정 (#73) * fix: SonarCloud 에러 수정 (#73) * refactor: 버전 관리 분리 (코드 리뷰 반영) (#52) * fix: CI Integration Tester 에러 수정 (#73)
- Loading branch information
1 parent
8c97dce
commit 3d1bd23
Showing
19 changed files
with
308 additions
and
88 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
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
20 changes: 12 additions & 8 deletions
20
src/main/java/net/teumteum/core/security/filter/JwtAuthenticationEntryPoint.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,30 +1,34 @@ | ||
package net.teumteum.core.security.filter; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.teumteum.core.error.ErrorResponse; | ||
import org.springframework.security.core.AuthenticationException; | ||
import org.springframework.security.web.AuthenticationEntryPoint; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
|
||
import static jakarta.servlet.http.HttpServletResponse.SC_UNAUTHORIZED; | ||
|
||
@Slf4j | ||
@Component | ||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { | ||
|
||
@Override | ||
public void commence(HttpServletRequest request, | ||
HttpServletResponse response, | ||
AuthenticationException authenticationException | ||
HttpServletResponse response, | ||
AuthenticationException authenticationException | ||
) throws IOException { | ||
this.sendUnAuthenticatedError(response, authenticationException); | ||
} | ||
|
||
private void sendUnAuthenticatedError(HttpServletResponse response, | ||
Exception exception) throws IOException { | ||
Exception exception) throws IOException { | ||
OutputStream os = response.getOutputStream(); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
log.error("Responding with unauthenticated error. Message - {}", exception.getMessage()); | ||
response.sendError(SC_UNAUTHORIZED, exception.getMessage()); | ||
objectMapper.writeValue(os, ErrorResponse.of("인증 과정에서 오류가 발생했습니다.")); | ||
os.flush(); | ||
} | ||
} |
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
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
25 changes: 25 additions & 0 deletions
25
src/test/java/net/teumteum/core/config/RedisTestContainerConfig.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,25 @@ | ||
package net.teumteum.core.config; | ||
|
||
import org.junit.jupiter.api.extension.BeforeAllCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@Testcontainers | ||
public class RedisTestContainerConfig implements BeforeAllCallback { | ||
|
||
private static final String REDIS_IMAGE = "redis:7.0.8-alpine"; | ||
private static final int REDIS_PORT = 6379; | ||
|
||
private GenericContainer redis; | ||
|
||
@Override | ||
public void beforeAll(ExtensionContext context) throws Exception { | ||
redis = new GenericContainer(DockerImageName.parse(REDIS_IMAGE)).withExposedPorts(REDIS_PORT); | ||
|
||
redis.start(); | ||
System.setProperty("spring.data.redis.host", redis.getHost()); | ||
System.setProperty("spring.data.redis.port", String.valueOf(redis.getMappedPort(REDIS_PORT))); | ||
} | ||
} |
Oops, something went wrong.