2025-07-17 10:05:47 +09:00
|
|
|
<?php
|
|
|
|
|
|
2025-07-24 17:55:20 +09:00
|
|
|
use App\Exceptions\Handler;
|
2025-07-17 10:05:47 +09:00
|
|
|
use App\Http\Middleware\ApiKeyMiddleware;
|
2025-11-13 20:30:34 +09:00
|
|
|
use App\Http\Middleware\ApiRateLimiter;
|
feat: API 라우터 분리 및 버전 폴백 시스템 구현
- api.php를 13개 도메인별 파일로 분리 (1,479줄 → 61줄)
- ApiVersionMiddleware 생성 (헤더/쿼리 기반 버전 선택)
- v2 요청 시 v2 없으면 v1으로 자동 폴백
- 지원 헤더: Accept-Version, X-API-Version, api_version 쿼리
분리된 도메인:
auth, admin, users, tenants, hr, finance, sales,
inventory, production, design, files, boards, common
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:30:19 +09:00
|
|
|
use App\Http\Middleware\ApiVersionMiddleware;
|
2025-11-06 17:45:49 +09:00
|
|
|
use App\Http\Middleware\CheckPermission;
|
2025-07-17 10:05:47 +09:00
|
|
|
use App\Http\Middleware\CheckSwaggerAuth;
|
2025-11-06 17:45:49 +09:00
|
|
|
use App\Http\Middleware\CorsMiddleware;
|
2025-12-15 15:16:38 +09:00
|
|
|
use App\Http\Middleware\LogApiRequest;
|
2025-08-16 03:25:06 +09:00
|
|
|
use App\Http\Middleware\PermMapper;
|
feat:DB 트리거 기반 데이터 변경 추적 시스템 구현
Phase 1: DB 기반 구축
- trigger_audit_logs 테이블 (RANGE 파티셔닝 15개, 3개 인덱스)
- 789개 MySQL AFTER 트리거 (263 테이블 × INSERT/UPDATE/DELETE)
- SetAuditSessionVariables 미들웨어 (@sam_actor_id, @sam_session_info)
Phase 2: 복구 메커니즘
- TriggerAuditLog 모델, TriggerAuditLogService, AuditRollbackService
- 6개 API 엔드포인트 (index, show, stats, history, rollback-preview, rollback)
- FormRequest 검증 (TriggerAuditLogIndexRequest, TriggerAuditRollbackRequest)
Phase 3: 관리 도구
- v_unified_audit VIEW (APP + TRIGGER 통합, COLLATE 처리)
- audit:partitions 커맨드 (파티션 추가/삭제, dry-run)
- audit:triggers 커맨드 (트리거 재생성, 테이블별/전체)
- 월 1회 파티션 자동 관리 스케줄러 등록
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:17:15 +09:00
|
|
|
use App\Http\Middleware\SetAuditSessionVariables;
|
2025-11-06 17:45:49 +09:00
|
|
|
use Illuminate\Contracts\Debug\ExceptionHandler;
|
|
|
|
|
use Illuminate\Foundation\Application;
|
|
|
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
|
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
2025-07-17 10:05:47 +09:00
|
|
|
|
2025-07-24 17:55:20 +09:00
|
|
|
$app = Application::configure(basePath: dirname(__DIR__))
|
2025-07-17 10:05:47 +09:00
|
|
|
->withRouting(
|
|
|
|
|
web: __DIR__.'/../routes/web.php',
|
|
|
|
|
api: __DIR__.'/../routes/api.php',
|
|
|
|
|
commands: __DIR__.'/../routes/console.php',
|
|
|
|
|
health: '/up',
|
|
|
|
|
)
|
|
|
|
|
->withMiddleware(function (Middleware $middleware) {
|
2025-11-13 20:30:34 +09:00
|
|
|
// 글로벌 미들웨어 (모든 요청에 적용, 순서 중요)
|
2025-07-17 10:05:47 +09:00
|
|
|
$middleware->append(CorsMiddleware::class);
|
feat: API 라우터 분리 및 버전 폴백 시스템 구현
- api.php를 13개 도메인별 파일로 분리 (1,479줄 → 61줄)
- ApiVersionMiddleware 생성 (헤더/쿼리 기반 버전 선택)
- v2 요청 시 v2 없으면 v1으로 자동 폴백
- 지원 헤더: Accept-Version, X-API-Version, api_version 쿼리
분리된 도메인:
auth, admin, users, tenants, hr, finance, sales,
inventory, production, design, files, boards, common
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:30:19 +09:00
|
|
|
$middleware->append(ApiRateLimiter::class); // 1. Rate Limiting 먼저 체크
|
|
|
|
|
$middleware->append(ApiKeyMiddleware::class); // 2. API Key 검증
|
|
|
|
|
$middleware->append(ApiVersionMiddleware::class); // 3. API 버전 해석 및 폴백
|
2025-07-17 10:05:47 +09:00
|
|
|
|
feat:DB 트리거 기반 데이터 변경 추적 시스템 구현
Phase 1: DB 기반 구축
- trigger_audit_logs 테이블 (RANGE 파티셔닝 15개, 3개 인덱스)
- 789개 MySQL AFTER 트리거 (263 테이블 × INSERT/UPDATE/DELETE)
- SetAuditSessionVariables 미들웨어 (@sam_actor_id, @sam_session_info)
Phase 2: 복구 메커니즘
- TriggerAuditLog 모델, TriggerAuditLogService, AuditRollbackService
- 6개 API 엔드포인트 (index, show, stats, history, rollback-preview, rollback)
- FormRequest 검증 (TriggerAuditLogIndexRequest, TriggerAuditRollbackRequest)
Phase 3: 관리 도구
- v_unified_audit VIEW (APP + TRIGGER 통합, COLLATE 처리)
- audit:partitions 커맨드 (파티션 추가/삭제, dry-run)
- audit:triggers 커맨드 (트리거 재생성, 테이블별/전체)
- 월 1회 파티션 자동 관리 스케줄러 등록
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:17:15 +09:00
|
|
|
// API 미들웨어 그룹에 로깅 + 감사 세션변수 추가
|
2025-12-15 15:16:38 +09:00
|
|
|
$middleware->appendToGroup('api', LogApiRequest::class);
|
feat:DB 트리거 기반 데이터 변경 추적 시스템 구현
Phase 1: DB 기반 구축
- trigger_audit_logs 테이블 (RANGE 파티셔닝 15개, 3개 인덱스)
- 789개 MySQL AFTER 트리거 (263 테이블 × INSERT/UPDATE/DELETE)
- SetAuditSessionVariables 미들웨어 (@sam_actor_id, @sam_session_info)
Phase 2: 복구 메커니즘
- TriggerAuditLog 모델, TriggerAuditLogService, AuditRollbackService
- 6개 API 엔드포인트 (index, show, stats, history, rollback-preview, rollback)
- FormRequest 검증 (TriggerAuditLogIndexRequest, TriggerAuditRollbackRequest)
Phase 3: 관리 도구
- v_unified_audit VIEW (APP + TRIGGER 통합, COLLATE 처리)
- audit:partitions 커맨드 (파티션 추가/삭제, dry-run)
- audit:triggers 커맨드 (트리거 재생성, 테이블별/전체)
- 월 1회 파티션 자동 관리 스케줄러 등록
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:17:15 +09:00
|
|
|
$middleware->appendToGroup('api', SetAuditSessionVariables::class);
|
2025-12-15 15:16:38 +09:00
|
|
|
|
2025-07-17 10:05:47 +09:00
|
|
|
$middleware->alias([
|
feat: API 라우터 분리 및 버전 폴백 시스템 구현
- api.php를 13개 도메인별 파일로 분리 (1,479줄 → 61줄)
- ApiVersionMiddleware 생성 (헤더/쿼리 기반 버전 선택)
- v2 요청 시 v2 없으면 v1으로 자동 폴백
- 지원 헤더: Accept-Version, X-API-Version, api_version 쿼리
분리된 도메인:
auth, admin, users, tenants, hr, finance, sales,
inventory, production, design, files, boards, common
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:30:19 +09:00
|
|
|
'auth.apikey' => ApiKeyMiddleware::class, // 인증: apikey + basic auth (alias 유지)
|
|
|
|
|
'api.version' => ApiVersionMiddleware::class, // API 버전 해석 및 폴백
|
2025-07-24 17:55:20 +09:00
|
|
|
'swagger.auth' => CheckSwaggerAuth::class,
|
2025-11-06 17:45:49 +09:00
|
|
|
'perm.map' => PermMapper::class, // 전처리: 라우트명 → perm 키 생성/주입
|
2025-08-16 03:25:06 +09:00
|
|
|
'permission' => CheckPermission::class, // 검사: perm 키로 접근 허용/차단
|
2025-12-15 15:16:38 +09:00
|
|
|
'log.api' => LogApiRequest::class, // API 요청/응답 로깅 (선택적 사용용)
|
2025-07-17 10:05:47 +09:00
|
|
|
]);
|
|
|
|
|
})
|
|
|
|
|
->withExceptions(function (Exceptions $exceptions) {
|
2025-07-24 17:55:20 +09:00
|
|
|
// 이건 비워두세요
|
|
|
|
|
})
|
|
|
|
|
->create();
|
|
|
|
|
|
|
|
|
|
// 🔥 핵심: create() 이후에 반드시 등록
|
|
|
|
|
$app->singleton(ExceptionHandler::class, Handler::class);
|
2025-07-17 10:05:47 +09:00
|
|
|
|
2025-07-24 17:55:20 +09:00
|
|
|
return $app;
|