fix : 회원 인증 실패시 401 전송
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\User;
|
||||
@@ -62,6 +63,23 @@ public function handle(Request $request, Closure $next)
|
||||
}
|
||||
}
|
||||
|
||||
// 화이트리스트(인증 예외 라우트)
|
||||
$allowWithoutAuth = [
|
||||
'api/v1/login',
|
||||
'api/v1/debug-apikey',
|
||||
// 추가적으로 허용하고 싶은 라우트
|
||||
];
|
||||
|
||||
// 현재 라우트 확인 (경로 또는 이름)
|
||||
$currentRoute = $request->route()->uri(); // 또는 $request->path()
|
||||
|
||||
if (!in_array($currentRoute, $allowWithoutAuth)) {
|
||||
// 인증정보(api_user, tenant_id) 없으면 튕김
|
||||
if (!app()->bound('api_user') || !app()->bound('tenant_id')) {
|
||||
throw new AuthenticationException('회원정보 또는 테넌트 정보 없음');
|
||||
}
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
// 응답 정보 저장
|
||||
|
||||
Reference in New Issue
Block a user