Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand Down Expand Up @@ -101,11 +102,26 @@ public void onAuthenticationSuccess(
// 5. RefreshToken 저장(DB or Redis)
refreshTokenService.saveOrUpdateToken(user.getUserId(), refreshToken);

boolean isProd = Arrays.asList(env.getActiveProfiles()).contains("prod");
String[] activeProfiles = env.getActiveProfiles();
List<String> profiles = Arrays.asList(activeProfiles);

boolean isProd = profiles.contains("prod");
boolean isDev = profiles.contains("dev");

// SameSite, Secure 설정 (dev도 prod와 동일하게)
String sameSite = (isProd || isDev) ? "None" : "Lax";
boolean secure = (isProd || isDev);

// 도메인 설정
String domain;
if (isProd) {
domain = "sjusisc.com"; // 운영 도메인
} else if (isDev) {
domain = "sisc-web.duckdns.org"; // 개발 도메인
} else {
domain = "localhost"; // 기본값
}

String sameSite = isProd ? "None" : "Lax";
boolean secure = isProd;
String domain = isProd ? "sisc-web.duckdns.org" : "localhost";



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class SecurityConfig {
private boolean isProd() {
return List.of(env.getActiveProfiles()).contains("prod");
}
private boolean isDev() {
return List.of(env.getActiveProfiles()).contains("dev");
}

@Bean
public AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository() {
Expand Down Expand Up @@ -72,8 +75,11 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.successHandler(oAuth2SuccessHandler)
.failureHandler((req, res, ex) -> {
if (isProd()) {
res.sendRedirect("https://sjusisc.com/oauth/fail");
}else if(isDev()){
res.sendRedirect("https://sisc-web.duckdns.org/oauth/fail");
} else {
}
else {
res.sendRedirect("http://localhost:5173/oauth/fail");
}
})
Expand Down Expand Up @@ -121,7 +127,8 @@ public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOriginPatterns(List.of(
"http://localhost:5173",
"https://sisc-web.duckdns.org"
"https://sisc-web.duckdns.org",
"https://sjusisc.com"
));
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
config.setAllowedHeaders(List.of("*"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@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.

@EnableJpaRepositories(
basePackages = "org.sejongisc.backend",
entityManagerFactoryRef = "primaryEntityManagerFactory",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
Expand All @@ -21,6 +22,7 @@

@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") 애노테이션 추가)

@EnableJpaRepositories(
basePackages = "org.sejongisc.backend.stock.repository",
entityManagerFactoryRef = "stockEntityManagerFactory",
Expand Down