mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-08 13:53:17 +01:00
- Rename the audit actor columns user_type/user_id to actor_type/actor_id - Add owner_organization_id and owner_user_id to the audits table as foreign keys with cascade on delete, so that the audits of an organization or user are deleted together with it. The indexes and foreign keys are created without blocking writes on the large table. - Fill the owner columns for new audits via CustomAuditable. Organizations and users no longer record their own deletion audit, since it would reference the already deleted owner.
206 lines
5.6 KiB
PHP
206 lines
5.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
use App\Extensions\Auditing\Resolvers\CustomIpAddressResolver;
|
|
use OwenIt\Auditing\Models\Audit;
|
|
use OwenIt\Auditing\Resolvers\UrlResolver;
|
|
use OwenIt\Auditing\Resolvers\UserAgentResolver;
|
|
use OwenIt\Auditing\Resolvers\UserResolver;
|
|
|
|
return [
|
|
|
|
'enabled' => env('AUDITING_ENABLED', false),
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Implementation
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Define which Audit model implementation should be used.
|
|
|
|
|
*/
|
|
|
|
'implementation' => Audit::class,
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| User Morph prefix & Guards
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Define the morph prefix and authentication guards for the User resolver.
|
|
|
|
|
*/
|
|
|
|
'user' => [
|
|
'morph_prefix' => 'actor',
|
|
'guards' => [
|
|
'web',
|
|
'api',
|
|
],
|
|
'resolver' => UserResolver::class,
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Resolvers
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Define the IP Address, User Agent and URL resolver implementations.
|
|
|
|
|
*/
|
|
'resolvers' => [
|
|
'ip_address' => CustomIpAddressResolver::class,
|
|
'user_agent' => UserAgentResolver::class,
|
|
'url' => UrlResolver::class,
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Events
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The Eloquent events that trigger an Audit.
|
|
|
|
|
*/
|
|
|
|
'events' => [
|
|
'created',
|
|
'updated',
|
|
'deleted',
|
|
'restored',
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Strict Mode
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Enable the strict mode when auditing?
|
|
|
|
|
*/
|
|
|
|
'strict' => true,
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Global exclude
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Have something you always want to exclude by default? - add it here.
|
|
| Note that this is overwritten (not merged) with local exclude
|
|
|
|
|
*/
|
|
|
|
'exclude' => [],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Empty Values
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Should Audit records be stored when the recorded old_values & new_values
|
|
| are both empty?
|
|
|
|
|
| Some events may be empty on purpose. Use allowed_empty_values to exclude
|
|
| those from the empty values check. For example when auditing
|
|
| model retrieved events which will never have new and old values.
|
|
|
|
|
|
|
|
*/
|
|
|
|
'empty_values' => false,
|
|
'allowed_empty_values' => [
|
|
'retrieved',
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Allowed Array Values
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Should the array values be audited?
|
|
|
|
|
| By default, array values are not allowed. This is to prevent performance
|
|
| issues when storing large amounts of data. You can override this by
|
|
| setting allow_array_values to true.
|
|
*/
|
|
'allowed_array_values' => true,
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Timestamps
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Should the created_at, updated_at and deleted_at timestamps be audited?
|
|
|
|
|
*/
|
|
|
|
'timestamps' => false,
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Threshold
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Specify a threshold for the amount of Audit records a model can have.
|
|
| Zero means no limit.
|
|
|
|
|
*/
|
|
|
|
'threshold' => 0,
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Driver
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The default audit driver used to keep track of changes.
|
|
|
|
|
*/
|
|
|
|
'driver' => 'database',
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Driver Configurations
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Available audit drivers and respective configurations.
|
|
|
|
|
*/
|
|
|
|
'drivers' => [
|
|
'database' => [
|
|
'table' => 'audits',
|
|
'connection' => null,
|
|
],
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Queue Configurations
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Available audit queue configurations.
|
|
|
|
|
*/
|
|
|
|
'queue' => [
|
|
'enable' => false,
|
|
'connection' => 'sync',
|
|
'queue' => 'default',
|
|
'delay' => 0,
|
|
],
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Audit Console
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Whether console events should be audited (eg. php artisan db:seed).
|
|
|
|
|
*/
|
|
|
|
'console' => true,
|
|
];
|