fix: [auth] Swagger publicRoutes + File 모델 네임스페이스 수정

- publicRoutes에 api/documentation/* 추가 (Swagger UI 공개 접근)
- web.php /files/{id}/view: App\Models\File → App\Models\Commons\File
This commit is contained in:
강영보
2026-03-20 08:34:25 +09:00
parent 786bb20d86
commit ce4a61e0ce
3 changed files with 21 additions and 10 deletions

View File

@@ -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();

View File

@@ -7,7 +7,7 @@
<body>
<rapi-doc
id="doc"
spec-url="/docs?api-docs.json"
spec-url="/docs/api-docs-v1.json"
sort-tags="true"
tag-sorter="alpha"

View File

@@ -38,9 +38,18 @@
]);
})->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);
}