Skip to content

edit DataSources,Oauth2#167

Merged
Kosw6 merged 4 commits intomainfrom
BE-prod-setting-update
Dec 8, 2025
Merged

edit DataSources,Oauth2#167
Kosw6 merged 4 commits intomainfrom
BE-prod-setting-update

Conversation

@Kosw6
Copy link
Collaborator

@Kosw6 Kosw6 commented Dec 8, 2025

  1. 두 개의 Primary,StockDataSource에
    @Profile("dev")을 추가하여 개발서버에서는 기존의 개발된 설정 파일을 사용
    profile: prod로 진행시에 기존의 설정 대신 스프링 기본 설정으로 사용하도록 변경
  2. Security, Oauth2SuccessHandler수정
    기존의 isProd밑 isDev추가하여 dev, prod분기 생성

Summary by CodeRabbit

릴리스 노트

  • 개선 사항

    • 개발/운영 환경에 따른 쿠키 속성(sameSite, secure) 및 도메인 결정 로직 개선
    • 환경별 OAuth2 인증 실패 시 리다이렉트 대상 구분 추가
    • CORS 허용 도메인 확장
  • 구성 변경

    • 개발(dev) 프로필에서만 활성화되는 데이터 소스 구성 적용

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

@Kosw6 Kosw6 requested a review from discipline24 as a code owner December 8, 2025 16:36
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

Warning

Rate limit exceeded

@Kosw6 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2192cdb and 5da7b9e.

📒 Files selected for processing (1)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java (3 hunks)

Walkthrough

프로덕션(prod), 개발(dev), 그 외 환경을 구분해 활성 Spring 프로필을 검사하도록 변경했습니다. OAuth2 성공 핸들러와 보안 설정에서 환경별 쿠키 속성(sameSite/secure), 도메인, 리다이렉트 URL, CORS 허용 원본을 분기 처리하도록 추가 및 조정했고, 두 데이터 소스 구성 클래스에 @Profile("dev") 애노테이션을 적용했습니다.

Changes

코호트 / 파일(s) 변경 요약
OAuth2 성공 핸들러
backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java
활성 프로필을 Environment에서 읽어 List<String>으로 처리하고 isProd/isDev 판별 추가; sameSite를 prod/dev인 경우 "None", 기타는 "Lax"로 설정; secure 플래그를 prod/dev에서 true로 설정; 도메인 선택을 prod → sjusisc.com, dev → sisc-web.duckdns.org, 기타 → localhost의 3분기 로직으로 변경; 쿠키 생성 직전에 sameSite/secure/domain을 계산하도록 흐름 재배치
보안 설정
backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java
isDev() 헬퍼 메서드 추가; OAuth2 실패 시 환경별 리다이렉트 URL 분기(prod/dev/기타); CORS 허용 원본에 https://sjusisc.com 추가
데이터 소스 구성 (dev 전용)
backend/src/main/java/org/sejongisc/backend/common/config/PrimaryDataSourceConfig.java, backend/src/main/java/org/sejongisc/backend/common/config/StockDataSourceConfig.java
클래스 선언에 @Profile("dev") 애노테이션을 추가하여 해당 빈들이 dev 프로필에서만 활성화되도록 변경 (로직/시그니처 변경 없음)

Estimated code review effort

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

  • 주의할 파일/영역:
    • OAuth2SuccessHandler.java: 환경별 도메인/쿠키 속성 분기 로직이 모든 시나리오(prod/dev/기타)에서 기대대로 동작하는지 검증 필요
    • SecurityConfig.java: 추가된 CORS 허용 원본과 환경별 리다이렉트가 보안 정책 및 배포 환경과 일치하는지 확인
    • @Profile("dev") 적용된 데이터 소스 클래스들: 다른 환경에서 데이터 소스 빈 누락 여부 확인 및 대체 설정 존재 여부 점검

Possibly related PRs

Suggested reviewers

  • discipline24

Poem

🐰 프로필들 사이로 깡충깡충,
prod는 단단히, dev는 은밀히,
쿠키는 규칙을 바꿔 입고, 도메인은 제자리로 향하네.
CORS 창문 하나 더 열고, 데이터 소스는 dev 무대에서 반짝! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 주요 내용을 부분적으로만 반영하고 있습니다. 'edit DataSources,Oauth2'는 실제 변경사항(프로필 기반 조건부 로딩, 개발/프로덕션 환경별 설정 분리)을 명확하게 설명하지 못합니다.

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.

@Kosw6 Kosw6 closed this Dec 8, 2025
@Kosw6 Kosw6 reopened this Dec 8, 2025
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: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f96eade and 0dc24d9.

📒 Files selected for processing (4)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (1 hunks)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java (3 hunks)
  • backend/src/main/java/org/sejongisc/backend/common/config/PrimaryDataSourceConfig.java (1 hunks)
  • backend/src/main/java/org/sejongisc/backend/common/config/StockDataSourceConfig.java (2 hunks)
🔇 Additional comments (5)
backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java (2)

47-49: LGTM!

isDev() 헬퍼 메서드가 기존 isProd()와 동일한 패턴으로 올바르게 구현되었습니다.


130-131: LGTM!

프로덕션 도메인 https://sjusisc.com이 CORS 허용 목록에 올바르게 추가되었습니다.

backend/src/main/java/org/sejongisc/backend/common/config/StockDataSourceConfig.java (1)

10-10: LGTM!

Profile import가 올바르게 추가되었습니다.

backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (2)

104-107: LGTM!

프로파일 감지 로직이 올바르게 구현되었습니다. isProdisDev 플래그를 통해 환경별로 다른 동작을 지원할 수 있습니다.


110-111: LGTM!

쿠키 보안 설정이 프로파일에 따라 적절하게 구성되었습니다. 프로덕션에서는 SameSite=NoneSecure=true를 사용하고, 개발 환경에서는 SameSite=LaxSecure=false를 사용합니다.


@Configuration
@EnableTransactionManagement
@Profile("dev")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for prod profile datasource configurations
echo "=== Searching for @Profile(\"prod\") annotations ==="
rg -n '@Profile.*prod' --type java -A 3

echo -e "\n=== Searching for prod-specific configuration files ==="
fd -e yml -e yaml -e properties 'application-prod'

echo -e "\n=== Checking directory structure for datasource configs ==="
find . -path ./\.git -prune -o -type f -name '*DataSource*.java' -print

echo -e "\n=== Searching for all @Profile annotations in config directory ==="
rg -n '@Profile' backend/src/main/java/org/sejongisc/backend/common/config/ --type java -B 2 -A 2

Repository: SISC-IT/sisc-web

Length of output: 1646


🏁 Script executed:

#!/bin/bash
echo "=== Searching for application configuration files ==="
fd -e yml -e yaml -e properties 'application' | grep -E 'application(-|\.)(yml|yaml|properties)$'

echo -e "\n=== Checking main resources directory ==="
ls -la backend/src/main/resources/ 2>/dev/null || echo "resources dir not found"

echo -e "\n=== Examining PrimaryDataSourceConfig.java ==="
cat -n backend/src/main/java/org/sejongisc/backend/common/config/PrimaryDataSourceConfig.java

echo -e "\n=== Examining StockDataSourceConfig.java ==="
cat -n backend/src/main/java/org/sejongisc/backend/common/config/StockDataSourceConfig.java

Repository: SISC-IT/sisc-web

Length of output: 9475


🏁 Script executed:

cat -n backend/src/main/resources/application.yml

Repository: SISC-IT/sisc-web

Length of output: 477


Production datasource configuration is missing—application will fail to start in production.

The @Profile("dev") annotation restricts PrimaryDataSourceConfig and StockDataSourceConfig to the dev profile only. However, application.yml sets spring.profiles.active: prod with no datasource properties defined. In production, Spring Boot will fail to auto-configure datasources without connection parameters (url, username, password), and the custom EntityManager and TransactionManager beans won't be instantiated.

Create application-prod.yml with production datasource configuration, or remove the @Profile("dev") restriction and adjust the configuration to support both profiles.

🤖 Prompt for AI Agents
In
backend/src/main/java/org/sejongisc/backend/common/config/PrimaryDataSourceConfig.java
around line 24, the class is annotated with @Profile("dev") which restricts
datasource beans to the dev profile and will cause startup failure in prod since
application.yml activates prod but no datasource properties exist; remove the
@Profile("dev") annotation (and the same annotation in StockDataSourceConfig) or
add a production datasource configuration file (create application-prod.yml)
that supplies spring.datasource.url/username/password (or configure
profile-specific properties) so the custom EntityManager/TransactionManager
beans are available in production.


@Configuration
@EnableTransactionManagement
@Profile("dev")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all datasource-related config files
fd -type f -name '*DataSourceConfig.java' backend/src/main/java/

# Check for all profile annotations in config directory
rg -n '@Profile' backend/src/main/java/org/sejongisc/backend/common/config/ -A 2 -B 1

# Look for application configuration files
fd -type f -name 'application*.yml' -o -name 'application*.properties' backend/src/main/resources/

Repository: SISC-IT/sisc-web

Length of output: 1384


🏁 Script executed:

#!/bin/bash
# Read the StockDataSourceConfig file
cat -n backend/src/main/java/org/sejongisc/backend/common/config/StockDataSourceConfig.java

# Read the PrimaryDataSourceConfig file
cat -n backend/src/main/java/org/sejongisc/backend/common/config/PrimaryDataSourceConfig.java

# Check for all config files in the config directory
ls -la backend/src/main/java/org/sejongisc/backend/common/config/

Repository: SISC-IT/sisc-web

Length of output: 9410


🏁 Script executed:

#!/bin/bash
# Find all application configuration files
find backend/src/main/resources -name "application*.yml" -o -name "application*.properties" | sort

# Read the main application.yml
cat backend/src/main/resources/application.yml

# Check if there's an application-prod file
find backend/src/main/resources -name "application-prod*"

# Check for other profile-specific configs
ls -la backend/src/main/resources/

Repository: SISC-IT/sisc-web

Length of output: 639


🏁 Script executed:

#!/bin/bash
# Check if there are any other Config classes that might provide datasource for prod
rg -n '@Configuration' backend/src/main/java/org/sejongisc/backend/common/config/ -A 5

# Search for any prod-specific datasource beans in the entire codebase
rg -n '@Profile.*prod' backend/src/main/java/ -A 3

# Check if there are conditional beans or default configurations
rg -n '@ConditionalOnProfile|@ConditionalOnMissingBean' backend/src/main/java/org/sejongisc/backend/common/config/

Repository: SISC-IT/sisc-web

Length of output: 5535


Stock 데이터소스 구성이 프로덕션 환경에서 누락되었습니다.

@Profile("dev") 애노테이션이 추가되면서 StockDataSourceConfig는 dev 프로파일에서만 활성화되지만, application.yml에서 활성 프로파일이 prod로 설정되어 있습니다. PrimaryDataSourceConfig 역시 동일하게 @Profile("dev")를 가지고 있어, 프로덕션 환경에서는 두 데이터소스 모두 구성되지 않습니다.

프로덕션 환경을 위한 datasource 구성이 필요합니다:

  • application-prod.yml 파일 생성 및 prod 프로파일 설정, 또는
  • 프로덕션 환경을 위한 별도의 datasource config 클래스 작성 (예: @Profile("prod") 애노테이션 추가)

@Kosw6 Kosw6 closed this Dec 8, 2025
@Kosw6 Kosw6 reopened this Dec 8, 2025
@Kosw6 Kosw6 closed this Dec 8, 2025
@Kosw6 Kosw6 reopened this Dec 8, 2025
@Kosw6 Kosw6 merged commit f35ca84 into main Dec 8, 2025
1 check passed
Kosw6 added a commit that referenced this pull request Dec 8, 2025
Kosw6 added a commit that referenced this pull request Dec 8, 2025
Kosw6 added a commit that referenced this pull request Dec 8, 2025
Kosw6 added a commit that referenced this pull request Dec 8, 2025
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.

1 participant