Skip to content

[KW-33] feat/admin-auth#5

Merged
willjsw merged 12 commits intodevelopfrom
KW-33/feat/admin-auth
May 3, 2025
Merged

[KW-33] feat/admin-auth#5
willjsw merged 12 commits intodevelopfrom
KW-33/feat/admin-auth

Conversation

@willjsw
Copy link
Contributor

@willjsw willjsw commented May 3, 2025

🔷 Jira Ticket ID

KW-33


📌 작업 내용 및 특이사항

  • Admin service 제반 세팅 및 Login/Logout 구현
  • 기본 구조는 member service와 동일합니다.

📚 참고사항

@willjsw willjsw self-assigned this May 3, 2025
@willjsw willjsw requested a review from Copilot May 3, 2025 02:24
@github-actions github-actions bot changed the title KW-33/feat/admin auth [KW-33] feat/admin auth May 3, 2025
@willjsw willjsw requested review from coffeesigma and midday2612 May 3, 2025 02:24
@willjsw willjsw changed the title [KW-33] feat/admin auth [KW-33] feat/admin-auth May 3, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements admin authentication by integrating Redis caching alongside JWT-based login/logout functionality for the Admin service following a pattern similar to the Member service.

  • Added Redis configuration and properties for token caching.
  • Introduced authentication endpoints with login, logout, and token reissue logic.
  • Updated error codes and security configurations to support admin-specific authentication.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/resources/application.yml Updated configuration to include redis settings.
src/main/java/com/doubleo/adminservice/infra/config/redis/RedisProperties.java Added Redis properties as a record type.
src/main/java/com/doubleo/adminservice/infra/config/redis/RedisConfig.java Configures Redis connection with Lettuce; consider braces in if.
src/main/java/com/doubleo/adminservice/infra/config/properties/PropertiesConfig.java Enabled configuration properties binding for JWT and Redis.
src/main/java/com/doubleo/adminservice/infra/config/jwt/JwtProperties.java Defined JWT properties using record with helper methods.
src/main/java/com/doubleo/adminservice/global/exception/errorcode/AdminErrorCode.java Added new admin-specific error codes.
src/main/java/com/doubleo/adminservice/global/config/security/WebSecurityConfig.java Configured web security with stateless session management.
src/main/java/com/doubleo/adminservice/domain/auth/service/JwtTokenServiceImpl.java Implements token generation, refresh, and blacklist logic.
src/main/java/com/doubleo/adminservice/domain/auth/service/AuthServiceImpl.java Implements admin login and logout with token handling.
src/main/java/com/doubleo/adminservice/domain/auth/controller/AuthController.java Provides REST endpoints for authentication operations.
... (other files supporting auth domain such as DTOs, repositories, and domain models)
Comments suppressed due to low confidence (1)

src/main/java/com/doubleo/adminservice/domain/auth/controller/AuthController.java:78

  • The reissueAccessTokenIfExpired method may return null if the token is not expired, which could lead to a NullPointerException in the subsequent header update. Consider handling the null case before using newAccessTokenDto.
AccessTokenDto newAccessTokenDto = jwtTokenService.reissueAccessTokenIfExpired(oldAccessToken);

Comment on lines 23 to 24
if (!redisProperties.password().isBlank())
redisStandaloneConfig.setPassword(redisProperties.password());
Copy link

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding braces around the if-statement to improve readability and avoid potential errors in future modifications.

Suggested change
if (!redisProperties.password().isBlank())
redisStandaloneConfig.setPassword(redisProperties.password());
if (!redisProperties.password().isBlank()) {
redisStandaloneConfig.setPassword(redisProperties.password());
}

Copilot uses AI. Check for mistakes.
public LoginResponse loginAdmin(LoginRequest request) {
Admin admin = validateAdminByEmail(request.email());
if (!encoder.matches(request.password(), admin.getPassword())) {
throw new CommonException(AdminErrorCode.ADMIN_NOT_FOUND);
Copy link

Copilot AI May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Since an INVALID_PASSWORD error code already exists, consider using it instead of ADMIN_NOT_FOUND to more precisely indicate a password mismatch.

Suggested change
throw new CommonException(AdminErrorCode.ADMIN_NOT_FOUND);
throw new CommonException(AdminErrorCode.INVALID_PASSWORD);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: 비밀번호&아이디 중 어느 것이 잘못되었는지, 외부 공격자에게 상세히 노출하지 않는게 좋다고 생각해서 로그인 로직에 한해 ADMIN_NOT_FOUND 코드로 통합해 걸어두었는데, 리뷰하시는 분들이 INVALID_PASSWORD로 구체화하는 것이 좋겠다는 의견 내시면 반영해서 수정하겠습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADMIN_NOT_FOUND로 통합하는 것이 좋을 것 같습니다.

Copy link

@midday2612 midday2612 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다. 리뷰 확인해주세요!

public LoginResponse loginAdmin(LoginRequest request) {
Admin admin = validateAdminByEmail(request.email());
if (!encoder.matches(request.password(), admin.getPassword())) {
throw new CommonException(AdminErrorCode.ADMIN_NOT_FOUND);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADMIN_NOT_FOUND로 통합하는 것이 좋을 것 같습니다.

Copy link
Contributor

@coffeesigma coffeesigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~

@willjsw willjsw merged commit fa894c1 into develop May 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants