-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: application.yml 설정 수정, Spring Security 설정 #14
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
Changes from all commits
f1c14fc
e4fff74
d2d7199
7e64def
386cec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,23 @@ | ||
| FROM eclipse-temurin:17-jdk AS build | ||
| FROM gradle:8.12-jdk17 AS build | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ARG GPR_USER | ||
| ARG GPR_TOKEN | ||
|
|
||
| COPY gradlew . | ||
| COPY gradle gradle | ||
| COPY build.gradle . | ||
| COPY settings.gradle . | ||
|
|
||
| RUN chmod +x gradlew | ||
| COPY build.gradle settings.gradle ./ | ||
| COPY gradle ./gradle | ||
|
|
||
| RUN ./gradlew dependencies --no-daemon \ | ||
| -PGPR_USER=${GPR_USER} \ | ||
| -PGPR_TOKEN=${GPR_TOKEN} || true | ||
| RUN GPR_USER=${GPR_USER} GPR_TOKEN=${GPR_TOKEN} gradle dependencies --no-daemon || true | ||
|
|
||
| COPY src src | ||
| COPY src ./src | ||
|
|
||
| RUN ./gradlew bootJar -x test --no-daemon \ | ||
| -PGPR_USER=${GPR_USER} \ | ||
| -PGPR_TOKEN=${GPR_TOKEN} | ||
| RUN GPR_USER=${GPR_USER} GPR_TOKEN=${GPR_TOKEN} gradle bootJar --no-daemon -x test | ||
|
|
||
| FROM eclipse-temurin:17-jre | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=build /app/build/libs/*.jar app.jar | ||
|
|
||
| ENTRYPOINT ["java", "-jar", "app.jar"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.ticketing.queue.infrastructure.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.core.annotation.Order; | ||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
| import org.springframework.security.config.http.SessionCreationPolicy; | ||
| import org.springframework.security.web.SecurityFilterChain; | ||
|
|
||
| @Configuration | ||
| public class QueueSecurityConfig { | ||
|
|
||
| // MVP 통합 테스트용 임시 SecurityConfig | ||
| @Bean | ||
| @Order(1) | ||
| public SecurityFilterChain queueFilterChain(HttpSecurity http) throws Exception { | ||
| return http | ||
| .securityMatcher("/**") | ||
| .csrf(AbstractHttpConfigurer::disable) | ||
| .formLogin(AbstractHttpConfigurer::disable) | ||
| .httpBasic(AbstractHttpConfigurer::disable) | ||
| .sessionManagement(session -> | ||
| session.sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
| ) | ||
| .authorizeHttpRequests(auth -> auth | ||
| .anyRequest().permitAll() | ||
| ) | ||
| .build(); | ||
|
Comment on lines
+11
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether permissive chain is profile-gated and whether other security chains/method-security exist.
rg -n --type=java '@Profile\(|@EnableMethodSecurity|@EnableWebSecurity|SecurityFilterChain|@Order\(' src/main/java
rg -n --type=java 'securityMatcher\("/\*\*"\)|anyRequest\(\)\.permitAll\(' src/main/javaRepository: 3s-ticketing/queue-service Length of output: 740 🏁 Script executed: # Check the full QueueSecurityConfig file
cat -n src/main/java/org/ticketing/queue/infrastructure/config/QueueSecurityConfig.javaRepository: 3s-ticketing/queue-service Length of output: 1547 🏁 Script executed: # Search for all SecurityFilterChain beans in the project to understand the overall security setup
rg -n --type=java 'public SecurityFilterChain' src/main/javaRepository: 3s-ticketing/queue-service Length of output: 240 🏁 Script executed: # Check if there are any Spring application properties or YAML configs that gate profiles
fd -e properties -e yml -e yaml src/main/resources | head -20Repository: 3s-ticketing/queue-service Length of output: 448 🏁 Script executed: # Search for any conditional annotations or profile-based configurations
rg -n --type=java '@ConditionalOnProperty|@ConditionalOnProfile|@Profile|spring\.config\.activate' src/main/javaRepository: 3s-ticketing/queue-service Length of output: 52 🏁 Script executed: # Correct fd syntax to find properties files
fd . 'src/main/resources' -e properties -e yml -e yamlRepository: 3s-ticketing/queue-service Length of output: 147 🏁 Script executed: # Search for any profile or conditional properties in config files
find src/main/resources -type f \( -name "*.properties" -o -name "*.yml" -o -name "*.yaml" \) 2>/dev/null | xargs grep -l "spring.config.activate\|spring.profiles" 2>/dev/null || echo "No profile config files found"Repository: 3s-ticketing/queue-service Length of output: 100 🏁 Script executed: # Also check if there are any other Java config classes that might conditionally disable/replace this config
rg -n --type=java 'QueueSecurityConfig|@ConditionalOnMissingBean|@Primary' src/main/javaRepository: 3s-ticketing/queue-service Length of output: 189 Gate this permissive filter chain to test environments only; it currently allows unauthenticated access in all environments. The Add Suggested patch direction import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
...
`@Configuration`
+@Profile("test")
public class QueueSecurityConfig {🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,66 @@ | ||
| server: | ||
| tomcat: | ||
| threads: | ||
| max: 500 | ||
| min-spare: 100 | ||
| accept-count: 1000 | ||
| max-connections: 8192 | ||
| connection-timeout: 5000 | ||
|
|
||
| spring: | ||
| config: | ||
| activate: | ||
| on-profile: docker | ||
|
|
||
| data: | ||
| redis: | ||
| host: ticketing-redis | ||
| port: 6379 | ||
| host: ${REDIS_HOST:ticketing-redis} | ||
| port: ${REDIS_PORT:6379} | ||
| timeout: 5000ms | ||
| lettuce: | ||
| shutdown-timeout: 100ms | ||
|
|
||
| datasource: | ||
| url: jdbc:postgresql://${DB_HOST:ticketing-postgres}:${DB_PORT:15432}/${DB_NAME:ticketing}?currentSchema=${QUEUE_SCHEMA:queue} | ||
| url: jdbc:postgresql://${DB_HOST:ticketing-postgres}:${DB_PORT:15432}/${DB_NAME:ticketing}?currentSchema=${DB_SCHEMA:queue} | ||
| username: ${DB_USERNAME} | ||
| password: ${DB_PASSWORD} | ||
| driver-class-name: org.postgresql.Driver | ||
| hikari: | ||
| maximum-pool-size: 30 | ||
| minimum-idle: 10 | ||
| connection-timeout: 3000 | ||
| idle-timeout: 600000 | ||
| max-lifetime: 1800000 | ||
|
|
||
| jpa: | ||
| hibernate: | ||
| ddl-auto: ${JPA_DDL_AUTO:update} # 도커는 update (create면 매번 초기화 위험) | ||
| ddl-auto: ${JPA_DDL_AUTO:update} | ||
| properties: | ||
| hibernate: | ||
| default_schema: ${QUEUE_SCHEMA:queue} | ||
| default_schema: ${DB_SCHEMA:queue} | ||
| hbm2ddl: | ||
| create_schemas: true | ||
|
|
||
| kafka: | ||
| bootstrap-servers: kafka:9092 | ||
| bootstrap-servers: ${SPRING_KAFKA_BOOTSTRAP_SERVERS} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a safe default for Kafka bootstrap servers to avoid unresolved-placeholder startup failure. Line 42 currently requires 🔧 Proposed fix- bootstrap-servers: ${SPRING_KAFKA_BOOTSTRAP_SERVERS}
+ bootstrap-servers: ${SPRING_KAFKA_BOOTSTRAP_SERVERS:ticketing-kafka:9092}🤖 Prompt for AI Agents |
||
|
|
||
| eureka: | ||
| client: | ||
| service-url: | ||
| defaultZone: ${EUREKA_DEFAULT_ZONE:http://eureka-server:10001/eureka/} # 도커 내부 서비스명 | ||
| defaultZone: ${EUREKA_DEFAULT_ZONE:http://eureka-server:10001/eureka/} | ||
|
|
||
| management: | ||
| metrics: | ||
| tags: | ||
| application: ${spring.application.name} | ||
| endpoints: | ||
| web: | ||
| exposure: | ||
| include: health,info,prometheus | ||
| tracing: | ||
| sampling: | ||
| probability: 1.0 | ||
| probability: 0.1 | ||
| zipkin: | ||
| tracing: | ||
| endpoint: ${ZIPKIN_URL:http://localhost:9411/api/v2/spans} | ||
|
|
||
| # data: | ||
| # redis: | ||
| # password: ${REDIS_PASSWORD} | ||
| # sentinel: | ||
| # master: mymaster | ||
| # nodes: | ||
| # - redis-sentinel-1:26379 | ||
| # - redis-sentinel-2:26379 | ||
| # - redis-sentinel-3:26379 | ||
| # timeout: 5000ms | ||
| # lettuce: | ||
| # shutdown-timeout: 100ms | ||
| queue: | ||
| token: | ||
| secret: ${QUEUE_TOKEN_SECRET} | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,10 +3,27 @@ spring: | |||||
| name: queue-service | ||||||
|
|
||||||
| config: | ||||||
| import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:10002} | ||||||
| import: optional:configserver:http://localhost:10002 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid hardcoded Config Server endpoint in shared config. Line 6 pins the Config Server to Suggested patch- import: optional:configserver:http://localhost:10002
+ import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:10002}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| cloud: | ||||||
| config: | ||||||
| fail-fast: false # config-server 없어도 로컬 기동 가능 | ||||||
| import-check: | ||||||
| enabled: false | ||||||
| kafka: | ||||||
| bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:localhost:19092} | ||||||
| consumer: | ||||||
| group-id: queue-service | ||||||
| auto-offset-reset: latest | ||||||
| key-deserializer: org.apache.kafka.common.serialization.StringDeserializer | ||||||
| value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer | ||||||
| properties: | ||||||
| spring.deserializer.value.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer | ||||||
| spring.json.trusted.packages: "org.ticketing.queue.domain.event,java.util,java.lang" | ||||||
| spring.json.use.type.headers: false | ||||||
| spring.json.value.default.type: org.ticketing.queue.domain.event.MatchApprovedEvent | ||||||
|
|
||||||
| management: | ||||||
| tracing: | ||||||
| enabled: false | ||||||
| sampling: | ||||||
| probability: 0.0 | ||||||
| zipkin: | ||||||
| tracing: | ||||||
| export: | ||||||
| enabled: false | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,25 +19,45 @@ | |
| </encoder> | ||
| </appender> | ||
|
|
||
| <!-- 파일 (컬러 없이 순수 로그) --> | ||
| <!-- Docker/Loki용: JSON 구조화 로그 --> | ||
| <appender name="CONSOLE_JSON" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <encoder class="net.logstash.logback.encoder.LogstashEncoder"> | ||
| <customFields>{"service":"queue-service"}</customFields> | ||
| <fieldNames> | ||
| <timestamp>timestamp</timestamp> | ||
| <message>message</message> | ||
| <logger>logger</logger> | ||
| <thread>thread</thread> | ||
| <level>level</level> | ||
| </fieldNames> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <!-- 파일 --> | ||
| <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| <file>logs/queue-service.log</file> | ||
|
|
||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
| <fileNamePattern>logs/queue-service.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
| <maxHistory>14</maxHistory> | ||
| </rollingPolicy> | ||
|
|
||
| <encoder> | ||
| <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %thread %logger{36} [traceId=%X{traceId}] - %msg%n</pattern> | ||
| <charset>UTF-8</charset> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <!-- root --> | ||
| <root level="INFO"> | ||
| <appender-ref ref="CONSOLE"/> | ||
| <appender-ref ref="FILE"/> | ||
| </root> | ||
| <!-- 로컬: 텍스트, Docker: JSON --> | ||
| <springProfile name="default, local"> | ||
| <root level="INFO"> | ||
| <appender-ref ref="CONSOLE"/> | ||
| <appender-ref ref="FILE"/> | ||
| </root> | ||
| </springProfile> | ||
|
|
||
| <springProfile name="docker"> | ||
| <root level="INFO"> | ||
| <appender-ref ref="CONSOLE_JSON"/> | ||
| </root> | ||
| </springProfile> | ||
|
Comment on lines
+49
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify current logging config wiring and whether both logback variants exist
fd -i 'logback*.xml' src/main/resources
rg -n -C3 'logging\.config|springProfile|logback-spring\.xml|logback\.xml' src/main/resourcesRepository: 3s-ticketing/queue-service Length of output: 1084 🏁 Script executed: #!/bin/bash
# Check if this is a Spring Boot project and verify dependencies
echo "=== Looking for Spring Boot dependencies ==="
find . -name "pom.xml" -o -name "build.gradle" | head -5
# Check pom.xml if it exists
if [ -f "pom.xml" ]; then
echo -e "\n=== Spring Boot dependency in pom.xml ==="
rg -i 'spring-boot' pom.xml | head -10
fi
# Check for application configuration files
echo -e "\n=== Application config files ==="
fd -i 'application.*\.(properties|yml|yaml)' src/
# Check if logging.config is specified anywhere
echo -e "\n=== Custom logging config references ==="
rg -i 'logging\.config' . --type properties --type yaml 2>/dev/null | head -10Repository: 3s-ticketing/queue-service Length of output: 318 🏁 Script executed: #!/bin/bash
# Verify Spring Boot's behavior with logback.xml vs logback-spring.xml
# by checking Spring Boot documentation references in code or comments
echo "=== Checking for any Spring Boot version info ==="
if [ -f "pom.xml" ]; then
rg -A2 'spring-boot-starter-parent|spring.boot.version' pom.xml
fi
# Check if there are any bootstrap or configuration files
echo -e "\n=== Bootstrap/Configuration setup ==="
find . -name "bootstrap*" -o -name "application-*" | grep -E '\.(properties|yml|yaml)$' | head -20Repository: 3s-ticketing/queue-service Length of output: 203 🏁 Script executed: #!/bin/bash
# Check Spring Boot version in build.gradle
echo "=== Spring Boot version ==="
rg -i 'spring.boot|springboot' build.gradle -A2 -B2
# Check what profiles are defined
echo -e "\n=== Active profiles in application.yml ==="
rg -i 'profiles|spring:' src/main/resources/application.yml -A5 -B2
echo -e "\n=== Application docker profile ==="
cat src/main/resources/application-docker.ymlRepository: 3s-ticketing/queue-service Length of output: 2457 🏁 Script executed: #!/bin/bash
# Check if the current logback.xml is actually being processed with springProfile
echo "=== Full logback.xml content ==="
cat src/main/resources/logback.xml
# Check for any test that might verify logging behavior
echo -e "\n=== Looking for log configuration tests ==="
find . -path '*/test/*' -name '*Log*' -o -path '*/test/*' -name '*Appender*' | head -10Repository: 3s-ticketing/queue-service Length of output: 2498 Rename The FixRename the file from 🤖 Prompt for AI Agents |
||
|
|
||
| </configuration> | ||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: 3s-ticketing/queue-service
Length of output: 113
🏁 Script executed:
Repository: 3s-ticketing/queue-service
Length of output: 684
Run the runtime container as a non-root user.
Lines 17–23 define the final image but lack a
USERinstruction, causing the app to run as root. This weakens container isolation and violates security best practices.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents