first commit
This commit is contained in:
53
app/Providers/SecurityServiceProvider.php
Normal file
53
app/Providers/SecurityServiceProvider.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\AuthEventSubscriber;
|
||||
use App\Models\PersonalData;
|
||||
use App\Policies\PersonalDataPolicy;
|
||||
use App\Services\Audit\AuditService;
|
||||
use App\Services\Crypto\GostCipher;
|
||||
use App\Services\Crypto\LaravelAesCipher;
|
||||
use App\Services\Crypto\PdnCipher;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
|
||||
/**
|
||||
* Регистрация мер защиты информации (ФСТЭК №21).
|
||||
*
|
||||
* Связывает реализацию криптографического драйвера, сервис аудита, движок MFA,
|
||||
* политики доступа и подписчиков событий аутентификации.
|
||||
*/
|
||||
class SecurityServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
// Драйвер шифрования ПДн (ЗНИ): AES Laravel или ГОСТ-заглушка.
|
||||
$this->app->singleton(PdnCipher::class, function ($app): PdnCipher {
|
||||
$driver = (string) config('security.encryption.driver', 'laravel');
|
||||
|
||||
return match ($driver) {
|
||||
'gost' => new GostCipher([
|
||||
'binary' => config('security.encryption.gost.binary'),
|
||||
'container' => config('security.encryption.gost.container'),
|
||||
]),
|
||||
default => new LaravelAesCipher($app->make(Encrypter::class)),
|
||||
};
|
||||
});
|
||||
|
||||
$this->app->singleton(AuditService::class);
|
||||
$this->app->singleton(Google2FA::class);
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
// Разграничение доступа к объектам ПДн (УПД.2).
|
||||
Gate::policy(PersonalData::class, PersonalDataPolicy::class);
|
||||
|
||||
// Регистрация событий аутентификации в журнале (РСБ.2).
|
||||
Event::subscribe(AuthEventSubscriber::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user