printshopcreator/src/new/config/packages/security.php
2025-02-07 22:04:13 +01:00

171 lines
6.8 KiB
PHP
Executable File

<?php
declare(strict_types=1);
use PSC\Shop\EntityBundle\Document\Instance;
use PSC\Shop\EntityBundle\Entity\Contact;
use PSC\Shop\EntityBundle\Entity\Shop;
use PSC\Shop\UserBundle\Model\ApiUser;
use PSC\Shop\UserBundle\Security\ApiKeyAuthenticator;
use PSC\Shop\UserBundle\Security\ApiKeyExtractor;
use PSC\Shop\UserBundle\Security\ApiKeyHandler;
use PSC\Shop\UserBundle\Security\ApiKey\ApiKeyProvider;
use PSC\Shop\UserBundle\Security\ApiKey\InstanceProvider;
use PSC\Shop\UserBundle\Security\ApiKey\ShopProvider;
use PSC\Shop\UserBundle\Security\User\UserProvider;
use PSC\Shop\UserBundle\Security\ZendAuthenticator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension(
'security',
[
'password_hashers' =>
[
Contact::class =>
['algorithm' => 'auto']
],
'role_hierarchy' =>
[
'ROLE_SHOP' => 'ROLE_USER',
'ROLE_PRODUCT_EDITOR' => ['ROLE_SHOP'],
'ROLE_SHOP_OPERATOR' => [
'ROLE_SHOP',
'ROLE_PRODUCTION',
'ROLE_PRODUCT_EDITOR'
],
'ROLE_SHOP_ADMIN' => [
'ROLE_SHOP',
'ROLE_SHOP_OPERATOR'
],
'ROLE_ADMIN' => [
'ROLE_SHOP',
'ROLE_SHOP_OPERATOR',
'ROLE_SHOP_ADMIN'
],
'ROLE_WAREHOUSE' => [
'ROLE_USER',
'ROLE_ADMIN'
],
'ROLE_PRODUCTION' => [
'ROLE_USER',
'ROLE_ADMIN',
'ROLE_WAREHOUSE'
],
'ROLE_SUPER_SHOP' => [
'ROLE_USER',
'ROLE_SHOP',
'ROLE_ADMIN',
'ROLE_PRODUCTION',
'ROLE_WAREHOUSE'
],
'ROLE_SUPER_ADMIN' => [
'ROLE_USER',
'ROLE_SHOP',
'ROLE_ADMIN',
'ROLE_WAREHOUSE',
'ROLE_PRODUCTION',
'ROLE_SUPER_SHOP',
'ROLE_ALLOWED_TO_SWITCH'
],
'ROLE_API' => [
'ROLE_SHOP'
]
],
'providers' => [
//'database' => ['entity' => ['class' => Contact::class]],
'user_provider' => ['id' => UserProvider::class ],
'shop_provider' => ['id' => ShopProvider::class ],
'instance_provider' => ['id' => InstanceProvider::class ],
'all' => [
'chain' =>
[
'providers' =>
['user_provider', 'shop_provider', 'instance_provider']
]
]
// 'database_token' => ['entity' => ['class' => Shop::class]],
// 'database_api_key' => ['entity' => ['class' => Instance::class]],
],
'firewalls' => [
'admin_secured_area' => [
'pattern' => '^/backend',
'provider' => 'user_provider',
'form_login' => [
'check_path' => 'psc_backend_login',
'login_path' => 'psc_backend_login',
'enable_csrf' => true,
'default_target_path' => 'psc_backend_dashboard_index',
'username_parameter' => 'username',
'password_parameter' => 'password'
],
'logout' => [
'path' => 'psc_backend_logout',
'target' => 'psc_backend_login'
]
],
'api_login' => [
'pattern' => '/api/login',
'stateless' => false,
'provider' => 'all',
'json_login' => [
'check_path' => '/api/login_check',
'success_handler' => 'lexik_jwt_authentication.handler.authentication_success',
'failure_handler' => 'lexik_jwt_authentication.handler.authentication_failure'
]
],
'api' => [
'pattern' => '^/api',
'stateless' => false,
'provider' => 'all',
'jwt' => null,
'access_token' => [
'token_handler' => ApiKeyHandler::class,
'token_extractors' => ApiKeyExtractor::class
],
'custom_authenticators' => [
ApiKeyAuthenticator::class,
ZendAuthenticator::class,
]
],
'storefront' => [
'pattern' => '^/',
'provider' => 'user_provider',
'stateless' => false,
'jwt' => null,
'custom_authenticators' => [
ApiKeyAuthenticator::class,
ZendAuthenticator::class,
]
]
],
'access_control' => [
[
'path' => '^/production',
'roles' => 'ROLE_SHOP'
],
[
'path' => '^/backend/login',
'roles' => 'PUBLIC_ACCESS'
],
[
'path' => '^/backend/order/detail/package/printpartner',
'roles' => 'PUBLIC_ACCESS'
],
[
'path' => '^/backend/order/detail/package/download',
'roles' => 'PUBLIC_ACCESS'
],
[
'path' => '^/backend',
'roles' => 'ROLE_SHOP'
],
[
'path' => '^/',
'roles' => 'PUBLIC_ACCESS'
]
]
]
);
};