<?php declare(strict_types=1);

return \Symfony\Component\DependencyInjection\Loader\Configurator\App::config([
    'security' => [
        'password_hashers' => [
            \Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface::class => [
                'algorithm' => 'bcrypt',
            ],
        ],
        'providers' => [
            'app_admin_user_provider' => [
                'entity' => [
                    'class' => \App\Engine\AdministratorUser\AdministratorUser::class,
                    'property' => 'email',
                ],
            ],
        ],
        'firewalls' => [
            'dev' => [
                'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
                'security' => false,
            ],
            'api_file_manager' => [
                'pattern' => '^/api/v3/file-manager',
                'entry_point' => \App\Engine\Admin\Auth\ApiEntryPoint::class,
                'lazy' => true,
                'form_login' => false,
                'context' => 'admin'
            ],
            'admin' => [
                'pattern' => '^/admin',
                'webauthn' => [
                    'registration' => [
                        'enabled' => true,
                        'profile' => 'default',
                        'routes' => [
                            'options_path' => '/admin/webauthn/register/options',
                            'result_path' => '/admin/webauthn/register',
                        ],
                    ],
                    'authentication' => [
                        'enabled' => true,
                        'profile' => 'default',
                        'routes' => [
                            'options_path' => '/admin/webauthn/auth/options',
                            'result_path' => '/admin/webauthn/auth',
                        ],
                    ],
                ],
                'form_login' => [
                    'provider' => 'app_admin_user_provider',
                    'login_path' => 'AdminLogin',
                    'check_path' => 'AdminLogin',
                    'default_target_path' => 'AdminDashboard',
                ],
                'context' => 'admin'
            ],
            'main' => [
                'lazy' => true,
            ],
        ],
        'access_control' => [
            [
                'path' => '^/api/v3/file-manager',
                'roles' => [\App\Engine\Security\Role::ADMINISTRATOR->value],
            ],
            [
                'path' => '^/admin/login',
                'roles' => [\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS],
            ],
            [
                'path' => '^/admin/webauthn',
                'roles' => [\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS],
            ],
            [
                'path' => '^/admin',
                'roles' => [\App\Engine\Security\Role::ADMINISTRATOR->value],
            ],
        ],
        'role_hierarchy' => [
            \App\Engine\Security\Role::USER->value => [\App\Engine\Security\Role::GUEST->value],
            \App\Engine\Security\Role::ADMINISTRATOR->value => [\App\Engine\Security\Role::USER->value],
            \App\Engine\Security\Role::SUPER_ADMINISTRATOR->value => [\App\Engine\Security\Role::ADMINISTRATOR->value],
        ],
    ]
]);
