fix(core,admin_basic): S3 스토리지 드라이버 실동작 결함 수정 및 S3 호환 스토리지 연결 지원

공개 제보 — 파일 스토리지에서 S3 를 선택해 저장해도 실제 파일 저장이
동작하지 않던 결함의 전면 수정.

- S3 어댑터(league/flysystem-aws-s3-v3)·predis 를 코어 기본 의존성으로 포함
 — 어댑터 부재 즉사, phpredis 확장 없는 서버의 redis 선택 전면 다운 차단
 (부트 시 확장 부재 감지 → predis 자동 폴백)
- storage_driver=s3 저장 시 코어 첨부 업로드 디스크를 s3 로 전환
 (ATTACHMENT_DISK env 명시가 항상 우선, 기존 행은 저장 당시 disk 로 서빙)
- 첨부·템플릿 레이아웃 첨부 서빙을 행 disk 를 따르는 스토리지 스트림으로 교체
 — 로컬 절대 경로 전제 fileResponse 는 S3 행에서 filemtime stat 500
 (streamedFileResponse: 행 메타 기반 ETag/304/Cache-Control)
- S3 호환 스토리지(R2/MinIO/NCP) 연결 지원: 엔드포인트 URL·path-style 설정
 신설, 리전 목록 선택 → 자유 입력 전환, 연결 테스트를 실제 저장 경로와
 동일 설정(endpoint/path-style)으로 정렬
- 사용 불능 드라이버(어댑터·PHP 확장 부재)의 저장/테스트 요청을 사유와 함께
 422 로 차단하는 서버 게이트 신설 (DriverRegistryService 능력 판정)
- 웹소켓 연결 테스트에 서버(백엔드 발송용) endpoint 검사 추가 — 클라이언트만
 검사해 테스트 성공 + 실제 발송 실패가 가능하던 비대칭 해소
- env 빈 값(`KEY=`) 함정 정규화: AWS_URL/AWS_ENDPOINT/ATTACHMENT_DISK 빈 문자열을
 미설정으로 취급 (config 정규화 + 예시 파일 주석 처리)
- 플러그인 드라이버 폴백의 log 카테고리 죽은 키(logging.default) 정정 및
 websocket 유령 설정 키 제거
- 실 AWS S3 종단 검증 완료 (설정 저장 → 업로드 S3 실저장 → 서빙 200/304)
This commit is contained in:
HeuJung committed 2026-08-13 15:15:19 +09:00
1 parent c128a6ea3a
commit ea58c606a2
56 files changed
+2899 -243

No files matched your search

+70 -9
View File
@@ -8,6 +8,7 @@ use Aws\S3\S3Client;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use Predis\Client;
/**
@@ -101,9 +102,19 @@ class DriverConnectionTester
];
}
// Flysystem S3 어댑터 존재 선검사 — 테스트는 SDK 직접 경로지만 실제 파일 I/O 는
// Storage::disk('s3') → 어댑터를 경유하므로, 어댑터가 없으면 테스트가 성공해도
// 실경로가 즉사한다 (#99 의 결함 은폐 구조). sdk_missing 검사와 대칭.
if (! class_exists(AwsS3V3Adapter::class)) {
return [
'success' => false,
'message' => __('settings.s3_adapter_missing'),
];
}
$startTime = microtime(true);
$client = new S3Client([
$clientOptions = [
'version' => 'latest',
'region' => $region,
'credentials' => [
@@ -114,7 +125,18 @@ class DriverConnectionTester
'timeout' => 5,
'connect_timeout' => 3,
],
]);
];
// S3 호환 스토리지(R2/MinIO 등) — 실경로(applyS3Config 주입)와 동일하게
// endpoint/path-style 을 반영해야 테스트가 실제 연결 대상과 일치한다.
if (! empty($config['s3_endpoint'])) {
$clientOptions['endpoint'] = $config['s3_endpoint'];
}
if (! empty($config['s3_use_path_style'])) {
$clientOptions['use_path_style_endpoint'] = true;
}
$client = new S3Client($clientOptions);
// 버킷 존재 확인
$client->headBucket(['Bucket' => $bucket]);
@@ -372,15 +394,53 @@ class DriverConnectionTester
* @return array 테스트 결과
*/
public function testWebsocket(array $config): array
{
$clientHost = $config['websocket_host'] ?? 'localhost';
$clientPort = (int) ($config['websocket_port'] ?? 8080);
$clientScheme = $config['websocket_scheme'] ?? 'https';
// 서버(백엔드 broadcast HTTP API) endpoint — 빈 값은 클라이언트 값으로 폴백한다
// (SettingsServiceProvider::applyWebsocketConfig 와 동일 규칙). 백엔드 송신은
// server endpoint 를 쓰므로 client 만 검사하면 "테스트 성공 + 실제 발송 실패" 가 된다.
$serverHost = ($config['websocket_server_host'] ?? '') !== '' ? $config['websocket_server_host'] : $clientHost;
$serverPort = (int) ($config['websocket_server_port'] ?? 0) > 0 ? (int) $config['websocket_server_port'] : $clientPort;
$serverScheme = ($config['websocket_server_scheme'] ?? '') !== '' ? $config['websocket_server_scheme'] : $clientScheme;
$clientUrl = sprintf('%s://%s:%d', $clientScheme, $clientHost, $clientPort);
$serverUrl = sprintf('%s://%s:%d', $serverScheme, $serverHost, $serverPort);
// 클라이언트 endpoint 검사
$clientResult = $this->probeWebsocketEndpoint($clientUrl);
if (! $clientResult['success']) {
return $clientResult;
}
// 서버 endpoint 검사 (클라이언트와 동일 주소면 중복 요청 생략)
if ($serverUrl !== $clientUrl) {
$serverResult = $this->probeWebsocketEndpoint($serverUrl);
if (! $serverResult['success']) {
return [
'success' => false,
'message' => __('settings.websocket_server_test_failed'),
'error' => $serverResult['error'] ?? ($serverResult['message'] ?? ''),
];
}
}
return $clientResult;
}
/**
* Websocket(Reverb) HTTP endpoint 하나를 probe 합니다.
*
* @param string $url 검사할 endpoint URL
* @return array 테스트 결과
*/
private function probeWebsocketEndpoint(string $url): array
{
try {
$host = $config['websocket_host'] ?? 'localhost';
$port = (int) ($config['websocket_port'] ?? 8080);
$scheme = $config['websocket_scheme'] ?? 'https';
// Reverb 서버 상태 확인 (기본 HTTP 엔드포인트)
$url = sprintf('%s://%s:%d', $scheme, $host, $port);
// Reverb 는 통상 localhost·사내 IP 에서 동작하므로 사설 주소 자체는 정상 구성이다.
// 다만 이 진단 요청을 임의 목적지 탐색에 전용하지 못하도록, 정상 설정에서는 나올 수
// 없는 값(userinfo 위장, http/https 이외 scheme, 제어문자 주입)은 거부한다.
@@ -426,6 +486,7 @@ class DriverConnectionTester
];
} catch (\Exception $e) {
Log::warning('Websocket connection test failed', [
'url' => $url,
'error' => $e->getMessage(),
]);