Conversation
…-및-redis-aof-rdb-고려 # Conflicts: # src/test/java/bumblebee/xchangepass/config/TestUserInitializer.java
…-및-redis-aof-rdb-고려 # Conflicts: # build.gradle
| ResponseCookie refreshCookie = loginService.saveRefreshToken(response); | ||
|
|
||
| return ResponseEntity.ok() | ||
| .header("Set-Cookie", accessCookie.toString()) |
There was a problem hiding this comment.
access 토큰도 쿠키로 반환하는 것일까요?
There was a problem hiding this comment.
네 accessToken을 localStorage에 저장하게 되면 XSS 공격 시 토큰이 노출될 수 있는데
이를 HttpOnly 쿠키에 저장하면 XSS에 더 안전하게 됩니다.
build.gradle
Outdated
| testImplementation "org.testcontainers:testcontainers:1.19.2" // Docker 기반 통합 테스트 지원 (Testcontainers 기본 라이브러리) | ||
| testImplementation "org.testcontainers:junit-jupiter:1.19.2" // JUnit 5(Testcontainers 연동) 지원 | ||
| testImplementation 'org.testcontainers:postgresql:1.19.2' | ||
| testImplementation "org.testcontainers:redis:1.19.1" |
There was a problem hiding this comment.
testImplementation 'com.redis:testcontainers-redis:2.2.2' // Redis용 Testcontainers (테스트 환경에서 Redis 컨테이너 실행) 이것과 다른 의존성인가요?
There was a problem hiding this comment.
알아보니 "org.testcontainers:redis:1.19.1"는
- Redis 클러스터 모드 테스트 (노드 여러 개로 분산)
- Redis Sentinel 기반 장애 조치 테스트
- Streams, Pub/Sub, RedisTimeSeries 등 특화 모듈 테스트
- 복잡한 상태 시뮬레이션 (failover, re-shard 등)
등의 고급 테스트 시나리오에 사용된다고 합니다.
저희 프로젝트는 단일 redis 인스턴스만을 띄우고 있기때문에 불필요하다고 판단합니다.
| return storedToken != null && storedToken.equals(refreshToken); | ||
| } | ||
|
|
||
| public String getRefreshToken(Long userId) { |
There was a problem hiding this comment.
일관성을 위해서 주석을 추가해주시면 감사하겠습니다
| Long userId = refreshTokenRepository.getUserIdFromRefreshToken(refreshToken); | ||
|
|
||
| // Redis에 저장된 토큰과 비교 → 재사용 감지 | ||
| String storedToken = refreshTokenRepository.getRefreshToken(userId); |
There was a problem hiding this comment.
이 로직으로 볼 때 Redis에 전에 사용했던 refreshToken을 누적시키는 것 처럼 보이는데 redis의 용량은 한정적인데 방안이 있을까요?
There was a problem hiding this comment.
RefreshToken Rotate방식을 적용해서 RefreshToken을 사용하면 레디스에서 삭제후 재발급하는 방식을 사용하고있습니다.
if (storedToken == null || !storedToken.equals(refreshToken)) {
// 이미 사용된 토큰 or 위조된 토큰 → 재사용 시도
refreshTokenRepository.deleteRefreshToken(userId); // Redis 강제 삭제
throw ErrorCode.REFRESH_TOKEN_INVALID.commonException();
}
| .secure(true) | ||
| .path("/") | ||
| .maxAge(60 * 60 * 24 * 7) | ||
| .sameSite("Strict") |
There was a problem hiding this comment.
sameStite 설정의 경우 https 도메인이 아니면 의미가 없는데 대체 방안이 있을까요?
There was a problem hiding this comment.
금융서비스 특징상 https를 사용할 것이라 생각해서 만들었습니다만 만약 아니라면
.sameSite("Lax")를 적용해서 최소한의 CSRF 방어하겠습니다
| .header("Set-Cookie", accessCookie.toString()) | ||
| .header("Set-Cookie", refreshCookie.toString()) |
There was a problem hiding this comment.
대체적으로 access 로컬 / refresh 쿠키로 저장하는게 일반적인데 access도 쿠키로 저장하는 이유가 있을까요?
| @@ -75,6 +79,13 @@ public void withdrawBalance(WalletBalance balance, BigDecimal amount) { | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
walletbalance 서버스도 다른 서버스와 같이 간단하게 주석을 추가해주실 수 있을까요?
🛠️ 과제 요약
📝 요구 사항과 구현 내용
✅ 피드백 반영사항
💬 PR 포인트 & 궁금한 점
🔗 연관된 이슈