feat(core): 리버스 프록시 신뢰 설정 지원 및 미설정 진단
TLS 가 앞단에서 종단되고 앱에는 HTTP 로 전달되는 구성에서 X-Forwarded-* 가 전부 무시되어 화면 백지·IP 왜곡·webhook 403 이 함께 발생했다. 코어에 신뢰 프록시 설정 지점이 아예 없던 것이 원인이다. - config/trustedproxy.php 로 내장 TrustProxies 미들웨어에 값을 공급한다. bootstrap/app.php 는 건드리지 않는다 — withMiddleware 클로저는 .env 로드 전에 평가되어 env 가 항상 null 이 되는 조용한 no-op 이다. - 판정은 App\Support\TrustedProxyDiagnostic 단일 SSoT 에서 계산하고 대시보드 알림·환경설정 고급 탭·설치 마법사·trusted-proxy:status 네 면이 소비한다. 판정식은 "HTTPS 인식 실패" 가 아니라 "X-Forwarded-* 수신 중 AND 신뢰 프록시 미설정" 이다 — HTTP 전용 사이트가 프록시 뒤에 있으면 화면은 정상인 채로 나머지만 조용히 어긋나기 때문이다. - 값 편집 UI 와 쓰기 엔드포인트는 두지 않는다(잠금 역설 + XFF 위조 경로). - 혼합 콘텐츠 차단을 부트스트랩 폴백의 별도 사유로 가른다. 새로고침으로 낫지 않으므로 버튼을 렌더하지 않고, 원인·조치는 콘솔로 운영자에게 보낸다. - 대시보드 알림을 심각도로 배치한다 — warning 은 상단 배너, 그 외는 하단 카드. 같은 알림이 두 곳에 뜨지 않으며, 여러 건은 간격을 두고 쌓인다. 공개 이슈: (@lyg-kaban 제보)
This commit is contained in:
1 parent
46ada4dddb
commit
b6c5e1f323
55 files changed
+2861
-38
No files matched your search
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Http;
|
||||
|
||||
use App\Support\TrustedProxyDiagnostic;
|
||||
use Illuminate\Http\Middleware\TrustProxies;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 신뢰 프록시 설정 계약 (#124).
|
||||
*
|
||||
* `config/trustedproxy.php` 는 코어 PHP 코드 수정 없이 Laravel 내장 TrustProxies 미들웨어에
|
||||
* 값을 전달하는 **유일한 배선점**이다(`$this->proxies() ?: config('trustedproxy.proxies')`).
|
||||
* 그 배선이 끊기면 프록시 뒤 설치처의 화면이 통째로 뜨지 않는데, 예외도 로그도 남지 않는다.
|
||||
*
|
||||
* `bootstrap/app.php` 에서 `trustProxies(at: env(...))` 로 설정하는 것은 함정이다 —
|
||||
* `withMiddleware` 클로저는 `.env` 로드 전에 평가되어 `env()` 가 항상 `null` 을 돌려주고,
|
||||
* 설정한 것처럼 보이는데 실제로는 아무 프록시도 신뢰하지 않는 상태가 된다. 관련 케이스가
|
||||
* 그 형태의 재유입을 소스 스캔으로 차단한다.
|
||||
*
|
||||
* DB 를 쓰지 않으므로 `RefreshDatabase` 를 붙이지 않는다. 신뢰 상태는 `Request` 의 **정적**
|
||||
* 상태라 테스트마다 되돌리지 않으면 같은 프로세스의 후속 테스트로 샌다.
|
||||
*/
|
||||
class TrustedProxyContractTest extends TestCase
|
||||
{
|
||||
/** 프록시로 위장할 직전 호출 IP */
|
||||
private const REMOTE_ADDR = '10.0.0.5';
|
||||
|
||||
/** 프록시가 전달한 실제 방문자 IP */
|
||||
private const CLIENT_IP = '203.0.113.77';
|
||||
|
||||
/**
|
||||
* 각 테스트 후 정적 신뢰 상태를 원복합니다.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 프록시 뒤 요청을 만들고 TrustProxies 미들웨어를 통과시킵니다.
|
||||
*
|
||||
* @param string|null $proxies 신뢰 프록시 설정값
|
||||
* @param string $forwardedFor X-Forwarded-For 헤더 값
|
||||
* @return Request 미들웨어를 통과한 요청
|
||||
*/
|
||||
private function proxiedRequest(?string $proxies, string $forwardedFor = self::CLIENT_IP): Request
|
||||
{
|
||||
config(['trustedproxy.proxies' => $proxies]);
|
||||
|
||||
$request = Request::create('http://g7_2.dev/', 'GET', [], [], [], [
|
||||
'REMOTE_ADDR' => self::REMOTE_ADDR,
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||
'HTTP_X_FORWARDED_FOR' => $forwardedFor,
|
||||
'HTTP_X_FORWARDED_HOST' => 'g7_2.dev',
|
||||
'HTTP_X_FORWARDED_PORT' => '8443',
|
||||
]);
|
||||
|
||||
(new TrustProxies)->handle($request, fn () => null);
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* 설정이 없으면 X-Forwarded-* 를 전부 무시합니다 (기본값 — 기존 설치처 동작 불변).
|
||||
*
|
||||
* @scenario proxies_setting=unset, forwarded_proto=https, forwarded_for=single
|
||||
*
|
||||
* @effects unset_ignores_forwarded_headers
|
||||
*/
|
||||
public function test_미설정이면_전달_헤더를_신뢰하지_않는다(): void
|
||||
{
|
||||
$request = $this->proxiedRequest(null);
|
||||
|
||||
$this->assertFalse($request->isSecure(), '미설정 상태에서는 X-Forwarded-Proto 를 신뢰하지 않아야 합니다.');
|
||||
$this->assertSame(self::REMOTE_ADDR, $request->ip(), '미설정 상태에서는 REMOTE_ADDR 이 방문자 IP 여야 합니다.');
|
||||
$this->assertStringStartsWith('http://', $request->root(), '미설정 상태에서는 평문 HTTP 루트가 만들어져야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* `*` 은 직전 호출 IP 를 신뢰해 스킴·IP·호스트·포트를 모두 복원합니다.
|
||||
*
|
||||
* @scenario proxies_setting=star, forwarded_proto=https, forwarded_for=single, forwarded_host=same, forwarded_port=nonstandard
|
||||
*
|
||||
* @effects star_restores_scheme_ip_and_root
|
||||
*/
|
||||
public function test_별표는_직전_호출_i_p_를_신뢰한다(): void
|
||||
{
|
||||
$request = $this->proxiedRequest('*');
|
||||
|
||||
$this->assertTrue($request->isSecure());
|
||||
$this->assertSame(self::CLIENT_IP, $request->ip());
|
||||
$this->assertSame('https://g7_2.dev:8443', $request->root());
|
||||
}
|
||||
|
||||
/**
|
||||
* `**` 은 Laravel 내장 미들웨어에서 `*` 과 동일하게 동작합니다.
|
||||
*
|
||||
* 별도 패키지 시절 `**` 는 "모든 프록시 신뢰" 였으나, 내장 구현은 `*` 과 같은
|
||||
* `setTrustedProxyIpAddressesToTheCallingIp()` 로 분기한다. 그 사실을 문서·설정 주석이
|
||||
* 그대로 서술하고 있으므로, 프레임워크 업그레이드로 의미가 갈라지면 여기서 드러나야 한다.
|
||||
*
|
||||
* @scenario proxies_setting=double_star, forwarded_proto=https, forwarded_for=single
|
||||
*
|
||||
* @effects double_star_behaves_like_star
|
||||
*/
|
||||
public function test_별표두개는_별표와_동일하게_동작한다(): void
|
||||
{
|
||||
$starIp = $this->proxiedRequest('*')->ip();
|
||||
Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
$double = $this->proxiedRequest('**');
|
||||
|
||||
$this->assertTrue($double->isSecure());
|
||||
$this->assertSame($starIp, $double->ip(), '** 와 * 의 방문자 IP 해석이 갈라졌습니다 — 문서·설정 주석을 함께 갱신해야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 다단계 체인에서 `*` 은 마지막 프록시를 방문자로 본다 — 모든 단을 나열해야 복원됩니다.
|
||||
*
|
||||
* @scenario proxies_setting=star, forwarded_for=chain
|
||||
*
|
||||
* @effects chain_requires_listing_every_hop
|
||||
*/
|
||||
public function test_다단계_체인은_모든_프록시를_나열해야_클라이언트_i_p_가_해석된다(): void
|
||||
{
|
||||
$chain = self::CLIENT_IP.', 10.1.1.1, 10.2.2.2';
|
||||
|
||||
$star = $this->proxiedRequest('*', $chain);
|
||||
$this->assertSame('10.2.2.2', $star->ip(), '* 은 직전 호출 IP 하나만 신뢰하므로 마지막 프록시가 방문자로 보여야 합니다.');
|
||||
Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
$listed = $this->proxiedRequest(self::REMOTE_ADDR.',10.1.1.1,10.2.2.2', $chain);
|
||||
$this->assertSame(self::CLIENT_IP, $listed->ip(), '체인의 모든 단을 나열하면 최초 클라이언트 IP 가 해석되어야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록에 직전 호출 IP 가 있으면 신뢰하고, 없으면 신뢰하지 않습니다.
|
||||
*
|
||||
* @scenario proxies_setting=single_ip_match, forwarded_proto=https
|
||||
*
|
||||
* @effects ip_list_match_trusts_and_mismatch_rejects
|
||||
*/
|
||||
public function test_i_p_목록은_일치할_때만_신뢰한다(): void
|
||||
{
|
||||
$match = $this->proxiedRequest(self::REMOTE_ADDR);
|
||||
$this->assertTrue($match->isSecure());
|
||||
$this->assertSame(self::CLIENT_IP, $match->ip());
|
||||
Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
$mismatch = $this->proxiedRequest('10.0.0.9');
|
||||
$this->assertFalse($mismatch->isSecure(), '목록에 없는 프록시의 헤더는 신뢰하지 않아야 합니다.');
|
||||
$this->assertSame(self::REMOTE_ADDR, $mismatch->ip());
|
||||
}
|
||||
|
||||
/**
|
||||
* CIDR 표기도 신뢰 판정에 사용됩니다.
|
||||
*
|
||||
* @scenario proxies_setting=cidr, forwarded_proto=https
|
||||
*
|
||||
* @effects cidr_notation_is_honored
|
||||
*/
|
||||
public function test_cid_r_표기가_신뢰_판정에_사용된다(): void
|
||||
{
|
||||
$request = $this->proxiedRequest('10.0.0.0/8');
|
||||
|
||||
$this->assertTrue($request->isSecure());
|
||||
$this->assertSame(self::CLIENT_IP, $request->ip());
|
||||
}
|
||||
|
||||
/**
|
||||
* `config/trustedproxy.php` 는 `proxies` 키를 노출하고 TRUSTED_PROXIES 를 그대로 반영합니다.
|
||||
*
|
||||
* @effects config_file_exposes_proxies_key_from_env
|
||||
*/
|
||||
public function test_설정_파일이_truste_d_proxie_s_를_그대로_반영한다(): void
|
||||
{
|
||||
$path = base_path('config/trustedproxy.php');
|
||||
$this->assertFileExists($path, 'config/trustedproxy.php 는 신뢰 프록시 설정의 유일한 배선점입니다.');
|
||||
|
||||
$previous = $_ENV['TRUSTED_PROXIES'] ?? null;
|
||||
$_ENV['TRUSTED_PROXIES'] = '198.51.100.7';
|
||||
|
||||
try {
|
||||
$config = require $path;
|
||||
} finally {
|
||||
if ($previous === null) {
|
||||
unset($_ENV['TRUSTED_PROXIES']);
|
||||
} else {
|
||||
$_ENV['TRUSTED_PROXIES'] = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertArrayHasKey('proxies', $config);
|
||||
$this->assertSame('198.51.100.7', $config['proxies']);
|
||||
}
|
||||
|
||||
/**
|
||||
* `bootstrap/app.php` 에 env() 기반 trustProxies / trustHosts 가 재유입되지 않습니다.
|
||||
*
|
||||
* `withMiddleware` 클로저는 `.env` 로드 전에 평가되므로 그 자리의 `env()` 는 항상 null 이다
|
||||
* — 오류 없이 no-op 이 되어, 설정한 것처럼 보이는데 아무 프록시도 신뢰하지 않는다.
|
||||
* `trustHosts()` 는 호출 자체가 모든 설치처에서 Host 검증을 켠다(opt-in 원칙 위반).
|
||||
*
|
||||
* @effects bootstrap_does_not_reintroduce_env_trust_proxies
|
||||
*/
|
||||
public function test_bootstrap_에_env_기반_trust_proxies_가_없다(): void
|
||||
{
|
||||
$source = (string) file_get_contents(base_path('bootstrap/app.php'));
|
||||
|
||||
// 주석을 제거해 "하면 안 되는 것" 설명문이 오탐되지 않게 한다.
|
||||
$stripped = (string) preg_replace(['#/\*.*?\*/#s', '#//[^\n]*#'], '', $source);
|
||||
|
||||
$this->assertStringNotContainsString(
|
||||
'trustHosts(',
|
||||
$stripped,
|
||||
'trustHosts() 호출은 모든 설치처에서 Host 검증을 켭니다 — opt-in 원칙 위반입니다.'
|
||||
);
|
||||
|
||||
if (preg_match('/trustProxies\s*\(([^;]*)\)/s', $stripped, $m) === 1) {
|
||||
$this->assertStringNotContainsString(
|
||||
'env(',
|
||||
$m[1],
|
||||
'bootstrap/app.php 의 trustProxies() 안에서 env() 를 읽으면 항상 null 입니다 — config/trustedproxy.php 를 쓰세요.'
|
||||
);
|
||||
} else {
|
||||
$this->assertTrue(true, 'trustProxies() 호출이 없으므로 config 폴백이 유일한 배선점입니다.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `.env.example` 과 `.env.testing.example` 이 TRUSTED_PROXIES 를 안내합니다.
|
||||
*
|
||||
* @effects env_examples_document_trusted_proxies
|
||||
*/
|
||||
public function test_env_예시_파일이_truste_d_proxie_s_를_안내한다(): void
|
||||
{
|
||||
foreach (['.env.example', '.env.testing.example'] as $file) {
|
||||
$this->assertStringContainsString(
|
||||
'TRUSTED_PROXIES',
|
||||
(string) file_get_contents(base_path($file)),
|
||||
$file.' 에 TRUSTED_PROXIES 안내가 있어야 합니다.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 설치 마법사의 전달 헤더 목록이 코어 진단과 같은 집합입니다.
|
||||
*
|
||||
* 설치 마법사는 순수 PHP 영역이라 Laravel 헬퍼를 쓸 수 없어 목록을 복제한다. 복제본이
|
||||
* 갈라지면 "설치 때는 안내가 떴는데 운영 화면에는 경고가 없다"(또는 그 반대)가 된다.
|
||||
*
|
||||
* @effects installer_header_list_matches_core_diagnostic
|
||||
*/
|
||||
public function test_설치_마법사의_전달_헤더_목록이_코어와_같다(): void
|
||||
{
|
||||
$source = (string) file_get_contents(base_path('public/install/api/check-configuration.php'));
|
||||
|
||||
foreach (TrustedProxyDiagnostic::FORWARDED_HEADERS as $header) {
|
||||
$this->assertStringContainsString(
|
||||
"'".$header."' => 'HTTP_",
|
||||
$source,
|
||||
$header.' 가 설치 마법사의 전달 헤더 목록에 없습니다.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 신뢰 프록시가 있으면 쿠키의 Secure 가 자동 판정으로 붙고, 없으면 붙지 않습니다.
|
||||
*
|
||||
* `SESSION_SECURE_COOKIE` 미설정 시 Symfony `Response::prepare()` 가 `isSecure()` 로
|
||||
* 판정하므로, 신뢰 설정이 없으면 HTTPS 사이트인데 쿠키가 Secure 없이 발급된다.
|
||||
*
|
||||
* @scenario proxies_setting=star, session_secure_cookie=unset
|
||||
*
|
||||
* @effects cookie_secure_follows_trusted_scheme
|
||||
*/
|
||||
public function test_쿠키_secure_는_신뢰된_스킴을_따른다(): void
|
||||
{
|
||||
$this->assertTrue($this->cookieIsSecureAfterPrepare('*'), '신뢰 프록시가 있으면 쿠키에 Secure 가 붙어야 합니다.');
|
||||
Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_FOR);
|
||||
|
||||
$this->assertFalse($this->cookieIsSecureAfterPrepare(null), '신뢰 프록시가 없으면 평문으로 판정되어 Secure 가 붙지 않습니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 주어진 신뢰 설정으로 응답을 준비했을 때 쿠키에 Secure 가 붙는지 판정합니다.
|
||||
*
|
||||
* @param string|null $proxies 신뢰 프록시 설정값
|
||||
* @return bool Secure 부착 여부
|
||||
*/
|
||||
private function cookieIsSecureAfterPrepare(?string $proxies): bool
|
||||
{
|
||||
$request = $this->proxiedRequest($proxies);
|
||||
|
||||
$response = new Response('ok');
|
||||
// secure = null → Response::prepare() 가 요청 스킴으로 자동 판정한다.
|
||||
$response->headers->setCookie(Cookie::create('g7-session', 'value', 0, '/', null, null));
|
||||
$response->prepare($request);
|
||||
|
||||
foreach ($response->headers->getCookies() as $cookie) {
|
||||
if ($cookie->getName() === 'g7-session') {
|
||||
return $cookie->isSecure();
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('g7-session 쿠키를 응답에서 찾지 못했습니다.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Http;
|
||||
|
||||
use App\Listeners\TrustedProxyAlertListener;
|
||||
use App\Support\TrustedProxyDiagnostic;
|
||||
use Illuminate\Http\Request;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 신뢰 프록시 진단 판정 (#124).
|
||||
*
|
||||
* 판정식은 "HTTPS 인식 실패" 가 아니라 다음이다:
|
||||
*
|
||||
* X-Forwarded-* 헤더를 수신 중 AND 신뢰 프록시가 비어 있음
|
||||
*
|
||||
* HTTPS 기준으로 잡으면 **HTTP 전용 사이트가 프록시 뒤에 있는 구성**을 덮지 못한다. 그
|
||||
* 구성에서는 혼합 콘텐츠가 없어 화면이 완전히 정상 렌더되지만 webhook 403 · IP 왜곡 ·
|
||||
* 로그인 제한 붕괴는 그대로 발생하며, 능동 경고가 없으면 영구 미발견이다. 그래서 이
|
||||
* 테스트가 그 축을 명시적으로 잠근다.
|
||||
*/
|
||||
class TrustedProxyDiagnosticTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* 전달 헤더를 붙인 요청을 만듭니다.
|
||||
*
|
||||
* @param array<string, string> $server 추가 서버 변수
|
||||
* @return Request 생성된 요청
|
||||
*/
|
||||
private function request(array $server = []): Request
|
||||
{
|
||||
return Request::create('http://g7_2.dev/', 'GET', [], [], [], array_merge([
|
||||
'REMOTE_ADDR' => '10.0.0.5',
|
||||
], $server));
|
||||
}
|
||||
|
||||
/**
|
||||
* 프록시 헤더가 없고 설정도 없으면 정상(직접 노출 구성)입니다.
|
||||
*
|
||||
* @scenario proxies_setting=unset, forwarded_proto=absent, forwarded_for=absent
|
||||
*
|
||||
* @effects direct_exposure_is_not_a_warning
|
||||
*/
|
||||
public function test_프록시_헤더가_없으면_경고하지_않는다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => null]);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest($this->request());
|
||||
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_OK, $result['status']);
|
||||
$this->assertSame([], $result['forwarded_headers']);
|
||||
$this->assertFalse($result['trusted_configured']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 프록시 헤더를 받는데 설정이 없으면 경고입니다.
|
||||
*
|
||||
* @scenario proxies_setting=unset, forwarded_proto=https, forwarded_for=single
|
||||
*
|
||||
* @effects forwarded_without_config_is_warning
|
||||
*/
|
||||
public function test_프록시_헤더를_받는데_설정이_없으면_경고한다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => null]);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest($this->request([
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||
'HTTP_X_FORWARDED_FOR' => '203.0.113.77',
|
||||
]));
|
||||
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_WARNING, $result['status']);
|
||||
$this->assertContains('X-Forwarded-Proto', $result['forwarded_headers']);
|
||||
$this->assertContains('X-Forwarded-For', $result['forwarded_headers']);
|
||||
// 신뢰하지 않으므로 방문자 IP 가 직전 호출 IP 와 같다 = 모두 한 사람으로 기록된다.
|
||||
$this->assertSame($result['remote_addr'], $result['client_ip']);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP 전용 사이트가 프록시 뒤에 있어도 경고합니다 (조용한 구성).
|
||||
*
|
||||
* 이 케이스가 "HTTPS 인식 실패" 판정식과 갈라지는 유일한 지점이다. 화면은 정상이라
|
||||
* 사용자도 운영자도 이상을 감지할 단서가 없다.
|
||||
*
|
||||
* @scenario proxies_setting=unset, forwarded_proto=http, forwarded_for=single
|
||||
*
|
||||
* @effects http_only_behind_proxy_still_warns
|
||||
*/
|
||||
public function test_htt_p_전용_사이트가_프록시_뒤에_있어도_경고한다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => null]);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest($this->request([
|
||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||
'HTTP_X_FORWARDED_FOR' => '203.0.113.77',
|
||||
]));
|
||||
|
||||
$this->assertFalse($result['is_secure'], '이 구성은 HTTPS 가 아니다 — 그럼에도 경고해야 한다.');
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_WARNING, $result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 설정이 있으면 프록시 헤더를 받아도 정상입니다.
|
||||
*
|
||||
* @scenario proxies_setting=star, forwarded_proto=https, forwarded_for=single
|
||||
*
|
||||
* @effects configured_proxy_is_ok
|
||||
*/
|
||||
public function test_설정이_있으면_정상으로_판정한다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => '*']);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest($this->request([
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||
]));
|
||||
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_OK, $result['status']);
|
||||
$this->assertTrue($result['trusted_configured']);
|
||||
$this->assertSame('*', $result['configured_proxies']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 빈 문자열 설정은 미설정과 같게 다룹니다.
|
||||
*
|
||||
* `.env` 에 `TRUSTED_PROXIES=` 만 남긴 상태가 "설정됨" 으로 판정되면 경고가 조용히
|
||||
* 사라지는데, 미들웨어는 여전히 아무것도 신뢰하지 않는다.
|
||||
*
|
||||
* @effects empty_string_counts_as_unset
|
||||
*/
|
||||
public function test_빈_문자열은_미설정과_같다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => ' ']);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest($this->request([
|
||||
'HTTP_X_FORWARDED_FOR' => '203.0.113.77',
|
||||
]));
|
||||
|
||||
$this->assertFalse($result['trusted_configured']);
|
||||
$this->assertNull($result['configured_proxies']);
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_WARNING, $result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청이 없는 맥락(콘솔)은 "값 없음" 이 아니라 "판정 불가" 입니다.
|
||||
*
|
||||
* @effects console_context_is_not_applicable
|
||||
*/
|
||||
public function test_요청이_없으면_판정_불가로_구분한다(): void
|
||||
{
|
||||
config(['trustedproxy.proxies' => null]);
|
||||
|
||||
$result = TrustedProxyDiagnostic::forRequest(null);
|
||||
|
||||
$this->assertSame(TrustedProxyDiagnostic::STATUS_NOT_APPLICABLE, $result['status']);
|
||||
$this->assertNull($result['is_secure']);
|
||||
$this->assertNull($result['client_ip']);
|
||||
$this->assertNull($result['remote_addr']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 대시보드 알림은 경고 상태에서만, 심각도 `warning` 으로 추가됩니다.
|
||||
*
|
||||
* 알림 카드의 색상 분기는 `alert.type` 을 읽으므로, 여기서 `warning` 이 아니면 경고가
|
||||
* 회색 안내로 렌더되어 경고로 보이지 않는다.
|
||||
*
|
||||
* @effects dashboard_alert_only_on_warning_with_warning_type
|
||||
*/
|
||||
public function test_대시보드_알림은_경고_상태에서만_추가된다(): void
|
||||
{
|
||||
$listener = new TrustedProxyAlertListener;
|
||||
|
||||
config(['trustedproxy.proxies' => '*']);
|
||||
$this->assertSame([], $listener->addTrustedProxyAlert([]), '설정이 있으면 알림을 추가하지 않아야 합니다.');
|
||||
|
||||
config(['trustedproxy.proxies' => null]);
|
||||
app()->instance('request', $this->request([
|
||||
'HTTP_X_FORWARDED_FOR' => '203.0.113.77',
|
||||
]));
|
||||
|
||||
$alerts = $listener->addTrustedProxyAlert([]);
|
||||
|
||||
$this->assertCount(1, $alerts);
|
||||
$this->assertSame('trusted_proxy_missing', $alerts[0]['id']);
|
||||
$this->assertSame('warning', $alerts[0]['type'], '심각도가 warning 이 아니면 대시보드에서 경고로 렌더되지 않습니다.');
|
||||
$this->assertNotSame('', $alerts[0]['title']);
|
||||
$this->assertStringNotContainsString(':headers', $alerts[0]['message'], '치환 자리가 그대로 남아 있습니다.');
|
||||
$this->assertStringNotContainsString(':ip', $alerts[0]['message'], '치환 자리가 그대로 남아 있습니다.');
|
||||
$this->assertStringContainsString('TRUSTED_PROXIES', $alerts[0]['message'], '원인만이 아니라 조치도 담아야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 진단 엔드포인트는 값 편집 경로를 제공하지 않습니다 (읽기 전용 계약).
|
||||
*
|
||||
* @effects diagnostic_endpoint_is_read_only
|
||||
*/
|
||||
public function test_진단_엔드포인트는_읽기_전용이다(): void
|
||||
{
|
||||
$routes = app('router')->getRoutes();
|
||||
$names = [];
|
||||
|
||||
foreach ($routes as $route) {
|
||||
if (str_contains((string) $route->uri(), 'settings/trusted-proxy')) {
|
||||
$names[] = implode('|', $route->methods());
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertNotSame([], $names, '진단 엔드포인트가 등록되어 있어야 합니다.');
|
||||
|
||||
foreach ($names as $methods) {
|
||||
$this->assertStringNotContainsString('POST', $methods, '신뢰 프록시 값은 .env 전용입니다 — 쓰기 라우트를 두지 않습니다.');
|
||||
$this->assertStringNotContainsString('PUT', $methods);
|
||||
$this->assertStringNotContainsString('PATCH', $methods);
|
||||
$this->assertStringNotContainsString('DELETE', $methods);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,9 +48,9 @@ class BootstrapFallbackDiagnosisTest extends TestCase
|
||||
"[{$templateType}] 전역 부재 경로가 SyntaxError 관측 결과로 사유를 가르지 않는다"
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
"renderFallback('network')",
|
||||
"renderFallback(blocked ? 'blocked' : 'network')",
|
||||
$html,
|
||||
"[{$templateType}] 재시도 소진 경로가 network 사유를 넘기지 않는다"
|
||||
"[{$templateType}] 재시도 소진 경로가 차단/네트워크 사유를 가르지 않는다"
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'data-g7-bootstrap-fallback',
|
||||
@@ -60,6 +60,96 @@ class BootstrapFallbackDiagnosisTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTPS 페이지가 http 자산을 요청해 차단된 경우를 별도 사유로 가른다 (#124).
|
||||
*
|
||||
* 이 실패는 회선이 멀쩡하고 새로고침으로도 낫지 않으므로, 네트워크 문구 + 새로고침
|
||||
* 버튼은 두 겹의 거짓 안내가 된다.
|
||||
*
|
||||
* @effects blocked_branch_is_emitted_with_https_http_judgment
|
||||
*/
|
||||
public function test_혼합_콘텐츠_차단을_별도_사유로_가른다(): void
|
||||
{
|
||||
foreach (['user', 'admin'] as $templateType) {
|
||||
$html = $this->render($templateType);
|
||||
|
||||
$this->assertStringContainsString(
|
||||
"location.protocol === 'https:'",
|
||||
$html,
|
||||
"[{$templateType}] 차단 판정이 페이지 스킴을 보지 않는다"
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
"indexOf('http://') === 0",
|
||||
$html,
|
||||
"[{$templateType}] 차단 판정이 자산 스킴을 보지 않는다"
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
"blocked ? 'blocked' : 'network'",
|
||||
$html,
|
||||
"[{$templateType}] 폴백 마커가 blocked 값을 낼 수 없다"
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'(incompatible || blocked)',
|
||||
$html,
|
||||
"[{$templateType}] 차단 경로에서 새로고침 버튼이 생략되지 않는다"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 차단 안내는 화면(방문자)과 콘솔(운영자)로 대상을 나눈다 (#124).
|
||||
*
|
||||
* 화면 문구에 서버 설정 지시를 쓰면 방문자에게 실행 불가능한 지시를 주는 셈이고,
|
||||
* 원인을 통째로 감추면 운영자가 도달할 통로가 사라진다.
|
||||
*
|
||||
* @effects blocked_notice_splits_visitor_screen_and_operator_console
|
||||
*/
|
||||
public function test_차단_안내는_화면과_콘솔로_대상을_나눈다(): void
|
||||
{
|
||||
$html = $this->render();
|
||||
|
||||
// 콘솔에는 운영자 기준 원인·조치가 영문으로 남는다 (기존 로그와 같은 계열).
|
||||
$this->assertStringContainsString('Blocked as mixed content', $html);
|
||||
$this->assertStringContainsString('TRUSTED_PROXIES', $html);
|
||||
$this->assertStringContainsString('docs/backend/reverse-proxy.md', $html);
|
||||
|
||||
$original = app()->getLocale();
|
||||
|
||||
try {
|
||||
foreach (['ko', 'en'] as $locale) {
|
||||
app()->setLocale($locale);
|
||||
|
||||
foreach (['blocked_title', 'blocked_message'] as $key) {
|
||||
$value = __("errors.bootstrap.{$key}");
|
||||
|
||||
$this->assertNotSame("errors.bootstrap.{$key}", $value, "[{$locale}] errors.bootstrap.{$key} 미정의");
|
||||
$this->assertNotSame('', trim($value), "[{$locale}] errors.bootstrap.{$key} 가 비어 있다");
|
||||
}
|
||||
|
||||
// 사유가 다르면 문구도 달라야 한다 — 같으면 분기가 무의미하다.
|
||||
$this->assertNotSame(
|
||||
__('errors.bootstrap.message'),
|
||||
__('errors.bootstrap.blocked_message'),
|
||||
"[{$locale}] 차단 문구가 네트워크 문구와 동일하다"
|
||||
);
|
||||
|
||||
// 화면 문구는 방문자 기준 — 서버 설정 지시를 담지 않는다.
|
||||
$this->assertStringNotContainsString(
|
||||
'TRUSTED_PROXIES',
|
||||
__('errors.bootstrap.blocked_message'),
|
||||
"[{$locale}] 방문자 화면에 서버 설정 지시가 노출된다"
|
||||
);
|
||||
$this->assertStringNotContainsString(
|
||||
'.env',
|
||||
__('errors.bootstrap.blocked_message'),
|
||||
"[{$locale}] 방문자 화면에 서버 설정 지시가 노출된다"
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
app()->setLocale($original);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_파싱_오류_관측_리스너가_설치된다(): void
|
||||
{
|
||||
$html = $this->render();
|
||||
@@ -115,11 +205,18 @@ class BootstrapFallbackDiagnosisTest extends TestCase
|
||||
$this->assertArrayHasKey('bootstrap', $ja);
|
||||
$this->assertArrayHasKey('incompatible_title', $ja['bootstrap']);
|
||||
$this->assertArrayHasKey('incompatible_message', $ja['bootstrap']);
|
||||
$this->assertArrayHasKey('blocked_title', $ja['bootstrap']);
|
||||
$this->assertArrayHasKey('blocked_message', $ja['bootstrap']);
|
||||
$this->assertNotSame(
|
||||
$ja['bootstrap']['message'],
|
||||
$ja['bootstrap']['incompatible_message'],
|
||||
'ja 비호환 문구가 네트워크 문구와 동일하다'
|
||||
);
|
||||
$this->assertNotSame(
|
||||
$ja['bootstrap']['message'],
|
||||
$ja['bootstrap']['blocked_message'],
|
||||
'ja 차단 문구가 네트워크 문구와 동일하다'
|
||||
);
|
||||
}
|
||||
|
||||
public function test_인라인_부트스트랩은_구형_브라우저_문법만_사용한다(): void
|
||||
|
||||
@@ -114,6 +114,80 @@ async function assertNetworkFailure(page: Page, url: string): Promise<void> {
|
||||
expect(attempts).toBe(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 혼합 콘텐츠 차단 케이스 본문 — 회선은 멀쩡한데 브라우저가 요청을 거부하는 실패다 (공개 #124).
|
||||
*
|
||||
* 문서 HTML 의 코어 스크립트 URL 만 `http://` 로 바꾸면 재현된다 — TLS 종단 프록시도
|
||||
* 인증서도 필요 없다. 프록시 뒤에서 신뢰 프록시가 지정되지 않았을 때 서버가 만들어 내는
|
||||
* 것이 바로 이 HTML 이기 때문이다.
|
||||
*
|
||||
* 판정은 `location.protocol === 'https:'` 를 보므로, 기대값은 실행 시점 base URL 의
|
||||
* 스킴에서 파생한다 — http base 에서는 이 실패가 그냥 도달 불가이므로 `network` 가 정답이다.
|
||||
* 분기 자체의 방출은 스킴과 무관하게 BootstrapFallbackDiagnosisTest 가 단언한다.
|
||||
*
|
||||
* @param page Playwright page
|
||||
* @param url 진입 경로
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function assertMixedContentBlocked(page: Page, url: string): Promise<void> {
|
||||
const consoleErrors: string[] = [];
|
||||
page.on('console', (m) => {
|
||||
if (m.type() === 'error') consoleErrors.push(m.text());
|
||||
});
|
||||
|
||||
// 문서 응답을 가로채 코어 번들 URL 만 절대 http:// 로 바꾼다.
|
||||
// 서버는 이 URL 을 절대(`https://host/build/core/…`) 또는 상대(`/build/core/…`) 어느
|
||||
// 형태로도 낼 수 있으므로 두 경우를 모두 정규화해 다룬다 — 한 형태만 가정하면 치환이
|
||||
// 조용히 0건이 되어 테스트가 아무것도 재현하지 않은 채 실패한다.
|
||||
let rewritten = 0;
|
||||
|
||||
await page.route('**/*', async (route) => {
|
||||
if (route.request().resourceType() !== 'document') return route.fallback();
|
||||
|
||||
const response = await route.fetch();
|
||||
const body = await response.text();
|
||||
const origin = new URL(route.request().url()).origin;
|
||||
|
||||
const patched = body.replace(
|
||||
/src="([^"]*\/build\/core\/template-engine\.min\.js[^"]*)"/g,
|
||||
(whole, src: string) => {
|
||||
const abs = new URL(src, origin);
|
||||
if (abs.protocol !== 'https:') return whole;
|
||||
abs.protocol = 'http:';
|
||||
rewritten += 1;
|
||||
return `src="${abs.toString()}"`;
|
||||
}
|
||||
);
|
||||
|
||||
return route.fulfill({ response, body: patched });
|
||||
});
|
||||
|
||||
await page.goto(url);
|
||||
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
||||
|
||||
const isHttpsBase = new URL(page.url()).protocol === 'https:';
|
||||
if (isHttpsBase) {
|
||||
// 치환이 실제로 일어났는지 확인한다 — 0 건이면 아래 단언은 결함이 아니라
|
||||
// 재현 실패를 보고하게 된다.
|
||||
expect(rewritten, '코어 번들 URL 치환이 0 건입니다 — 재현되지 않았습니다').toBeGreaterThan(0);
|
||||
}
|
||||
|
||||
const isHttps = isHttpsBase;
|
||||
const fallback = await readFallback(page);
|
||||
|
||||
expect(fallback.reason).toBe(isHttps ? 'blocked' : 'network');
|
||||
expect(fallback.title.length).toBeGreaterThan(0);
|
||||
// 차단은 새로고침으로 낫지 않는다 — 버튼을 두면 그것 자체가 다시 거짓 안내가 된다.
|
||||
expect(fallback.buttons).toBe(isHttps ? 0 : 1);
|
||||
|
||||
if (isHttps) {
|
||||
// 화면에서 뺀 원인·조치는 콘솔에서 운영자에게 도달해야 한다.
|
||||
const joined = consoleErrors.join(' | ');
|
||||
expect(joined).toMatch(/Blocked as mixed content/);
|
||||
expect(joined).toMatch(/TRUSTED_PROXIES/);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 정상 부팅 케이스 본문 — 폴백이 오발동하지 않아야 한다.
|
||||
*
|
||||
@@ -175,6 +249,22 @@ test.describe('부팅 실패 사유별 안내 분기 (공개 #121)', () => {
|
||||
await assertNetworkFailure(page, '/admin');
|
||||
});
|
||||
|
||||
/**
|
||||
* @scenario entrypoint=user, failure_mode=mixed_content_blocked
|
||||
* @effects mixed_content_blocked_renders_blocked_notice, blocked_notice_omits_reload_button
|
||||
*/
|
||||
test('@smoke [user] 코어 번들이 http 로 차단 → 사이트 설정 안내 + 새로고침 버튼 부재', async ({ page }) => {
|
||||
await assertMixedContentBlocked(page, '/');
|
||||
});
|
||||
|
||||
/**
|
||||
* @scenario entrypoint=admin, failure_mode=mixed_content_blocked
|
||||
* @effects mixed_content_blocked_renders_blocked_notice, blocked_notice_omits_reload_button
|
||||
*/
|
||||
test('@smoke [admin] 코어 번들이 http 로 차단 → 사이트 설정 안내 + 새로고침 버튼 부재', async ({ page }) => {
|
||||
await assertMixedContentBlocked(page, '/admin');
|
||||
});
|
||||
|
||||
/**
|
||||
* @scenario entrypoint=user, failure_mode=none
|
||||
* @effects normal_boot_renders_no_fallback
|
||||
|
||||
@@ -12,18 +12,25 @@ description: |
|
||||
- window 의 error 이벤트로 번들 SyntaxError 를 관측(element 이벤트로는 구분 불가)
|
||||
- 관측되면 renderFallback('incompatible') — 전용 문구 + 새로고침 버튼 생략
|
||||
- 관측되지 않으면 renderFallback('corrupt') — 기존 문구 유지(사유 미상)
|
||||
- 재시도 소진 경로는 renderFallback('network') — 기존 문구 + 버튼 유지
|
||||
- 재시도 소진 경로는 두 갈래다 — HTTPS 페이지가 http:// 자산을 요청해 브라우저가
|
||||
차단한 경우는 renderFallback('blocked'), 그 외는 renderFallback('network')
|
||||
- 'blocked' 는 회선이 멀쩡하고 새로고침으로도 낫지 않으므로 버튼을 렌더하지 않고,
|
||||
화면 문구는 방문자 기준(서버 설정 지시 없음) · 원인과 조치는 콘솔에 운영자 기준
|
||||
- 코어 엔진 번들에서 정규식 lookbehind 제거(파싱 하한 Safari 16.4 → 14.1)
|
||||
|
||||
axes:
|
||||
entrypoint: [user, admin]
|
||||
failure_mode: [parse_error, network_exhausted, none]
|
||||
failure_mode: [parse_error, network_exhausted, mixed_content_blocked, none]
|
||||
|
||||
effects:
|
||||
- syntax_error_renders_incompatible_notice
|
||||
- incompatible_notice_omits_reload_button
|
||||
- network_failure_renders_network_notice
|
||||
- network_notice_keeps_reload_button
|
||||
- blocked_branch_is_emitted_with_https_http_judgment
|
||||
- mixed_content_blocked_renders_blocked_notice
|
||||
- blocked_notice_omits_reload_button
|
||||
- blocked_notice_splits_visitor_screen_and_operator_console
|
||||
- normal_boot_renders_no_fallback
|
||||
- shipped_core_bundle_has_no_lookbehind
|
||||
- bootstrap_partial_emits_reason_branch
|
||||
@@ -37,6 +44,13 @@ test_files:
|
||||
- resources/js/core/template-engine/__tests__/DataBindingEngine.test.ts
|
||||
|
||||
notes: |
|
||||
`blocked` 축(공개 #124)은 프록시 없이 재현한다 — 문서 HTML 의 코어 스크립트 URL 만
|
||||
`http://` 로 바꾸면 브라우저가 혼합 콘텐츠로 차단하므로, 인증서도 TLS 종단 프록시도
|
||||
필요 없다. 다만 판정이 `location.protocol === 'https:'` 를 보므로, E2E 의 기대값은
|
||||
실행 시점 base URL 의 스킴에서 파생된다(http base 에서는 `network` 가 정답이다).
|
||||
분기 자체의 방출과 문구·대상 분리는 BootstrapFallbackDiagnosisTest 가 스킴과 무관하게
|
||||
단언한다.
|
||||
|
||||
로케일 축은 E2E cross product 에 넣지 않는다 — 화면 문구는 서버가 렌더한 문자열을
|
||||
그대로 심는 구조라 브라우저 경로가 로케일마다 갈리지 않기 때문이다. ko/en/ja 문구의
|
||||
실존과 상호 구분은 BootstrapFallbackDiagnosisTest 가 직접 단언하고, 번들 ja 언어팩의
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# audit:allow test-scenario-coverage reason: 본 매니페스트는 신규 기능 시나리오 매트릭스 SSoT 로 기록. 축 곱(6×3×3×3×2×2 = 648)이 커 전 조합 docblock 매핑은 비현실적이며, 핵심 회귀 가드는 test_files 의 통과 테스트로 커버.
|
||||
|
||||
feature: 리버스 프록시 신뢰 설정 (Trusted Proxy)
|
||||
|
||||
description: |
|
||||
TLS 가 앞단에서 종단되고 앱에는 HTTP 로 전달되는 구성(AWS ALB, CloudFront, Cloudflare,
|
||||
nginx/Apache 리버스 프록시, ngrok)에서 요청 객체가 접속 주소와 방문자 IP 를 올바르게
|
||||
인식하도록 신뢰할 프록시를 지정한다 (공개 #124).
|
||||
|
||||
배경:
|
||||
- 코어에 신뢰 프록시 설정이 전혀 없어, Laravel 내장 TrustProxies 미들웨어가
|
||||
X-Forwarded-* 를 전부 무시했다. 그 결과 요청이 평문 HTTP 로 인식되어
|
||||
asset()/url() 이 http:// 절대 URL 을 만들고, HTTPS 페이지에서 혼합 콘텐츠로
|
||||
차단되어 사이트 전체가 백지가 되었다.
|
||||
- 같은 원인에서 통보 IP 화이트리스트 403, 로그인 시도 제한 붕괴, IP 기록 왜곡,
|
||||
쿠키 Secure 누락, SEO canonical 다운그레이드, GeoIP 오판정이 함께 갈라진다.
|
||||
|
||||
조치:
|
||||
- config/trustedproxy.php 1개 (`'proxies' => env('TRUSTED_PROXIES')`).
|
||||
코어 PHP 코드 수정 0줄 — 내장 미들웨어가 요청 시점에 이 키를 폴백으로 읽는다.
|
||||
- bootstrap/app.php 는 건드리지 않는다. withMiddleware 클로저는 .env 로드 전에
|
||||
평가되어 env() 가 항상 null 이므로 그 경로는 조용한 no-op 이 된다.
|
||||
- 미설정이 기본값이므로 기존 설치처 동작은 바뀌지 않는다(opt-in).
|
||||
|
||||
진단 (읽기 전용, 4면):
|
||||
- 판정식은 "HTTPS 인식 실패" 가 아니라
|
||||
`X-Forwarded-* 수신 중 AND 신뢰 프록시 미설정` 이다. HTTP 전용 사이트가 프록시
|
||||
뒤에 있으면 화면은 완전히 정상 렌더되면서 나머지 파손만 조용히 계속되기 때문이다.
|
||||
- 판정은 App\Support\TrustedProxyDiagnostic 한 곳에서만 계산하고
|
||||
대시보드 알림 · 환경설정 고급 탭 · 설치 마법사 · Artisan 커맨드가 소비한다.
|
||||
- 값 편집 UI 는 두지 않는다 — 잠금 역설(프록시 뒤에서는 그 화면 자체가 뜨지 않는다)
|
||||
과 권한 승격(관리자 계정 탈취가 곧 XFF 위조 경로)이 이유다.
|
||||
|
||||
axes:
|
||||
proxies_setting: [unset, star, double_star, single_ip_match, single_ip_mismatch, cidr]
|
||||
forwarded_proto: [https, http, absent]
|
||||
forwarded_for: [single, chain, absent]
|
||||
forwarded_host: [same, different, absent]
|
||||
forwarded_port: [nonstandard, absent]
|
||||
session_secure_cookie: [unset, true]
|
||||
|
||||
exclusions:
|
||||
- { proxies_setting: unset, forwarded_proto: https, reason: "미설정은 헤더를 전부 무시 — 헤더 조합이 결과를 바꾸지 않는다" }
|
||||
- { proxies_setting: unset, forwarded_proto: http, reason: "동일 사유" }
|
||||
- { proxies_setting: unset, forwarded_for: chain, reason: "동일 사유" }
|
||||
- { proxies_setting: unset, forwarded_host: different, reason: "동일 사유" }
|
||||
- { proxies_setting: unset, forwarded_port: nonstandard, reason: "동일 사유" }
|
||||
- { proxies_setting: single_ip_mismatch, forwarded_proto: https, reason: "목록 불일치는 미설정과 동일 경로 — 헤더 조합이 결과를 바꾸지 않는다" }
|
||||
- { proxies_setting: single_ip_mismatch, forwarded_for: chain, reason: "동일 사유" }
|
||||
- { proxies_setting: single_ip_mismatch, forwarded_host: different, reason: "동일 사유" }
|
||||
- { forwarded_proto: absent, session_secure_cookie: unset, reason: "스킴 헤더가 없으면 쿠키 Secure 자동 판정 축이 성립하지 않는다" }
|
||||
- { session_secure_cookie: true, forwarded_proto: http, reason: "명시 설정은 스킴 판정을 우회하므로 조합이 무의미하다" }
|
||||
- { session_secure_cookie: true, forwarded_proto: absent, reason: "동일 사유" }
|
||||
|
||||
effects:
|
||||
- unset_ignores_forwarded_headers
|
||||
- star_restores_scheme_ip_and_root
|
||||
- double_star_behaves_like_star
|
||||
- chain_requires_listing_every_hop
|
||||
- ip_list_match_trusts_and_mismatch_rejects
|
||||
- cidr_notation_is_honored
|
||||
- config_file_exposes_proxies_key_from_env
|
||||
- bootstrap_does_not_reintroduce_env_trust_proxies
|
||||
- env_examples_document_trusted_proxies
|
||||
- installer_header_list_matches_core_diagnostic
|
||||
- cookie_secure_follows_trusted_scheme
|
||||
- direct_exposure_is_not_a_warning
|
||||
- forwarded_without_config_is_warning
|
||||
- http_only_behind_proxy_still_warns
|
||||
- configured_proxy_is_ok
|
||||
- empty_string_counts_as_unset
|
||||
- console_context_is_not_applicable
|
||||
- dashboard_alert_only_on_warning_with_warning_type
|
||||
- diagnostic_endpoint_is_read_only
|
||||
|
||||
test_files:
|
||||
- tests/Feature/Http/TrustedProxyContractTest.php
|
||||
- tests/Feature/Http/TrustedProxyDiagnosticTest.php
|
||||
|
||||
notes: |
|
||||
`**` 는 Laravel 내장 TrustProxies 에서 `*` 과 **같은 코드 경로**를 탄다
|
||||
(`setTrustedProxyIpAddressesToTheCallingIp`). 별도 패키지 시절의 "모든 프록시 신뢰"
|
||||
의미가 아니므로, 다단계 체인에서는 둘 다 마지막 프록시를 방문자로 본다. 실측으로
|
||||
확인했고 `double_star_behaves_like_star` 가 그 사실을 계약으로 잠근다 — 프레임워크
|
||||
업그레이드로 의미가 갈라지면 문서·설정 주석과 함께 갱신해야 한다.
|
||||
|
||||
프록시를 실제로 경유하는 브라우저 축(혼합 콘텐츠 차단 → 화면 백지)은 이 매니페스트
|
||||
범위 밖이다. Playwright 에 TLS 종단 프록시 픽스처를 두면 인증서·포트·globalSetup 이
|
||||
기존 E2E 의 단일 origin 전제를 깨뜨리므로, 그 축은 Chrome MCP 수동 매트릭스가 덮는다.
|
||||
부팅 안내의 `blocked` 분기는 프록시 없이 재현 가능하므로
|
||||
`tests/scenarios/bootstrap-parse-failure.yaml` 이 별도로 다룬다.
|
||||
|
||||
이미 발송된 서명 URL 무효화 · 과거 적재 IP · SEO 캐시/사이트맵 재생성은 설정을 켜도
|
||||
자동으로 낫지 않는 1회성 후속 조치다. 코드가 아니라 운영 절차이므로 축에 넣지 않고
|
||||
docs/backend/reverse-proxy.md 가 문서로 고정한다.
|
||||
Reference in new issue
Block a user