Repository navigation
[Chore/#194] SecurityConfig CORS 설정 추가 - #195
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
허용 출처 설정 바인딩 .env.example, bootstrap/src/test/resources/application-gateway-auth.yml, gateway/auth/src/main/java/kr/ac/kookmin/stream/security/config/CorsProperties.java, gateway/auth/src/main/resources/application-gateway-auth.yml |
cors.allowed-origins를 CORS_ALLOWED_ORIGINS 환경변수에서 읽고 CorsProperties에 바인딩합니다. 예시 및 테스트 설정에는 http://localhost:5173을 지정합니다. |
보안 필터 체인에 CORS 정책 연결 gateway/auth/src/main/java/kr/ac/kookmin/stream/security/config/SecurityConfig.java |
보안 필터 체인에 CORS 설정을 연결합니다. 구성된 허용 출처와 GET, POST, PUT, PATCH, DELETE, OPTIONS 메서드 및 Authorization, Content-Type 헤더를 모든 경로에 적용합니다. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Feature
Suggested reviewers: xeoxxn
Merge Risk: 
Minimal · up to 27f22
-
This change adds configurable CORS origins and connects them to the security filter chain. No code defect was found. Before deploying, make sure CORS_ALLOWED_ORIGINS is set in the dev and prod environments, because the app will not start without it.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Out of Scope Changes check
-
Explanation
변경 범위는 이슈
#194의CORS 설정과 직접 연결됩니다. 모듈별 yml, 루트.env.example, 설정 바인딩 record,SecurityConfig의 CORS 필터 연결, 테스트 클래스패스 설정만 변경했습니다. 문서의 설정 컨벤션인 모듈별 yml 관리, 환경변수 참조,@ConfigurationPropertiesrecord 사용과도 일치합니다.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (3 skipped: 3 unsupported.)
-
Full details: Linked Issues check
-
Explanation
직접 연결된 이슈
#194의CORS 코딩 요구사항 대부분을 구현했습니다.gateway/auth/src/main/resources/application-gateway-auth.yml은CORS_ALLOWED_ORIGINS를cors.allowed-origins에 바인딩합니다.CorsProperties는@ConfigurationProperties(prefix = "cors")record입니다.SecurityConfig는/**경로에 지정된 메서드와Authorization,Content-Type헤더를 적용하고 credentials를 활성화하지 않습니다..env.example와 테스트 설정도 갱신했습니다. 그러나 이슈#194가요구한 dev/prod 배포 환경의CORS_ALLOWED_ORIGINS등록 변경은 PR diff에 없습니다. PR 설명도 이 작업이 머지 전에 필요하다고 명시합니다.Resolution
dev/prod 배포 환경에 실제
CORS_ALLOWED_ORIGINS값을 등록하고, 해당 등록이 완료되었음을 검증 가능한 저장소 또는 배포 설정 근거로 남기십시오.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
#️⃣연관된 이슈
🎯 해결하려는 문제가 무엇인가요?
SecurityConfig에 CORS 설정이 없어, 다른 origin에서 뜬 웹 클라이언트가 API를 호출하면 브라우저가 막습니다.Authorization헤더가 붙은 요청은 preflight(OPTIONS)를 거치는데, 이 요청에 CORS 응답 헤더가 없어 실제 요청이 나가지 못합니다.❓ 왜 해결해야 하나요?
⭐ 어떻게 해결했나요?
application-gateway-auth.yml에cors.allowed-origins: ${CORS_ALLOWED_ORIGINS}추가 (쉼표 구분으로 여러 개)CorsPropertiesrecord(@ConfigurationProperties(prefix = "cors"))로List<String>바인딩SecurityConfig에.cors(...)로CorsConfigurationSource연결, 전체 경로(/**)에 적용GET,POST,PUT,PATCH,DELETE,OPTIONSAuthorization,Content-Type.env.example에CORS_ALLOWED_ORIGINS추가application-gateway-auth.yml(main 파일을 가림)에 더미 origin 추가🧩 이 PR의 한계 & 트레이드오프
Authorization,Content-Type으로 좁혔습니다. 클라이언트가 다른 헤더를 보내게 되면 목록에 추가해야 합니다.Authorization헤더로만 전달합니다.exposedHeaders), preflight 캐시(maxAge)는 설정하지 않았습니다.⛓️ 기존 기능에 미치는 영향
CORS_ALLOWED_ORIGINS는 기본값이 없는 필수값이라, 설정하지 않으면 앱이 시작되지 않습니다. 머지 전에 dev/prod 배포 환경변수와 각자 로컬.env에 추가가 필요합니다.Origin헤더를 보내지 않으므로 영향이 없습니다.🔀 Edge Case & 실패 시나리오
CorsFilter가 403으로 거절합니다.http://localhost:5173≠http://127.0.0.1:5173). 끝에/를 붙이지 않습니다.CorsFilter가 인가 필터보다 앞에서 처리하므로 인증 없이 응답됩니다.📋 검토한 대안과 선택 이유
KCONNECT_ALLOWED_REDIRECT_URIS처럼 쉼표 구분 환경변수로 받았습니다.allowedHeaders = *: 편하지만 현재 쓰는 헤더가 두 개뿐이라 필요한 헤더만 열었습니다.CorsConfigurationSource를@Bean으로 등록: 다른 곳에서 쓰지 않아SecurityConfig안의 private 메서드로 두었습니다.💬 리뷰 포인트
CORS_ALLOWED_ORIGINS등록 후 머지해야 합니다. 등록할 origin 목록 확인 부탁드립니다.Authorization,Content-Type외에 보내는 헤더가 있는지 확인 부탁드립니다.