Skip to content

Conversation

@ksg1227
Copy link
Collaborator

@ksg1227 ksg1227 commented Jan 20, 2026

Related issue 🛠

Work Description 📝

  • 신고글 이미지 포스트를 위한 api 추가
  • 품종(breed) 칼럼 길이 증가

Screenshot 📸

Uncompleted Tasks 😅

To Reviewers 📢

수정 사항들 운영 서버에 반영하고자 하니 확인 한 번 부탁드립니다~

Summary by CodeRabbit

릴리스 노트

  • New Features

    • Admin 계정 인증 기능 추가 (전용 API 키 방식)
    • Admin 사용자 역할 및 권한 관리 시스템 도입
    • Admin 사용자의 이미지 업로드 기능 지원
  • Improvements

    • 반려동물 견종 정보 입력 길이 확대 (최대 50자)
  • Tests

    • Admin 로그인 및 서비스 관련 테스트 추가

✏️ Tip: You can customize this high-level summary in your review settings.

JJUYAAA and others added 26 commits January 4, 2026 21:51
[Refactor] 내부 자동화를 위한 관리자용 로그인 API 추가 (장기 refresh 토큰 기반)
@ksg1227 ksg1227 requested review from JJUYAAA and JangIkhwan January 20, 2026 00:02
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

개요

이 PR은 X-ADMIN-KEY 헤더를 통한 관리자 서비스 계정 로그인 기능을 추가하고, 관리자 역할(ROLE_ADMIN)을 도입하며, 관리자 API 접근을 제한하는 allowlist 필터를 적용합니다. 또한 Report 엔티티의 breed 칼럼 길이를 확장하고 관련 설정 및 테스트를 추가합니다.

변경사항

그룹 / 파일 변경 요약
인증 제어 및 서비스
src/main/java/com/kuit/findyou/domain/auth/controller/AuthController.java, src/main/java/com/kuit/findyou/domain/auth/dto/response/AdminLoginResponse.java, src/main/java/com/kuit/findyou/domain/auth/service/AdminLoginService.java, src/main/java/com/kuit/findyou/domain/auth/service/AdminLoginServiceImpl.java, src/main/java/com/kuit/findyou/domain/auth/service/AuthServiceFacade.java
새로운 /login/admin 엔드포인트 추가. X-ADMIN-KEY 헤더 검증 후 관리자 토큰 발급. AdminLoginResponse DTO, AdminLoginService 인터페이스 및 구현체 추가.
역할 및 권한 확장
src/main/java/com/kuit/findyou/domain/user/model/Role.java, src/main/java/com/kuit/findyou/domain/image/controller/ImageController.java
Role 열거형에 ADMIN 상수 추가. 이미지 업로드 엔드포인트 권한을 ROLE_USER에서 ROLE_USER | ROLE_ADMIN으로 변경.
보안 필터 및 설정
src/main/java/com/kuit/findyou/global/jwt/filter/AdminAllowlistFilter.java, src/main/java/com/kuit/findyou/global/config/SecurityConfig.java, src/main/java/com/kuit/findyou/global/jwt/security/CustomAccessDeniedHandler.java
새로운 AdminAllowlistFilter 추가로 관리자 API 접근 제한. SecurityConfig에 필터 등록. AccessDenied 응답에 예외 메시지 포함 가능.
JWT 유틸리티 확장
src/main/java/com/kuit/findyou/global/jwt/util/JwtUtil.java
사용자 정의 만료 시간을 지원하는 createAccessJwt() 오버로드 메서드 추가.
데이터베이스 및 설정
src/main/java/com/kuit/findyou/domain/report/model/Report.java, src/main/resources/db/migration/V9__alter_reports_breed_column.sql, src/main/resources/application.yml, src/test/resources/application-test.yml
Report breed 칼럼 길이를 20에서 50으로 확장. admin 설정 추가 (admin-user-id, access-ttl-ms, api.key).
테스트 및 유틸
src/test/java/com/kuit/findyou/domain/auth/controller/AuthControllerTest.java, src/test/java/com/kuit/findyou/domain/auth/service/AdminLoginServiceImplTest.java, src/test/java/com/kuit/findyou/global/common/util/TestInitializer.java
AdminLogin API의 정상/실패 케이스에 대한 통합 및 단위 테스트 추가. TestInitializer에 insertAdminUserWithFixedId() 유틸 메서드 추가.

시퀀스 다이어그램

sequenceDiagram
    participant Client
    participant AuthController
    participant AuthServiceFacade
    participant AdminLoginService
    participant UserRepository
    participant JwtUtil
    
    Client->>AuthController: POST /login/admin<br/>(X-ADMIN-KEY: admin-key)
    AuthController->>AuthController: adminKey 검증<br/>(configured adminApiKey와 비교)
    alt 유효한 KEY
        AuthController->>AuthServiceFacade: adminLogin()
        AuthServiceFacade->>AdminLoginService: adminLogin()
        AdminLoginService->>UserRepository: findById(adminUserId)
        alt 사용자 존재
            UserRepository-->>AdminLoginService: User
            AdminLoginService->>JwtUtil: createAccessJwt<br/>(userId, ROLE_ADMIN, ttl)
            JwtUtil-->>AdminLoginService: accessToken
            AdminLoginService-->>AuthServiceFacade: AdminLoginResponse<br/>(userId, accessToken)
            AuthServiceFacade-->>AuthController: AdminLoginResponse
            AuthController-->>Client: 200 OK<br/>(AdminLoginResponse)
        else 사용자 없음
            UserRepository-->>AdminLoginService: Optional.empty()
            AdminLoginService-->>AuthServiceFacade: CustomException<br/>(USER_NOT_FOUND)
            AuthServiceFacade-->>AuthController: CustomException
            AuthController-->>Client: 404 Not Found<br/>(USER_NOT_FOUND)
        end
    else 유효하지 않거나 누락된 KEY
        AuthController-->>Client: 401 Unauthorized<br/>(UNAUTHORIZED)
    end
Loading

코드 리뷰 예상 시간

🎯 3 (보통) | ⏱️ ~25분

관련 가능성 있는 PR

추천 리뷰어

  • JangIkhwan
  • JJUYAAA
🚥 Pre-merge checks | ✅ 1 | ❌ 4
❌ Failed checks (2 warnings, 2 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 이슈 #168은 품종 칼럼 수정만을 목표로 하지만, PR에는 AdminLoginService, AdminAllowlistFilter, JwtUtil 메서드 추가 등 관리자 인증 관련 변경사항들이 다수 포함되어 있습니다. 관리자 인증 기능 추가(#158 관련)는 별도 이슈로 분리하거나, 이슈 #168을 업데이트하여 스코프를 명확히 정의하세요. 또는 별도 PR로 나누는 것을 고려하세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 3.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive 연결된 이슈 #168의 목표는 품종 칼럼 수정 후 운영 서버 릴리즈입니다. 변경사항 중 품종 칼럼 길이 수정(20→50)과 마이그레이션 스크립트는 이슈 요구사항을 충족하나, 관리자 인증 기능 추가는 이슈 #168의 스코프를 벗어납니다. 이슈 #168에 명시되지 않은 관리자 인증 기능(#158 관련)이 포함되어 있습니다. 이러한 변경사항들이 의도적이라면 이슈를 명확히 링크하거나 PR 설명에서 추가 작업사항을 명시하세요.
Title check ❓ Inconclusive PR 제목은 '[Release] 수정 사항 반영 후 운영 서버 릴리즈'로, 변경 사항들을 운영 서버에 릴리즈한다는 일반적인 의도는 전달하지만, 구체적인 주요 변경 사항을 명확하게 나타내지 못합니다. 운영 서버 릴리즈의 주요 변경 사항(예: '관리자 로그인 기능 추가 및 품종 칼럼 길이 증가')을 더 구체적으로 명시하면 제목의 명확성이 향상됩니다.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

Test Results

379 tests   379 ✅  57s ⏱️
 95 suites    0 💤
 95 files      0 ❌

Results for commit 0d3a81b.

@github-actions
Copy link

📊 JaCoCo Coverage

Overall Project 82.8% -0.76% 🍏
Files changed 71.72%

File Coverage
AuthController.java 100% 🍏
AuthServiceFacade.java 100% 🍏
AdminLoginServiceImpl.java 100% 🍏
ImageController.java 100% 🍏
JwtUtil.java 91.09% 🍏
AdminAllowlistFilter.java 60.22% -39.78%
CustomAccessDeniedHandler.java 0% -48.72%

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In
`@src/main/java/com/kuit/findyou/domain/auth/dto/response/AdminLoginResponse.java`:
- Around line 9-10: Update the Swagger description string for the accessToken
field in AdminLoginResponse: change the Schema description from "엑세스 토큰" to the
correct Korean spelling "액세스 토큰" for the field named accessToken in the
AdminLoginResponse DTO so generated API docs show the corrected text.

In
`@src/main/java/com/kuit/findyou/domain/auth/service/AdminLoginServiceImpl.java`:
- Around line 27-34: In adminLogin(), after retrieving the User via
userRepository.findById(adminUserId), validate that the user has an admin role
and is in an active (not deleted/disabled) state before issuing the token: check
User.getRole() equals Role.ADMIN and the appropriate status flag/method on User
(e.g., isActive(), isDeleted()==false, or getStatus()==Status.ACTIVE) and if
either check fails throw a suitable CustomException (e.g., INVALID_PERMISSION or
USER_INACTIVE); only then call jwtUtil.createAccessJwt(...) and return the
AdminLoginResponse. Ensure you reference adminUserId, adminLogin(), User,
userRepository, Role.ADMIN, jwtUtil.createAccessJwt, AdminLoginResponse and
CustomException when making the change.

In `@src/main/java/com/kuit/findyou/domain/report/model/Report.java`:
- Line 31: DB 컬럼의 breed 길이를 50으로 늘린 것과 검증/문서가 불일치합니다:
CreateWitnessReportRequest.breed 및 CreateMissingReportRequest.breed 필드에
javax.validation.constraints.Size(max = 50) 어노테이션을 추가하고, 응답 DTO들(예:
WitnessReportResponse, MissingReportResponse 등)의 해당 breed 필드에 스웨거
어노테이션(`@Schema`)에 maxLength = 50을 명시해 주세요; 대상 필드 이름(breed)과 DTO 클래스명을 기준으로 찾아 일관된
검증/스키마 제약을 적용하면 됩니다.

In
`@src/main/java/com/kuit/findyou/global/jwt/security/CustomAccessDeniedHandler.java`:
- Around line 24-27: The current CustomAccessDeniedHandler exposes
accessDeniedException.getMessage() in the BaseErrorResponse which may leak
internal auth/filter details; update the handler (in CustomAccessDeniedHandler)
to avoid returning the raw exception message by using a fixed external-facing
message (e.g., "Access denied") or map only allowed error keys to user-friendly
messages, and pass that safe message into new BaseErrorResponse(FORBIDDEN,
safeMessage) (or new BaseErrorResponse(FORBIDDEN) if you choose the
fixed-message overload) instead of the raw accessDeniedException.getMessage().

In `@src/main/java/com/kuit/findyou/global/jwt/util/JwtUtil.java`:
- Around line 64-71: The createAccessJwt method can produce immediately-expired
tokens if expireMs is zero/negative or invalid; add a validation guard at the
start of createAccessJwt(Long userId, Role role, long expireMs) to ensure
expireMs is a positive value (e.g., throw IllegalArgumentException or clamp to a
safe minimum like 1 minute) before using it to compute expiration, so the
Jwts.builder() call always receives a valid expiration interval.

@ksg1227 ksg1227 changed the title [Release] 품종 칼럼 수정 후 운영 서버 릴리즈 [Release] 수정 사항 반영 후 운영 서버 릴리즈 Jan 20, 2026
Copy link
Collaborator

@JangIkhwan JangIkhwan left a comment

Choose a reason for hiding this comment

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

확인했습니다!

@ksg1227 ksg1227 merged commit 3505928 into main Jan 20, 2026
5 checks 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.

[Release] 수정 사항 반영 후 운영 서버 릴리즈

4 participants