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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### 새 마이크로서비스 추가 시 체크리스트
- [ ] 새 마이크로서비스를 위한 secret 이 작성되었나요?
- [ ] 새 마이크로서비스에 대한 deployment yaml 파일이 작성되었나요?
- [ ] 새 마이크로서비스에 대한 service yaml 파일이 작성되었나요?
- [ ] 새 마이크로서비스를 향한 API Gateway 설정이 작성되었나요?
- [ ] Dockerfile 이 작성되었나요?
- [ ] 새 마이크로서비스에 대한 CI/CD 파이프라인이 작성되었나요?
- [ ] 코파일럿 코드 리뷰를 위한 instructions가 작성되었나요?

### 새 API 버전 추가 시 주의할 점
- [ ] 새 API 버전에 대한 경로의 인증 필터링이 정상적으로 동작하나요?
- [ ] 프론트엔드에서 기존 API 버전도 정상적으로 동작하나요?
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ dependencies {

implementation 'org.springframework.boot:spring-boot-starter-security'

runtimeOnly 'io.micrometer:micrometer-registry-prometheus'

// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.12.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.5'
Expand Down
14 changes: 14 additions & 0 deletions k8s/gateway-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: gateway-metrics-service
namespace: pinit
spec:
selector:
app: pinit-gateway
ports:
- protocol: TCP
port: 9095
targetPort: 9095
Comment on lines +11 to +12
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: 관리 엔드포인트가 별도의 포트(9095)에서 실행되도록 설정되었지만, Kubernetes Deployment에 해당 포트가 노출되지 않았습니다.

영향: Kubernetes 환경에서 메트릭 서비스(gateway-metrics-service)가 포트 9095로 트래픽을 전달하려고 하지만, 컨테이너가 해당 포트를 노출하지 않아 연결이 실패합니다.

수정 제안: k8s/deployment.yaml의 ports 섹션에 관리 포트를 추가해야 합니다. containerPort: 9095를 name: management로 추가하세요.

Copilot generated this review using guidance from repository custom instructions.
type: NodePort
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: NodePort 타입의 서비스는 클러스터 외부에서 직접 접근이 가능하므로, 민감한 메트릭 정보가 노출될 수 있는 보안 위험이 있습니다.

영향: 인증 없이 외부에서 애플리케이션 메트릭에 접근할 수 있어, 시스템 내부 정보 노출, 성능 분석을 통한 공격 벡터 파악 등의 보안 위험이 존재합니다.

수정 제안: 프로메테우스가 클러스터 내부에서 실행되는 경우 type을 ClusterIP로 변경하거나, 외부 접근이 필요한 경우 인증/인가 메커니즘(예: NetworkPolicy, Ingress with authentication)을 추가해야 합니다.

Suggested change
type: NodePort
type: ClusterIP

Copilot uses AI. Check for mistakes.

2 changes: 1 addition & 1 deletion src/main/java/me/pinitgateway/security/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public SecurityWebFilterChain mainSecurityFilterChain(ServerHttpSecurity http,
JwtAuthenticationFilter jwtAuthenticationFilter) {
return applyCommon(http)
.authorizeExchange(auth -> auth
.pathMatchers("/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll()
.pathMatchers("/actuator/prometheus", "/actuator/health/liveness", "/actuator/health/readiness", "/v3/**", "/swagger-ui/**", "/async-api/**").permitAll()
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: /actuator/prometheus 엔드포인트가 주 게이트웨이 포트(8080)에서 인증 없이 접근 가능하도록 설정되어 있습니다. 하지만 management.server.port 설정에 따라 actuator 엔드포인트는 별도 포트(9095)에서만 접근 가능하므로 이 설정이 의도대로 작동하지 않습니다.

영향: 보안 설정이 불필요하거나 혼란을 야기할 수 있으며, 실제로 prometheus 엔드포인트는 9095 포트를 통해서만 접근 가능하므로 8080 포트의 보안 설정은 효과가 없습니다.

수정 제안: management.server.port를 사용하는 경우 actuator 엔드포인트는 별도 포트에서만 노출되므로, 주 포트의 보안 설정에서 /actuator/prometheus를 제거하는 것이 명확합니다. 또는 별도 관리 포트용 보안 설정을 추가로 구성해야 합니다.

Copilot generated this review using guidance from repository custom instructions.
.anyExchange().authenticated()
)
.addFilterAt(jwtAuthenticationFilter, SecurityWebFiltersOrder.AUTHENTICATION)
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ spring:
- Host=localhost:8080
filters:
- JwtSubToMemberIdHeader
metrics:
enabled: true
Comment on lines +25 to +26
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: Spring Cloud Gateway의 메트릭 설정이 routes 섹션 내부의 잘못된 위치에 있습니다. metrics 설정은 spring.cloud.gateway 레벨에 있어야 하며, routes 섹션 안에 있으면 안 됩니다.

영향: 설정이 제대로 인식되지 않아 게이트웨이 메트릭이 수집되지 않을 수 있습니다.

수정 제안: metrics 설정을 spring.cloud.gateway 레벨로 이동시켜야 합니다. 현재 spring.cloud.gateway.server.webflux.routes 내부가 아닌 spring.cloud.gateway 바로 아래에 위치해야 합니다.

Copilot uses AI. Check for mistakes.
management:
server:
port: 9096
endpoints:
web:
exposure:
include: "health,info,metrics,prometheus"
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: management 엔드포인트에 노출된 "info", "metrics" 엔드포인트가 민감한 정보를 포함할 수 있습니다.

영향: 애플리케이션의 내부 구성, 종속성 버전, 런타임 메트릭 등의 정보가 노출되어 공격자가 시스템 분석 및 취약점 파악에 활용할 수 있습니다.

수정 제안: 모니터링 목적이라면 "prometheus" 엔드포인트만 노출하고 나머지는 제거하거나, 별도의 인증 메커니즘을 추가하는 것을 고려해야 합니다.

Suggested change
include: "health,info,metrics,prometheus"
include: "prometheus"

Copilot uses AI. Check for mistakes.

server:
port: 8060
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ spring:
- Host=api.pinit.go-gradually.me
filters:
- JwtSubToMemberIdHeader
metrics:
enabled: true
Comment on lines +25 to +26
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: spring.cloud.gateway.server.webflux.metrics.enabled 설정의 위치가 올바르지 않습니다. 이 설정은 spring.cloud.gateway.metrics.enabled로 설정되어야 합니다.

영향: 현재 경로에서는 Gateway의 메트릭이 제대로 활성화되지 않을 수 있으며, Spring Cloud Gateway의 공식 설정 경로와 일치하지 않습니다.

수정 제안: 설정 경로를 spring.cloud.gateway.metrics.enabled: true로 수정해야 합니다.

Copilot uses AI. Check for mistakes.
management:
server:
port: 9095
endpoints:
web:
exposure:
include: "health,info,metrics,prometheus"
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

문제점: management 엔드포인트에 노출된 "info", "metrics" 엔드포인트가 민감한 정보를 포함할 수 있습니다.

영향: 애플리케이션의 내부 구성, 종속성 버전, 런타임 메트릭 등의 정보가 노출되어 공격자가 시스템 분석 및 취약점 파악에 활용할 수 있습니다.

수정 제안: 모니터링 목적이라면 "prometheus" 엔드포인트만 노출하고 나머지는 제거하거나, 별도의 인증 메커니즘을 추가하는 것을 고려해야 합니다.

Suggested change
include: "health,info,metrics,prometheus"
include: "health,prometheus"

Copilot uses AI. Check for mistakes.


path:
key:
Expand Down