feat: impl BoundedBCryptPasswordEncoder and Redis cache configuration - #65
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughBCrypt 인증 동시성 제한, Redis 사용자 응답 캐시, 사용자 상태 변경 후 캐시 무효화, 정지·탈퇴 계정 인증 검사가 추가되었습니다. Changes인증 처리량 제한
사용자 캐시 및 인증 연동
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant OAuth2UserDetailsService
participant UserCacheService
participant RedisCacheManager
participant UserRepository
participant UserSessionEventListener
OAuth2UserDetailsService->>UserCacheService: 정규화된 이메일로 UserResponse 조회
UserCacheService->>RedisCacheManager: user_dtos 캐시 조회
alt 캐시 미스
UserCacheService->>UserRepository: 사용자 조회
UserRepository-->>UserCacheService: User
UserCacheService->>RedisCacheManager: UserResponse 저장
end
UserCacheService-->>OAuth2UserDetailsService: UserResponse
UserSessionEventListener->>RedisCacheManager: 커밋 후 user_dtos 캐시 제거
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
momogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.java (1)
74-87: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
LOGIN_SERVER_BUSY이 인증 실패 핸들러를 통과하도록 예외를 감싸세요.
BusinessException은AuthenticationException이 아니므로,UsernamePasswordAuthenticationFilter의onAuthenticationFailure(handler)호출에는 전달되지 않습니다. 이 경우/api/auth/sign-in에서 정의한 503/AUTH-6014응답이 나오지 않고, 일반 전역 예외 핸들러나 서블릿 오류 경로를 타게 됩니다.
PasswordEncoder.matches(...)내부에서BusinessException(AuthErrorCode.LOGIN_SERVER_BUSY)가 발생할 때,AuthenticationException(예:InternalAuthenticationServiceException)에 wrapping하여AuthenticationFailureHandler가 처리할 수 있도록 바꾸거나, 이 코드 경로에서 의도한 503 응답을 필터 예외 처리 전에 별도 처리하세요.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@momogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.java` around lines 74 - 87, Update the interrupted-operation path in BoundedBCryptPasswordEncoder so LOGIN_SERVER_BUSY is propagated as an AuthenticationException, such as InternalAuthenticationServiceException, rather than only as BusinessException. Preserve the existing error code, 503 response mapping, and interrupt restoration while ensuring UsernamePasswordAuthenticationFilter routes the failure through its AuthenticationFailureHandler.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@momogo-api/src/main/java/com/momogo/api/auth/details/OAuth2UserDetailsService.java`:
- Around line 69-70: Move cache writes and invalidations for user state changes
to execute only after transaction commit. In
OAuth2UserDetailsService.java:69-70, remove getUserResponseCached(String
normalizedEmail) from the transactional registerSocialUser()/user.restore()
path, retaining only the existing-user cache lookup or adding a post-commit
refresh. In UserServiceImpl.java:122, 215-219, 254, and 379, update user change,
deletion, restoration, and ban-status cache handling to use
CommitTransactionApplicationEvent with AFTER_COMMIT, or
TransactionSynchronizationManager.afterCommit(), and consolidate
restoration/deletion invalidation through the existing UserSessionEventListener
user-event pattern.
In
`@momogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.java`:
- Around line 39-42: Validate maxConcurrency in the BoundedBCryptPasswordEncoder
constructor and explicitly reject values below 1 before creating the Semaphore.
Preserve the existing initialization for valid values so misconfigured
deployments fail at startup rather than allowing an unusable semaphore.
In
`@momogo-core/src/main/java/com/momogo/core/domain/user/service/UserCacheService.java`:
- Around line 34-43: JWT 인증 경로의 loadUserByUsernameForToken()에서 deletedAt을 무시하지
않도록 활성 사용자 조건을 적용하십시오. UserResponse.deletedAt을 기준으로 탈퇴 대기·만료 사용자가
MoMoGoUserDetails로 생성되지 않게 하고, isEnabled() 및 isAccountNonLocked() 검사가 동일한 활성 사용자
기준을 사용하도록 수정하십시오. 기존 로그인 경로의 탈퇴 검증 기준과 일치시키되 다른 캐시 조회 동작은 유지하십시오.
---
Nitpick comments:
In
`@momogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.java`:
- Around line 74-87: Update the interrupted-operation path in
BoundedBCryptPasswordEncoder so LOGIN_SERVER_BUSY is propagated as an
AuthenticationException, such as InternalAuthenticationServiceException, rather
than only as BusinessException. Preserve the existing error code, 503 response
mapping, and interrupt restoration while ensuring
UsernamePasswordAuthenticationFilter routes the failure through its
AuthenticationFailureHandler.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 54719453-83fa-44a9-b75f-5c52e1536928
📒 Files selected for processing (10)
momogo-api/src/main/java/com/momogo/api/auth/config/SecurityConfig.javamomogo-api/src/main/java/com/momogo/api/auth/details/MoMoGoUserDetailsService.javamomogo-api/src/main/java/com/momogo/api/auth/details/OAuth2UserDetailsService.javamomogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.javamomogo-api/src/main/java/com/momogo/api/common/config/CacheConfig.javamomogo-api/src/main/resources/application.yamlmomogo-core/build.gradlemomogo-core/src/main/java/com/momogo/core/common/exception/AuthErrorCode.javamomogo-core/src/main/java/com/momogo/core/domain/user/service/UserCacheService.javamomogo-core/src/main/java/com/momogo/core/domain/user/service/UserServiceImpl.java
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@momogo-api/src/main/java/com/momogo/api/auth/listener/UserSessionEventListener.java`:
- Around line 62-70: Remove the `@Async` annotation from handleUserCacheEvictEvent
so the USER_DTO_CACHE eviction runs synchronously after the transaction commits.
Leave the `@TransactionalEventListener` configuration and existing cache eviction
logic unchanged.
In
`@momogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.java`:
- Around line 40-42: BoundedBCryptPasswordEncoder의 초기화 검증에 acquireTimeoutMs 음수
거부 조건을 추가하세요. acquireTimeoutMs가 0인 fail-fast 설정은 허용하고, 0보다 작은 경우에만 명확한
IllegalArgumentException을 발생시키도록 기존 maxConcurrency 검증과 같은 시작 시점 검증 흐름을 유지하세요.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f3fed343-1e80-42ac-95c1-aea9437e072e
📒 Files selected for processing (8)
momogo-api/src/main/java/com/momogo/api/auth/details/MoMoGoUserDetails.javamomogo-api/src/main/java/com/momogo/api/auth/details/OAuth2UserDetailsService.javamomogo-api/src/main/java/com/momogo/api/auth/handler/LoginFailureHandler.javamomogo-api/src/main/java/com/momogo/api/auth/jwt/JwtAuthenticationFilter.javamomogo-api/src/main/java/com/momogo/api/auth/listener/UserSessionEventListener.javamomogo-api/src/main/java/com/momogo/api/auth/security/BoundedBCryptPasswordEncoder.javamomogo-core/src/main/java/com/momogo/core/domain/user/event/UserCacheEvictEvent.javamomogo-core/src/main/java/com/momogo/core/domain/user/service/UserServiceImpl.java
… into feature/login-refactor # Conflicts: # momogo-core/build.gradle
idktomorrow
left a comment
There was a problem hiding this comment.
저는 따로 문제점 없어 보입니다! 고생 많으셨습니다 ❤️
작업 내용
변경 사항
체크리스트
참고 사항
관련 이슈
Summary by CodeRabbit
요약
새 기능
버그 수정
개선 사항