-
Notifications
You must be signed in to change notification settings - Fork 1
[REFACTOR] CORS preflight 요청 매칭 추가 #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
""" Walkthrough보안 필터 체인 구성에서 인증이 필요 없는 엔드포인트에 대해 HTTP OPTIONS 요청("/**")을 추가로 매칭하도록 변경되었습니다. 이로써 CORS preflight 요청이 명시적으로 비인증 보안 필터 체인에서 처리될 수 있도록 조정되었습니다. 다른 로직이나 에러 처리에는 변화가 없습니다. 또한, 권한(role) 관련 타입을 문자열에서 Changes
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
sequenceDiagram
participant AuthService
participant AuthorityRepository
participant RoleEnum
AuthService->>AuthorityRepository: saveAuthority(memberId, Role)
AuthorityRepository->>RoleEnum: use Role enum for role field
AuthorityRepository-->>AuthService: save success
Estimated code review effort3 (~45 minutes) Possibly related issues
Possibly related PRs
Suggested reviewers
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
🧠 Learnings (4)📓 Common learningseeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (3)Learnt from: Daae-Kim Learnt from: rlajm1203 Learnt from: rlajm1203 eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (5)Learnt from: Daae-Kim Learnt from: rlajm1203 Learnt from: rlajm1203
Learnt from: rlajm1203 Learnt from: rlajm1203 eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)Learnt from: Daae-Kim 🧬 Code Graph Analysis (1)eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (1)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (5)
🧰 Additional context used🧠 Learnings (4)📓 Common learningseeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (3)Learnt from: Daae-Kim Learnt from: rlajm1203 Learnt from: rlajm1203 eeos/src/test/java/com/blackcompany/eeos/auth/application/domain/token/JwtTestUtil.java (5)Learnt from: Daae-Kim Learnt from: rlajm1203 Learnt from: rlajm1203
Learnt from: rlajm1203 Learnt from: rlajm1203 eeos/src/test/java/com/blackcompany/eeos/auth/fixture/FakeAuthority.java (1)Learnt from: Daae-Kim 🧬 Code Graph Analysis (1)eeos/src/test/java/com/blackcompany/eeos/auth/application/service/AuthFacadeServiceTest.java (1)
🔇 Additional comments (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
아 options 인증하도록 되어서 해당 코드 추가하신거죠? |
네 맞습니다..ㅎㅎ |
- 공통된 특성을 가지는 클래스끼리 같은 패키지로 묶기
- Role Enum 으로 변경
There was a problem hiding this 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.USERenum 사용은 좋습니다. 하지만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
📒 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:
- Token expiration check (ExpiredJwtException -> TokenExpiredException)
- Signature validation (SignatureException -> TokenParsingException)
- 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:
- Token expiration check (ExpiredJwtException -> TokenExpiredException)
- Signature validation (SignatureException -> TokenParsingException)
- 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필드를Roleenum으로 변경하고 정적 팩토리 메서드를 추가한 것은 타입 안전성을 높이는 좋은 개선사항입니다.
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 매핑 로직 올바르게 구현됨
toEntity와toModel메서드에서Roleenum을 올바르게 매핑하고 있습니다. string 기반에서 enum 기반으로의 전환이 일관되게 적용되었습니다.Also applies to: 36-36
eeos/src/main/java/com/blackcompany/eeos/auth/persistence/authority/AuthorityEntity.java (2)
3-3: 적절한 JPA enum 매핑
Roleenum 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::getRole→Role::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() 정적 팩토리 메서드를 사용하는 것은 객체 생성 의도를 명확하게 표현하고 코드 가독성을 향상시키는 좋은 개선사항입니다.
📌 관련 이슈
#271
✒️ 작업 내용
스크린샷 🏞️ (선택)
💬 REVIEWER에게 요구사항 💬
Summary by CodeRabbit
Summary by CodeRabbit