--- kind: CONCEPT slug: adapter-inbound-web-c04 title: publicPaths가 먼저 등록되어 제한 경로 규칙을 덮는다 topic: security-and-trust-boundaries project: clean-architecture-backend-template status: 게시 전 sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 rootTreeNode: concept:adapter-inbound-web-c04 evidenceCapturedOn: 2026-09-01 assets: - key: adapter-inbound-web-c04 file: ../../../final/evidence/rendered/adapter-inbound-web-c04.svg - key: adapter-inbound-web-c04-diagram file: ../../../final/assets/diagrams/adapter-inbound-web-c04.svg evidence: - ../../../final/evidence/raw/adapter-inbound-web-c04.txt source: - 원본 분석 절은 analysis/14-adapter-inbound-web.md#L473 이다. module: adapter-inbound-web --- # publicPaths가 먼저 등록되어 제한 경로 규칙을 덮는다 `SecurityConfig`가 `publicPaths`를 `RestrictedPathRule`보다 먼저 등록한다. Spring Security는 첫 일치가 이기므로, 주석이 말하는 순서는 `anyRequest()`에 대해서만 성립하고 `publicPaths`에 대해서는 반대다. ## 본문 매처가 등록되는 순서는 이렇다. ```java // SecurityConfig.java:83-94 .authorizeHttpRequests(auth -> { if (publicPaths.length > 0) { auth.requestMatchers(publicPaths).permitAll(); } // ← 먼저 for (RestrictedPathRule rule : restricted) { // ← 나중 auth.requestMatchers(rule.pathPattern()).hasAnyAuthority(rule.authorities()); } auth.anyRequest().authenticated(); }) ``` ## 매처가 등록되는 순서 :::evidence key="adapter-inbound-web-c04-diagram" alt="공개 경로 매처와 제한 경로 규칙과 인증 요구 매처가 왼쪽에서 오른쪽으로 이어지고 화살표에 등록 순서가 붙은 구조" caption="매처가 등록되는 순서" zoom="false" ::: Spring Security는 첫 일치가 이긴다. 주석은 "Ordered before the authenticated catch-all: **a management path must be refused at the transport**"라고 하는데, 그 순서는 `anyRequest()`에 대해서만 성립하고 `publicPaths`에 대해서는 반대다. §12.3. ## RestrictedPathRule 참조 위치 :::evidence key="adapter-inbound-web-c04" alt="코드베이스에서 RestrictedPathRule 를 검색한 출력 8줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="RestrictedPathRule 코드베이스 검색 — 8줄 · exit 0" zoom="true" ::: ## 실제로 등록되는 값 프로덕션 `RestrictedPathRule` 생산자는 하나다 — `FileserverAdminPlaneConfiguration:36`이 fileserver 관리 경로를 등록한다. `publicPaths`의 기본값은 `${SECURITY_PUBLIC_PATHS:${PRESENTATION_API_BASE_PATH:/v1}/healthcheck}`로, 환경변수 하나로 전체가 대체된다.