Conversation
Walkthrough보안 엔드포인트를 상수화하고 JWT 필터에 경로 기반 스킵 로직을 추가하며, 토큰 미존재 시 새로운 예외를 던지도록 인증 흐름을 단순화했습니다. CORS 관련 빈과 설정은 제거되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Filter as JwtTokenFilter
participant Paths as SecurityPaths
participant Auth as JwtUtils/AuthProvider
participant SecCtx as SecurityContext
Client->>Filter: HTTP 요청 (경로 포함)
Filter->>Paths: 요청 경로가 PERMIT_ALL인지 확인 (shouldNotFilter)
alt permit-all 경로
Filter-->>Client: 필터 스킵 -> 다음 핸들러로 전달
else 보호 필요 경로
Filter->>Auth: 요청에서 토큰 추출
alt 토큰 없음
Auth-->>Filter: 토큰 없음 -> AuthTokenMissingException 발생
Filter--xClient: 401 에러 처리 (예외)
else 토큰 존재
Auth->>Auth: 토큰 검증 및 Authentication 생성
Auth->>SecCtx: SecurityContext에 Authentication 설정
Filter-->>Client: 필터 통과 -> 다음 핸들러로 전달
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (2)
🔇 Additional comments (4)
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: 4
🧹 Nitpick comments (2)
src/main/kotlin/dsm/pick2024/global/config/security/SecurityConfig.kt (1)
40-41: 하드코딩된 경로를 SecurityPaths로 이동하세요.
"/attendance/time/grade/**"경로가SecurityPaths.SCH_GET_ENDPOINTS에 포함되지 않고 하드코딩되어 있습니다. 중앙 집중식 경로 관리의 일관성을 위해 해당 경로를SecurityPaths.SCH_GET_ENDPOINTS에 추가하는 것이 좋습니다.
SecurityPaths.kt에 경로 추가:val SCH_GET_ENDPOINTS = arrayOf( "/admin/**", "/after/**", + "/attendance/time/grade/**", "/application/reason/all",그 후
SecurityConfig.kt에서:.antMatchers( HttpMethod.GET, - *SecurityPaths.SCH_GET_ENDPOINTS, - "/attendance/time/grade/**" + *SecurityPaths.SCH_GET_ENDPOINTS ).hasRole(Role.SCH.name)src/main/kotlin/dsm/pick2024/global/security/path/SecurityPaths.kt (1)
77-83: 중복 패턴 정리 권장.
"/after/**"는 이미"/after/delete"를 포함하고,"/notice/delete/**"는"/notice/delete"를 포함합니다. 중복 항목을 제거하여 코드 가독성을 높이세요.val SCH_DELETE_ENDPOINTS = arrayOf( "/after/**", "/notice/delete/**", - "/schedule/delete/*", - "/after/delete", - "/notice/delete" + "/schedule/delete/*" )
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (5)
src/main/kotlin/dsm/pick2024/global/config/security/SecurityConfig.kt(2 hunks)src/main/kotlin/dsm/pick2024/global/error/exception/ErrorCode.kt(2 hunks)src/main/kotlin/dsm/pick2024/global/security/jwt/JwtTokenFilter.kt(2 hunks)src/main/kotlin/dsm/pick2024/global/security/jwt/exception/AuthTokenMissingException.kt(1 hunks)src/main/kotlin/dsm/pick2024/global/security/path/SecurityPaths.kt(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Check Code Quality
🔇 Additional comments (4)
src/main/kotlin/dsm/pick2024/global/config/security/SecurityConfig.kt (1)
72-72: 보안 강화 변경 확인.
anyRequest().denyAll()로 변경하여 명시적으로 정의되지 않은 모든 엔드포인트에 대한 접근을 거부합니다. 새로운 엔드포인트 추가 시 반드시SecurityPaths에 등록해야 합니다.src/main/kotlin/dsm/pick2024/global/error/exception/ErrorCode.kt (1)
22-22: LGTM!
AUTH_TOKEN_MISSING에러 코드가 적절한 401 상태 코드와 함께 추가되었습니다.JwtTokenFilter에서 토큰 부재 시 사용됩니다.src/main/kotlin/dsm/pick2024/global/security/jwt/exception/AuthTokenMissingException.kt (1)
6-8: LGTM!싱글톤
object패턴을 사용한 예외 구현이 적절합니다. 스택 트레이스가 재사용되지만, 인증 관련 예외에서는 디버깅 정보 노출을 최소화하는 것이 일반적인 관행입니다.src/main/kotlin/dsm/pick2024/global/security/jwt/JwtTokenFilter.kt (1)
31-35: 토큰 검증 로직 간소화 확인.
shouldNotFilter에서 permit-all 경로를 필터링하므로, 이 메서드에 도달하면 토큰이 필수입니다. 토큰 유효성 검증(만료, 형식 등)은jwtTokenProvider.authentication()에서 처리되는지 확인하세요.
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.