Skip to content

Conversation

@rlajm1203
Copy link
Contributor

@rlajm1203 rlajm1203 commented Jul 23, 2025

📌 관련 이슈

#271

✒️ 작업 내용

  • Security FilterChain에 OPTIONS 메소드를 매칭하도록 수정합니다.
  • Role을 enum클래스로 대체하였으며, 회원의 권한을 나타내는 값을 두 가지 값으로 나타내었습니다.
    • Role.name() : Enum 클래스의 이름을 가져오는 메소드 -> 토큰 생성 시 사용
    • Role.getRole() : Enum 클래스가 가지고 있는 String 필드를 가져오는 메소드 -> 시큐리티 필터체인에서 권한 검증 시 사용

스크린샷 🏞️ (선택)

💬 REVIEWER에게 요구사항 💬

Summary by CodeRabbit

Summary by CodeRabbit

  • 버그 수정
    • CORS 사전 요청(OPTIONS 메서드)이 올바르게 처리되도록 보안 구성을 개선했습니다.
  • 기능 개선
    • 역할(Role) 관리를 문자열에서 enum 타입으로 전환하여 권한 처리 방식을 강화했습니다.
    • 회원 가입 및 관리자 생성 시 역할 할당 로직을 간소화하고 일관성 있게 개선했습니다.

@rlajm1203 rlajm1203 requested review from Daae-Kim and kssumin July 23, 2025 05:01
@rlajm1203 rlajm1203 self-assigned this Jul 23, 2025
@rlajm1203 rlajm1203 added the 🔧refactor 코드 수정 label Jul 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 23, 2025

"""

Walkthrough

보안 필터 체인 구성에서 인증이 필요 없는 엔드포인트에 대해 HTTP OPTIONS 요청("/**")을 추가로 매칭하도록 변경되었습니다. 이로써 CORS preflight 요청이 명시적으로 비인증 보안 필터 체인에서 처리될 수 있도록 조정되었습니다. 다른 로직이나 에러 처리에는 변화가 없습니다.

또한, 권한(role) 관련 타입을 문자열에서 Role enum으로 변경하는 리팩토링이 이루어졌으며, 여러 패키지 경로가 세분화되어 import 경로가 수정되었습니다. 권한 처리 로직도 Role enum을 활용하도록 일관되게 개선되었습니다.

Changes

파일/경로 변경 요약
eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java 비인증 엔드포인트에 HTTP OPTIONS 요청 매처 추가
eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AuthorityModel.java, eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java, eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityRepositoryImpl.java 권한 필드 타입을 String에서 Role enum으로 변경, 필드명과 매핑 수정
eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java, eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java, eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java, eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java 권한 저장 및 조회 시 Role enum 사용으로 리팩토링, 권한 생성 방식 변경
eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java, eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java, eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OauthVerificationStorage.java, eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/* OAuth 관련 클래스 패키지 경로 변경 및 import 수정
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/* Account 관련 클래스 패키지 경로 변경 및 import 수정
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/* Authority 관련 클래스 패키지 경로 변경 및 import 수정
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/* OAuth 관련 클래스 패키지 경로 변경 및 import 수정
eeos/src/main/java/com/blackcompany/eeos/auth/application/service/DeactivateMemberService.java AccountJpaRepository import 경로 변경

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SecurityFilterChain
    participant Application

    Client->>SecurityFilterChain: HTTP OPTIONS /** (CORS Preflight)
    SecurityFilterChain-->>Client: Allow (No Authentication Required)
    Client->>SecurityFilterChain: Other Requests (e.g., GET/POST)
    SecurityFilterChain->>Application: Forward if allowed
Loading
sequenceDiagram
    participant AuthService
    participant AuthorityRepository
    participant RoleEnum

    AuthService->>AuthorityRepository: saveAuthority(memberId, Role)
    AuthorityRepository->>RoleEnum: use Role enum for role field
    AuthorityRepository-->>AuthService: save success
Loading

Estimated code review effort

3 (~45 minutes)

Possibly related issues

Possibly related PRs

  • [FEAT] 스프링 시큐리티 도입 #256: 보안 필터 체인 설정과 권한 기반 접근 제어, JWT 통합을 포함한 보안 체인 전반 변경과 관련된 PR로, 본 PR의 OPTIONS 요청 매처 추가가 해당 보안 체인 구성의 세부 개선 사항입니다.

Suggested reviewers

  • Daae-Kim

Suggested labels

feature

Poem

깡총깡총 토끼가 코드를 봤지,
OPTIONS도 이제 걱정이 없지!
CORS의 바람 따라 문을 열어,
프리플라이트 요청도 자유롭게 들어오네.
권한은 이제 Role로 명확히,
코드 숲에 질서가 더해졌네. 🥕
보안의 숲에 평화가 깃들길 바라며 🐇
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab50651 and b30c9d7.

📒 Files selected for processing (10)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/model/Role.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java (3 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (3 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java (2 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java (3 hunks)
  • eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (2 hunks)
  • eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (2 hunks)
  • eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1 hunks)
  • eeos/src/test/java/com/blackcompany/eeos/config/SpringSecurityFilterChainTest.java (5 hunks)
🧠 Learnings (4)
📓 Common learnings
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.
Learnt from: Daae-Kim
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.
Learnt from: rlajm1203
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/UnknownEndpointFilter.java:29-41
Timestamp: 2025-07-16T14:22:46.594Z
Learning: EEOS-BE 프로젝트에서는 여러 개의 SecurityFilterChain을 등록하고, 모든 API 엔드포인트들을 시큐리티 필터에 매칭시켜 놓았습니다. UnknownEndpointFilter는 SecurityMatcher에 걸리지 않는 요청들만 처리하는 catch-all 역할을 하므로, 정상적인 API 요청들이 이 필터에 도달하지 않습니다.
eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (3)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The HeaderTokenExtractor in EEOS already implements null checking for the Authorization header and throws NotFoundHeaderTokenException, making additional null checks in the AuthInterceptor redundant.

eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (5)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing JWT token validation in EEOS, check the TokenResolver's parseClaims and getClaimValue methods as they might contain the core validation logic and exception handling for invalid tokens.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The TokenResolver in EEOS already implements comprehensive token validation and error handling:

  1. Token expiration check (ExpiredJwtException -> TokenExpiredException)
  2. Signature validation (SignatureException -> TokenParsingException)
  3. General parsing errors (Exception -> TokenParsingException with logging)
    Additional null checks in AuthInterceptor would be redundant.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The HeaderTokenExtractor in EEOS already implements null checking for the Authorization header and throws NotFoundHeaderTokenException, making additional null checks in the AuthInterceptor redundant.

eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

🧬 Code Graph Analysis (1)
eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (1)
eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)
  • FakeAuthority (6-11)
✅ Files skipped from review due to trivial changes (2)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/model/Role.java
  • eeos/src/test/java/com/blackcompany/eeos/config/SpringSecurityFilterChainTest.java
🚧 Files skipped from review as they are similar to previous changes (5)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java
  • eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java
  • eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.
Learnt from: Daae-Kim
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.
Learnt from: rlajm1203
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/UnknownEndpointFilter.java:29-41
Timestamp: 2025-07-16T14:22:46.594Z
Learning: EEOS-BE 프로젝트에서는 여러 개의 SecurityFilterChain을 등록하고, 모든 API 엔드포인트들을 시큐리티 필터에 매칭시켜 놓았습니다. UnknownEndpointFilter는 SecurityMatcher에 걸리지 않는 요청들만 처리하는 catch-all 역할을 하므로, 정상적인 API 요청들이 이 필터에 도달하지 않습니다.
eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (3)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The HeaderTokenExtractor in EEOS already implements null checking for the Authorization header and throws NotFoundHeaderTokenException, making additional null checks in the AuthInterceptor redundant.

eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (5)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing JWT token validation in EEOS, check the TokenResolver's parseClaims and getClaimValue methods as they might contain the core validation logic and exception handling for invalid tokens.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The TokenResolver in EEOS already implements comprehensive token validation and error handling:

  1. Token expiration check (ExpiredJwtException -> TokenExpiredException)
  2. Signature validation (SignatureException -> TokenParsingException)
  3. General parsing errors (Exception -> TokenParsingException with logging)
    Additional null checks in AuthInterceptor would be redundant.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The HeaderTokenExtractor in EEOS already implements null checking for the Authorization header and throws NotFoundHeaderTokenException, making additional null checks in the AuthInterceptor redundant.

eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

🧬 Code Graph Analysis (1)
eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (1)
eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)
  • FakeAuthority (6-11)
🔇 Additional comments (3)
eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (1)

14-22: Role enum 리팩토링이 올바르게 적용되었습니다.

JWT 토큰 생성 시 role.name() 사용이 적절합니다. PR 설명에 따르면 Role.name()은 토큰 생성용, Role.getRole()은 보안 필터 체인의 역할 검증용으로 구분되어 있어 올바른 메서드를 사용하고 있습니다.

eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (1)

41-47: 권한 모델의 Role enum 전환이 잘 구현되었습니다.

AuthorityModel에서 Role enum을 사용하도록 변경하고, 최종적으로 Role::name을 통해 문자열로 변환하는 로직이 적절합니다. Role.ROLE_USER 사용으로 Spring Security의 권한 명명 규칙과도 일치합니다.

eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)

8-9: 테스트 픽스처가 Role enum 사용으로 올바르게 업데이트되었습니다.

AuthorityModel의 필드 변경사항(.name(role).role(role))에 맞춰 테스트 픽스처도 일관되게 수정되어 타입 안전성이 향상되었습니다.

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Jul 23, 2025

Test Results

101 tests  ±0   98 ✅ ±0   5s ⏱️ ±0s
 40 suites ±0    3 💤 ±0 
 40 files   ±0    0 ❌ ±0 

Results for commit b30c9d7. ± Comparison against base commit 56a3809.

♻️ This comment has been updated with latest results.

@kssumin
Copy link
Contributor

kssumin commented Jul 23, 2025

아 options 인증하도록 되어서 해당 코드 추가하신거죠?
그럼 지금 CORS 에러가 나는 건가요?

@rlajm1203
Copy link
Contributor Author

아 options 인증하도록 되어서 해당 코드 추가하신거죠? 그럼 지금 CORS 에러가 나는 건가요?

네 맞습니다..ㅎㅎ

- 공통된 특성을 가지는 클래스끼리 같은 패키지로 묶기
- Role Enum 으로 변경
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: 0

🧹 Nitpick comments (1)
eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (1)

45-45: enum 사용은 좋지만 정적 팩토리 메서드 사용 권장

Role.USER enum 사용은 좋습니다. 하지만 AuthorityModel 생성 시 새로 추가된 정적 팩토리 메서드 AuthorityModel.create(memberId, role)를 사용하는 것이 일관성 측면에서 더 좋습니다.

다음과 같이 변경을 권장합니다:

-	private void saveAuthority(Long memberId, Role role) {
-		AuthorityModel authorityModel = AuthorityModel.builder().memberId(memberId).role(role).build();
+	private void saveAuthority(Long memberId, Role role) {
+		AuthorityModel authorityModel = AuthorityModel.create(memberId, role);

Also applies to: 59-60

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aac4f19 and ab50651.

📒 Files selected for processing (22)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AccountEntityConverter.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AuthorityModel.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OauthVerificationStorage.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java (3 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/DeactivateMemberService.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (3 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountEntity.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountJpaRepository.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountRepositoryImpl.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java (2 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityJpaRepository.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityRepositoryImpl.java (2 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/JpaOAuthMemberRepository.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthInfo.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthMemberEntity.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthMemberRepositoryImpl.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OauthVerificationStorageImpl.java (1 hunks)
  • eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java (3 hunks)
  • eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java (1 hunks)
🧠 Learnings (7)
📓 Common learnings
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.
Learnt from: Daae-Kim
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.
Learnt from: rlajm1203
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/UnknownEndpointFilter.java:29-41
Timestamp: 2025-07-16T14:22:46.594Z
Learning: EEOS-BE 프로젝트에서는 여러 개의 SecurityFilterChain을 등록하고, 모든 API 엔드포인트들을 시큐리티 필터에 매칭시켜 놓았습니다. UnknownEndpointFilter는 SecurityMatcher에 걸리지 않는 요청들만 처리하는 catch-all 역할을 하므로, 정상적인 API 요청들이 이 필터에 도달하지 않습니다.
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AuthorityModel.java (2)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java (6)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The TokenResolver in EEOS already implements comprehensive token validation and error handling:

  1. Token expiration check (ExpiredJwtException -> TokenExpiredException)
  2. Signature validation (SignatureException -> TokenParsingException)
  3. General parsing errors (Exception -> TokenParsingException with logging)
    Additional null checks in AuthInterceptor would be redundant.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When suggesting additional validation checks, first verify if the underlying components (like TokenExtractor and TokenResolver in auth interceptors) already implement those checks to avoid redundancy.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing JWT token validation in EEOS, check the TokenResolver's parseClaims and getClaimValue methods as they might contain the core validation logic and exception handling for invalid tokens.

eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java (2)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (4)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: kssumin
PR: #218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.

eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityRepositoryImpl.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

✅ Files skipped from review due to trivial changes (16)
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityJpaRepository.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthService.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/service/DeactivateMemberService.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AccountEntityConverter.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthInfo.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthMemberRepositoryImpl.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountJpaRepository.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountEntity.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/account/AccountRepositoryImpl.java
  • eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeOauthMember.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/JpaOAuthMemberRepository.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OauthVerificationStorageImpl.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/domain/converter/OauthMemberEntityConverter.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/persistence/oauth/OAuthMemberEntity.java
  • eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OauthVerificationStorage.java
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.
Learnt from: Daae-Kim
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.
Learnt from: rlajm1203
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/UnknownEndpointFilter.java:29-41
Timestamp: 2025-07-16T14:22:46.594Z
Learning: EEOS-BE 프로젝트에서는 여러 개의 SecurityFilterChain을 등록하고, 모든 API 엔드포인트들을 시큐리티 필터에 매칭시켜 놓았습니다. UnknownEndpointFilter는 SecurityMatcher에 걸리지 않는 요청들만 처리하는 catch-all 역할을 하므로, 정상적인 API 요청들이 이 필터에 도달하지 않습니다.
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AuthorityModel.java (2)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java (6)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: The TokenResolver in EEOS already implements comprehensive token validation and error handling:

  1. Token expiration check (ExpiredJwtException -> TokenExpiredException)
  2. Signature validation (SignatureException -> TokenParsingException)
  3. General parsing errors (Exception -> TokenParsingException with logging)
    Additional null checks in AuthInterceptor would be redundant.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When suggesting additional validation checks, first verify if the underlying components (like TokenExtractor and TokenResolver in auth interceptors) already implement those checks to avoid redundancy.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing JWT token validation in EEOS, check the TokenResolver's parseClaims and getClaimValue methods as they might contain the core validation logic and exception handling for invalid tokens.

eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java (2)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (4)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

Learnt from: kssumin
PR: #201
File: eeos/src/main/java/com/blackcompany/eeos/auth/application/repository/OAuthMemberRepository.java:8-10
Timestamp: 2025-02-17T14:26:06.757Z
Learning: OAuthMemberRepository의 findByAccount 메서드의 반환 타입을 OauthMemberModel로 변경하는 작업은 관리자 생성 부분 리팩토링과 함께 진행될 예정입니다. 이는 영향도를 고려한 결정입니다.

Learnt from: rlajm1203
PR: #213
File: eeos/src/main/java/com/blackcompany/eeos/auth/presentation/interceptor/AuthInterceptor.java:33-36
Timestamp: 2025-02-22T16:03:14.347Z
Learning: When reviewing auth-related code in EEOS, check both TokenExtractor and TokenResolver implementations as they might already include necessary validation and error handling logic.

Learnt from: kssumin
PR: #218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.

eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityRepositoryImpl.java (1)

Learnt from: Daae-Kim
PR: #256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.

🔇 Additional comments (13)
eeos/src/main/java/com/blackcompany/eeos/auth/application/model/AuthorityModel.java (2)

15-19: 우수한 리팩토링: String에서 enum으로의 전환

name 필드를 Role enum으로 변경하고 정적 팩토리 메서드를 추가한 것은 타입 안전성을 높이는 좋은 개선사항입니다.


1-20: PR 목적과 실제 변경사항 불일치 확인 필요

PR 제목은 "CORS preflight 요청 매칭 추가"인데, 실제 변경사항은 role 처리를 string에서 enum으로 리팩토링하는 내용입니다. 실제 CORS 관련 변경사항이 누락되었는지 확인이 필요합니다.

Likely an incorrect or invalid review comment.

eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityRepositoryImpl.java (2)

1-1: 패키지 구조 개선

권한 관련 클래스들을 별도 패키지로 분리한 것은 코드 구조를 개선하는 좋은 변경입니다.


29-29: enum 매핑 로직 올바르게 구현됨

toEntitytoModel 메서드에서 Role enum을 올바르게 매핑하고 있습니다. string 기반에서 enum 기반으로의 전환이 일관되게 적용되었습니다.

Also applies to: 36-36

eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java (2)

3-3: 적절한 JPA enum 매핑

Role enum import와 @Enumerated(EnumType.STRING) 어노테이션 추가가 올바르게 구현되었습니다. 이는 데이터베이스에 enum 값을 문자열로 저장하는 최적의 방법입니다.

Also applies to: 7-8


41-43: Role enum에 ROLE_ 접두사 추가 필요

Role.getRole()가 현재 “ADMIN”/“USER”만 반환하므로 Spring Security의 hasRole/hasAnyRole 검증 시 권한 매칭이 실패합니다. 아래 중 한 가지 방법으로 수정해 주세요.

• eeos/src/main/java/com/blackcompany/eeos/auth/application/model/Role.java
• enum 값에 접두사 포함
diff - public enum Role { - ADMIN("ADMIN"), - USER("USER"); + public enum Role { + ADMIN("ROLE_ADMIN"), + USER("ROLE_USER");
• 또는 Lombok @Getter 대신 커스텀 getter 추가
```java
@Getter
public enum Role {
ADMIN("ADMIN"),
USER("USER");

    private String role;

    Role(String role) {
        this.role = role;
    }

    public String getRole() {
        return "ROLE_" + role;
    }
}
```

위 중 편한 방식을 선택해 ROLE_ 접두사를 보장해 주시면 됩니다.

⛔ Skipped due to learnings
Learnt from: Daae-Kim
PR: JNU-econovation/EEOS-BE#256
File: eeos/src/main/java/com/blackcompany/eeos/config/security/SecurityFilterChainConfig.java:93-106
Timestamp: 2025-07-20T14:09:51.877Z
Learning: EEOS-BE 프로젝트에서 Spring Security 도입 시 JWT 토큰의 역할 정보는 DB에 "ADMIN", "USER" 형태로 저장되지만, Spring Security의 hasAnyRole() 메서드는 "ROLE_" 접두사가 붙은 권한을 기대하므로, JWT 생성 시점에 SimpleGrantedAuthority("ROLE_" + role) 형태로 접두사를 추가해야 권한 매칭이 올바르게 작동합니다.
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#218
File: eeos/src/main/java/com/blackcompany/eeos/target/presentation/controller/AttendWeightPolicyController.java:19-20
Timestamp: 2025-03-01T17:43:11.312Z
Learning: 사용자 kssumin은 토큰 기반의 ROLE 검증 기능을 별도 이슈로 해결할 예정이며, 관리자 권한 검증 관련 TODO 항목은 현재 PR에서 다루지 않기로 했습니다.
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#203
File: eeos/src/main/java/com/blackcompany/eeos/common/utils/ProfileUtil.java:23-32
Timestamp: 2025-02-17T13:36:25.820Z
Learning: In the EEOS project, profile management (local/dev/live) is handled through string literals in ProfileUtil class as it's only used for cookie name formatting, and an enum would add unnecessary complexity.
Learnt from: kssumin
PR: JNU-econovation/EEOS-BE#203
File: eeos/src/main/java/com/blackcompany/eeos/common/utils/ProfileUtil.java:23-32
Timestamp: 2025-02-17T13:36:25.820Z
Learning: In the EEOS project, profile management (local/dev/live) is handled through string literals in ProfileUtil class as it's only used for cookie name formatting through CookieNameFormatter, and an enum would add unnecessary complexity.
eeos/src/main/java/com/blackcompany/eeos/auth/application/service/AuthFacadeService.java (2)

31-31: 코드 중복 제거로 유지보수성 향상

두 로그인 메서드에서 공통 로직을 getRoles() 메서드로 추출한 것은 DRY 원칙을 잘 적용한 개선사항입니다.

Also applies to: 41-41


46-51: enum 기반 권한 처리 로직 올바르게 구현됨

AuthorityModel::getRoleRole::getRole의 두 단계 매핑을 통해 enum에서 문자열로의 변환이 올바르게 구현되었습니다. 이는 전체 enum 리팩토링과 일관성을 유지합니다.

eeos/src/main/java/com/blackcompany/eeos/auth/application/service/SignUpService.java (1)

13-13: 패키지 경로 업데이트

OAuthInfo 클래스의 새로운 패키지 경로로 정확히 업데이트되었습니다.

eeos/src/main/java/com/blackcompany/eeos/member/application/service/CreateAdminMemberService.java (4)

9-10: 패키지 재구성이 잘 적용되었습니다.

AccountEntity와 AccountJpaRepository를 persistence.account 하위 패키지로 이동한 것은 관심사의 분리를 통해 코드 구조를 개선하는 좋은 리팩토링입니다.


48-48: Role enum 사용으로 타입 안전성이 향상되었습니다.

문자열 대신 Role.ADMIN enum을 사용하는 것은 컴파일 타임 검증을 통해 타입 안전성을 크게 향상시키는 좋은 변경사항입니다.


82-82: 메서드 시그니처 개선이 적절합니다.

파라미터 타입을 Role enum으로 변경한 것은 메서드 API의 명확성과 타입 안전성을 동시에 향상시키는 좋은 개선사항입니다.


83-83: 정적 팩토리 메서드 사용이 적절합니다.

AuthorityModel.create() 정적 팩토리 메서드를 사용하는 것은 객체 생성 의도를 명확하게 표현하고 코드 가독성을 향상시키는 좋은 개선사항입니다.

@coderabbitai coderabbitai bot added the feature 기능 개발 label Jul 23, 2025
@rlajm1203 rlajm1203 merged commit d68c772 into develop Jul 23, 2025
4 checks passed
@rlajm1203 rlajm1203 deleted the BM/fix/#271/security-filter branch July 23, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 기능 개발 🔧refactor 코드 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants