feat: /actuator/prometheus에 스크레이핑 전용 Basic Auth 추가 - #178
Open
BcKmini wants to merge 1 commit into
Open
Conversation
fowoco/infra#34에서 붙인 클러스터 내부 Prometheus가 /actuator/prometheus를 스크레이핑할 수 있도록, observability 프로필이 아닌 환경(prod 포함)에서도 그 경로만 여는 두 번째 SecurityFilterChain을 추가한다. permitAll이 아니라 app.observability.prometheus-scrape-password로 설정한 계정의 Basic Auth로만 접근 가능 — /actuator/**가 이미 public ingress로 나가 있어서 permitAll은 내부 지표를 인터넷에 그대로 노출시키기 때문이다. 비밀번호를 설정하지 않으면(기본값) 기존과 동일하게 전부 거부 — 로컬/테스트 환경은 지금처럼 observability 프로필의 permitAll 체인을 그대로 쓴다. Closes #177 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
확인했습니다 인프라 Basic Auth 같은 경우는 인프라에서 안쓰는건가요 몰라서 궁금해서 물어봅니다 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
fowoco/infra#34에서 붙인 클러스터 내부 Prometheus가
/actuator/prometheus를 스크레이핑하면 401을 받는다 — 지금은observability & !prod프로필일 때만 permitAll이라 prod에서는 항상 막힌다(의도된 설계)./actuator/**전체가 이미 public ingress로 나가 있어서(k8s/05-ingress.yaml) 그냥 prod에서도 permitAll로 바꾸면 내부 지표가 인증 없이 인터넷에 노출된다. 그래서 스크레이핑 전용 Basic Auth 계정 하나만 추가:SecurityFilterChain(prometheusScrapeAuthSecurityFilterChain,@Profile("!(observability & !prod)"))이/actuator/prometheus를 담당.app.observability.prometheus-scrape-password(env:PROMETHEUS_SCRAPE_PASSWORD)가 비어 있으면(기본값) 계정 자체를 안 만들고 전부 거부 — "설정 안 하면 막힘"이 기본.prometheus계정의 Basic Auth로만 허용.compose.observability.yml워크플로우(observability 프로필, permitAll)는 그대로 유지.테스트
./gradlew test전체: BUILD SUCCESSFULPrometheusScrapeAuthIntegrationTest: 무자격 401 / 잘못된 비밀번호 401 / 올바른 자격 200ServerApplicationTests#prometheusEndpointIsNotPublicWithoutObservabilityProfile(비밀번호 미설정 시 401),PrometheusEndpointIntegrationTest(observability 프로필 permitAll) 모두 그대로 통과배포 시 필요
server-envSecret에PROMETHEUS_SCRAPE_PASSWORD추가 필요 (fowoco/infra의grafana-admin처럼 git에는 커밋하지 않음). Prometheus 쪽 scrape config에도 같은 값으로basic_auth설정 필요 — 별도로 처리.Closes #177