From ce4a61e0ce103694ac0072be0759f378b6390dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=98=81=EB=B3=B4?= Date: Fri, 20 Mar 2026 08:34:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[auth]=20Swagger=20publicRoutes=20+=20Fi?= =?UTF-8?q?le=20=EB=AA=A8=EB=8D=B8=20=EB=84=A4=EC=9E=84=EC=8A=A4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - publicRoutes에 api/documentation/* 추가 (Swagger UI 공개 접근) - web.php /files/{id}/view: App\Models\File → App\Models\Commons\File --- app/Http/Middleware/ApiKeyMiddleware.php | 18 ++++++++++-------- public/api-docs/index.html | 2 +- routes/web.php | 11 ++++++++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/Http/Middleware/ApiKeyMiddleware.php b/app/Http/Middleware/ApiKeyMiddleware.php index 666b89fc..707ce3ce 100644 --- a/app/Http/Middleware/ApiKeyMiddleware.php +++ b/app/Http/Middleware/ApiKeyMiddleware.php @@ -16,18 +16,20 @@ public function handle(Request $request, Closure $next) { // 화이트리스트(인증 예외 라우트) - API Key 검증 제외 $publicRoutes = [ - '/', // Root (Swagger redirect) + '/', // Root (Swagger redirect) 'api/v1/signup', 'api/v1/register', 'api/v1/refresh', 'api/v1/debug-apikey', - 'api/v1/internal/*', // 내부 서버간 통신 (HMAC 인증 사용) - 'api-docs', // Swagger UI - 'api-docs/*', // Swagger 하위 경로 - 'docs', // L5-Swagger UI - 'docs/*', // L5-Swagger 하위 경로 (에셋 등) - 'docs/api-docs.json', // Swagger JSON - 'up', // Health check + 'api/v1/internal/*', // 내부 서버간 통신 (HMAC 인증 사용) + 'api-docs', // Swagger UI (정적) + 'api-docs/*', // Swagger 하위 경로 + 'docs', // L5-Swagger UI + 'docs/*', // L5-Swagger 하위 경로 (에셋 등) + 'docs/api-docs.json', // Swagger JSON (기본) + 'docs/api-docs-v1.json', // Swagger JSON (v1) + 'api/documentation/*', // L5-Swagger v1 문서 + 'up', // Health check ]; $currentRoute = $request->route()?->uri() ?? $request->path(); diff --git a/public/api-docs/index.html b/public/api-docs/index.html index e819a6b4..2f0edf20 100644 --- a/public/api-docs/index.html +++ b/public/api-docs/index.html @@ -7,7 +7,7 @@ where('path', '.*'); +// Swagger v1 JSON (api-docs-v1.json 직접 제공) +Route::get('/docs/api-docs-v1.json', function () { + $path = storage_path('api-docs/api-docs-v1.json'); + if (! file_exists($path)) { + abort(404); + } + return response()->file($path, ['Content-Type' => 'application/json']); +}); + // R2 파일 프록시 (file_id 기반, 인증 불필요, 캐시 1일) Route::get('/files/{id}/view', function (int $id) { - $file = \App\Models\File::find($id); + $file = \App\Models\Commons\File::find($id); if (! $file || ! $file->file_path) { abort(404); }