감사 로그
Doggy는 전 구간 시스템 작업 감사 기능을 제공하며, AuditService로 모든 핵심 작업을 기록하여 App\Entity\System\AuditLog에 저장합니다.
개요
감사 로그 시스템은 다음 부분으로 구성됩니다:
AuditLog엔티티(src/Entity/System/AuditLog.php): 로그 영속화AuditService(src/Service/System/AuditService.php): 로그 기록 서비스- 감사 로그 진입점은
App\Controller\Admin\SecurityConfigController
기록 내용
각 감사 로그는 다음을 포함합니다:
action: 작업 유형(login_success,login_failure,create,update,delete)category: 분류(security,business,system)details: 작업 상세(JSON 형식)performer: 작업을 수행한 사용자
사용 방법
php
use App\Service\System\AuditService;
class SomeService
{
public function __construct(private AuditService $auditService) {}
public function doSomething(): void
{
// 로그인 성공
$this->auditService->log('login_success', 'security', [], $user);
// 로그인 실패
$this->auditService->log('login_failure', 'security', [
'username' => $email,
'error' => $exception->getMessage(),
]);
// 데이터 작업
$this->auditService->log('update', 'business', [
'entity' => Employee::class,
'id' => $employee->getId(),
'changes' => $changes,
]);
}
}통합
감사 로그는 주요 보안 흐름에 자동으로 통합되었습니다:
로그인 인증
App\Security\AppCustomAuthenticator가 자동 기록:
php
// 로그인 성공 시
$this->auditService->log('login_success', 'security', [], $user);
// 로그인 실패 시
$this->auditService->log('login_failure', 'security', [
'username' => $email,
'error' => $exception->getMessage(),
]);보안 요구사항
- 감사 로그는 감사자만 열람 가능(
ROLE_AUDITOR,ThreeOfficersVoter의AUDIT_VIEW권한) - 로그는 데이터베이스에 저장되어 추적 및 내보내기 지원
- 시간 범위, 사용자, 작업 유형으로 검색 지원