diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index 07be4d7..93743b6 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -40,9 +40,9 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ 11.0.8 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: 11.0.8 + - pimcore: ~11.0.0 template_tag: v11.0.0 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index 2142fc9..be72917 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -39,9 +39,9 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ 11.0.8 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: 11.0.8 + - pimcore: ~11.0.0 template_tag: v11.0.0 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index 191f049..2263f5d 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -39,9 +39,9 @@ jobs: matrix: php: [ 8.2 ] symfony: [ ^6.2 ] - pimcore: [ 11.0.8 ] + pimcore: [ ~11.0.0 ] include: - - pimcore: 11.0.8 + - pimcore: ~11.0.0 template_tag: v11.0.0 steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 23bd39f..4d7824a 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ Add frontend user authentication and document restriction to pimcore. | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|-----------------------------------|----------------------------|--------------|----------------|----------| -| **4.x** | `10.5 - 10.6` | `5.4` | 22.11.2021 | Feature Branch | master | -| **3.x** | `6.0` - `6.8` | `3.4`, `^4.4` | 21.07.2019 | Feature Branch | 3.x | -| **2.5** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 18.07.2019 | Bugfix only | 2.5 | +| **5.x** | `11.0` | `6.2` | -- | Feature Branch | master | +| **4.x** | `10.5 - 10.6` | `5.4` | 22.11.2021 | Unsupported | 4.x | +| **3.x** | `6.0` - `6.8` | `3.4`, `^4.4` | 21.07.2019 | Unsupported | 3.x | +| **2.5** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 18.07.2019 | Unsupported | 2.5 | | **1.5** | `4.0` | -- | 07.07.2017 | Unsupported | pimcore4 | ## Features @@ -31,11 +32,17 @@ Please read the installation instructions before going deep with Members! ```json "require" : { - "dachcom-digital/members" : "~4.1.0" + "dachcom-digital/members" : "~5.0.0" } ``` -- Execute: `$ bin/console pimcore:bundle:enable MembersBundle` +Add Bundle to `bundles.php`: +```php +return [ + MembersBundle\MembersBundle::class => ['all' => true], +]; +``` + - Execute: `$ bin/console pimcore:bundle:install MembersBundle` ## Upgrading @@ -50,13 +57,9 @@ bin/console members:install:class ### Security Installation It is not possible to merge security configurations from multiple locations, including bundles. Instead, you have to move them to -one single config file, e.g. `config/packages/security.yaml`. Please adopt [security_auth_manager.yaml](./src/MembersBundle/Resources/config/packages/security_auth_manager.yaml) +one single config file, e.g. `config/packages/security.yaml`. Please adopt [security_auth_manager.yaml](./config/packages/security_auth_manager.yaml) and merge your own firewall configuration into one single file. -#### Legacy Security Configuration -⚠️ If you still want to use the legacy authenticator, adopt [security_legacy.yaml](./src/MembersBundle/Resources/config/packages/security_legacy.yaml) -Keep in mind, that this configuration will be removed in Members 5.0. - ### Route Installation MembersBundle does not include any routes per default. Otherwise, it would be hard for you to change or override included routes. diff --git a/UPGRADE.md b/UPGRADE.md index 1145341..60e8e68 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -7,6 +7,10 @@ - [ROUTE] Route include changed from `@MembersBundle/Resources/pimcore/routing/all.yml` to `@MembersBundle/config/pimcore/routing/all.yaml` - All template folder are lowercase/underscore now (`templates/change_password`, `templates/delete_account`) +### Deprecations +- Constant `MembersBundle\Security\RestrictionUri::PROTECTED_ASSET_FOLDER` has been removed +- Constant `MembersBundle\Security\RestrictionUri::MEMBERS_REQUEST_URL` has been removed + *** Members 4.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-members/blob/4.x/UPGRADE.md diff --git a/composer.json b/composer.json index c1572eb..160c7cd 100755 --- a/composer.json +++ b/composer.json @@ -42,6 +42,9 @@ "phpstan/phpstan-symfony": "^1.0", "symplify/easy-coding-standard": "^9.0" }, + "conflict": { + "league/csv": "9.11.0" + }, "suggest": { "knpuniversity/oauth2-client-bundle": "^2.0" } diff --git a/config/packages/security_auth_manager.yaml b/config/packages/security_auth_manager.yaml index 67ae103..b5b16f0 100644 --- a/config/packages/security_auth_manager.yaml +++ b/config/packages/security_auth_manager.yaml @@ -1,7 +1,5 @@ security: - enable_authenticator_manager: true - # symfony default is set to "true". # you may want to keep it "true" but keep in mind that this hide meaningful exceptions like "acount is disabled" # instead the BadCredentialsException will be thrown diff --git a/config/packages/security_legacy.yaml b/config/packages/security_legacy.yaml deleted file mode 100644 index 12d9f24..0000000 --- a/config/packages/security_legacy.yaml +++ /dev/null @@ -1,38 +0,0 @@ -security: - # symfony default is set to "true". - # you may want to keep it "true" but keep in mind that this hide meaningful exceptions like "acount is disabled" - # instead the BadCredentialsException will be thrown - hide_user_not_found: false - - providers: - - # [...] other providers - - members: - id: MembersBundle\Security\UserProvider - - firewalls: - - # [...] other firewalls - - members_fe: - pattern: ^/(?!(admin)($|/)).*$ - provider: members - form_login: - login_path: members_user_security_login - check_path: members_user_security_check - csrf_token_generator: security.csrf.token_manager - logout: - path: members_user_security_logout - invalidate_session: false - target: / - anonymous: true - user_checker: MembersBundle\Security\UserChecker - - access_control: - - # [...] other access controls - - - { path: ^/_locale/members/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/_locale/members/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/_locale/members/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/src/Command/OAuthSetupCommand.php b/src/Command/OAuthSetupCommand.php index 89cfabc..ad3b309 100644 --- a/src/Command/OAuthSetupCommand.php +++ b/src/Command/OAuthSetupCommand.php @@ -20,14 +20,11 @@ class OAuthSetupCommand extends Command protected static $defaultName = 'members:oauth:setup'; protected static $defaultDescription = 'This command helps you the enhance Members with oauth2 connectors.'; - protected bool $oauthEnabled; protected ClassManagerInterface $classManager; protected ClassInstaller $classInstaller; - public function __construct(bool $oauthEnabled) + public function __construct(protected bool $oauthEnabled) { - $this->oauthEnabled = $oauthEnabled; - parent::__construct(); } diff --git a/src/Controller/Admin/RestrictionController.php b/src/Controller/Admin/RestrictionController.php index 85c8200..4cc5bb5 100644 --- a/src/Controller/Admin/RestrictionController.php +++ b/src/Controller/Admin/RestrictionController.php @@ -15,18 +15,11 @@ class RestrictionController extends AdminAbstractController { - protected Configuration $configuration; - protected ClassManagerInterface $classManager; - protected RestrictionService $restrictionService; - public function __construct( - Configuration $configuration, - ClassManagerInterface $classManager, - RestrictionService $restrictionService + protected Configuration $configuration, + protected ClassManagerInterface $classManager, + protected RestrictionService $restrictionService ) { - $this->configuration = $configuration; - $this->classManager = $classManager; - $this->restrictionService = $restrictionService; } public function getGlobalSettingsAction(): JsonResponse diff --git a/src/Controller/AuthController.php b/src/Controller/AuthController.php index dd7785c..382c2cd 100644 --- a/src/Controller/AuthController.php +++ b/src/Controller/AuthController.php @@ -6,15 +6,12 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\Security; +use Symfony\Bundle\SecurityBundle\Security; class AuthController extends AbstractController { - protected FactoryInterface $formFactory; - - public function __construct(FactoryInterface $formFactory) + public function __construct(protected FactoryInterface $formFactory) { - $this->formFactory = $formFactory; } public function loginAction(Request $request): Response diff --git a/src/Controller/ChangePasswordController.php b/src/Controller/ChangePasswordController.php index fab4f3c..af8bab7 100644 --- a/src/Controller/ChangePasswordController.php +++ b/src/Controller/ChangePasswordController.php @@ -17,18 +17,11 @@ class ChangePasswordController extends AbstractController { - protected FactoryInterface $formFactory; - protected EventDispatcherInterface $eventDispatcher; - protected UserManagerInterface $userManager; - public function __construct( - FactoryInterface $formFactory, - EventDispatcherInterface $eventDispatcher, - UserManagerInterface $userManager + protected FactoryInterface $formFactory, + protected EventDispatcherInterface $eventDispatcher, + protected UserManagerInterface $userManager ) { - $this->formFactory = $formFactory; - $this->eventDispatcher = $eventDispatcher; - $this->userManager = $userManager; } public function changePasswordAction(Request $request): Response diff --git a/src/Controller/DeleteAccountController.php b/src/Controller/DeleteAccountController.php index e66cea6..f1f235c 100644 --- a/src/Controller/DeleteAccountController.php +++ b/src/Controller/DeleteAccountController.php @@ -16,18 +16,11 @@ class DeleteAccountController extends AbstractController { - protected FactoryInterface $formFactory; - protected EventDispatcherInterface $eventDispatcher; - protected UserManagerInterface $userManager; - public function __construct( - FactoryInterface $formFactory, - EventDispatcherInterface $eventDispatcher, - UserManagerInterface $userManager + protected FactoryInterface $formFactory, + protected EventDispatcherInterface $eventDispatcher, + protected UserManagerInterface $userManager ) { - $this->formFactory = $formFactory; - $this->eventDispatcher = $eventDispatcher; - $this->userManager = $userManager; } public function deleteAccountAction(Request $request): Response diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index fa92033..bb970f9 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -18,21 +18,12 @@ class ProfileController extends AbstractController { - protected FactoryInterface $formFactory; - protected EventDispatcherInterface $eventDispatcher; - protected UserManagerInterface $userManager; - protected RequestHelper $requestHelper; - public function __construct( - FactoryInterface $formFactory, - EventDispatcherInterface $eventDispatcher, - UserManagerInterface $userManager, - RequestHelper $requestHelper + protected FactoryInterface $formFactory, + protected EventDispatcherInterface $eventDispatcher, + protected UserManagerInterface $userManager, + protected RequestHelper $requestHelper ) { - $this->formFactory = $formFactory; - $this->eventDispatcher = $eventDispatcher; - $this->userManager = $userManager; - $this->requestHelper = $requestHelper; } public function showAction(Request $request): Response diff --git a/src/Controller/ResettingController.php b/src/Controller/ResettingController.php index 04f9724..9161b57 100644 --- a/src/Controller/ResettingController.php +++ b/src/Controller/ResettingController.php @@ -21,30 +21,15 @@ class ResettingController extends AbstractController { - protected FactoryInterface $requestResettingFormFactory; - protected FactoryInterface $resettingFormFactory; - protected EventDispatcherInterface $eventDispatcher; - protected UserManagerInterface $userManager; - protected TokenGeneratorInterface $tokenGenerator; - protected MailerInterface $mailer; - protected RequestHelper $requestHelper; - public function __construct( - FactoryInterface $requestResettingFormFactory, - FactoryInterface $resettingFormFactory, - EventDispatcherInterface $eventDispatcher, - UserManagerInterface $userManager, - TokenGeneratorInterface $tokenGenerator, - MailerInterface $mailer, - RequestHelper $requestHelper + protected FactoryInterface $requestResettingFormFactory, + protected FactoryInterface $resettingFormFactory, + protected EventDispatcherInterface $eventDispatcher, + protected UserManagerInterface $userManager, + protected TokenGeneratorInterface $tokenGenerator, + protected MailerInterface $mailer, + protected RequestHelper $requestHelper ) { - $this->requestResettingFormFactory = $requestResettingFormFactory; - $this->resettingFormFactory = $resettingFormFactory; - $this->eventDispatcher = $eventDispatcher; - $this->userManager = $userManager; - $this->tokenGenerator = $tokenGenerator; - $this->mailer = $mailer; - $this->requestHelper = $requestHelper; } public function requestAction(Request $request): Response diff --git a/src/Document/Builder/BrickBuilder.php b/src/Document/Builder/BrickBuilder.php index de9c50e..1a87dad 100644 --- a/src/Document/Builder/BrickBuilder.php +++ b/src/Document/Builder/BrickBuilder.php @@ -9,16 +9,12 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\Security; +use Symfony\Bundle\SecurityBundle\Security; use Twig\Environment; class BrickBuilder { protected string $sourceType = 'area'; - protected TokenStorageInterface $tokenStorage; - protected IncludeRenderer $includeRenderer; - protected Environment $templateRenderer; - protected UrlGeneratorInterface $urlGenerator; protected ?string $logoutUri = null; protected bool $hideAfterLogin = false; protected ?Document $redirectPage = null; @@ -35,15 +31,11 @@ class BrickBuilder ]; public function __construct( - TokenStorageInterface $tokenStorage, - IncludeRenderer $includeRenderer, - Environment $templateRenderer, - UrlGeneratorInterface $urlGenerator + protected TokenStorageInterface $tokenStorage, + protected IncludeRenderer $includeRenderer, + protected Environment $templateRenderer, + protected UrlGeneratorInterface $urlGenerator ) { - $this->tokenStorage = $tokenStorage; - $this->includeRenderer = $includeRenderer; - $this->templateRenderer = $templateRenderer; - $this->urlGenerator = $urlGenerator; } public function setup(string $sourceType): self diff --git a/src/Event/FormEvent.php b/src/Event/FormEvent.php index bf54362..130fc9d 100755 --- a/src/Event/FormEvent.php +++ b/src/Event/FormEvent.php @@ -9,14 +9,12 @@ class FormEvent extends Event { - private FormInterface $form; - private Request $request; private ?Response $response = null; - public function __construct(FormInterface $form, Request $request) - { - $this->form = $form; - $this->request = $request; + public function __construct( + private FormInterface $form, + private Request $request + ) { } public function getForm(): FormInterface diff --git a/src/Event/OAuth/OAuthResourceEvent.php b/src/Event/OAuth/OAuthResourceEvent.php index 1a302f3..c9ca0d2 100644 --- a/src/Event/OAuth/OAuthResourceEvent.php +++ b/src/Event/OAuth/OAuthResourceEvent.php @@ -8,13 +8,10 @@ class OAuthResourceEvent extends Event { - protected UserInterface $user; - protected ResourceOwnerInterface $resourceOwner; - - public function __construct(UserInterface $user, ResourceOwnerInterface $resourceOwner) - { - $this->resourceOwner = $resourceOwner; - $this->user = $user; + public function __construct( + protected UserInterface $user, + protected ResourceOwnerInterface $resourceOwner + ) { } public function getUser(): UserInterface diff --git a/src/Event/OAuth/OAuthResponseEvent.php b/src/Event/OAuth/OAuthResponseEvent.php index 91452b4..5e229b9 100644 --- a/src/Event/OAuth/OAuthResponseEvent.php +++ b/src/Event/OAuth/OAuthResponseEvent.php @@ -7,11 +7,8 @@ class OAuthResponseEvent extends Event { - protected OAuthResponseInterface $oauthResponse; - - public function __construct(OAuthResponseInterface $oauthResponse) + public function __construct(protected OAuthResponseInterface $oauthResponse) { - $this->oauthResponse = $oauthResponse; } public function getOAuthResponse(): OAuthResponseInterface diff --git a/src/Event/RestrictionEvent.php b/src/Event/RestrictionEvent.php index 1def793..88ccdcd 100644 --- a/src/Event/RestrictionEvent.php +++ b/src/Event/RestrictionEvent.php @@ -8,13 +8,10 @@ class RestrictionEvent extends Event { - protected ElementInterface $element; - protected ?Restriction $restriction; - - public function __construct(ElementInterface $element, ?Restriction $restriction) - { - $this->element = $element; - $this->restriction = $restriction; + public function __construct( + protected ElementInterface $element, + protected ?Restriction $restriction + ) { } public function getElement(): ElementInterface diff --git a/src/Event/StaticRouteEvent.php b/src/Event/StaticRouteEvent.php index 88b7800..7ca35b0 100755 --- a/src/Event/StaticRouteEvent.php +++ b/src/Event/StaticRouteEvent.php @@ -8,14 +8,12 @@ class StaticRouteEvent extends Event { - protected Request $request; - protected ?string $routeName; protected ?DataObject $object = null; - public function __construct(Request $request, ?string $routeName = null) - { - $this->request = $request; - $this->routeName = $routeName; + public function __construct( + protected Request $request, + protected ?string $routeName = null + ) { } public function getRequest(): Request diff --git a/src/Event/UserEvent.php b/src/Event/UserEvent.php index cd50471..baa8bf3 100644 --- a/src/Event/UserEvent.php +++ b/src/Event/UserEvent.php @@ -8,13 +8,10 @@ class UserEvent extends Event { - protected ?UserInterface $user = null; - protected ?Request $request = null; - - public function __construct(?UserInterface $user, ?Request $request = null) - { - $this->user = $user; - $this->request = $request; + public function __construct( + protected ?UserInterface $user = null, + protected ?Request $request = null + ) { } public function getUser(): ?UserInterface diff --git a/src/EventListener/AssetFrontendPathListener.php b/src/EventListener/AssetFrontendPathListener.php index 346c891..4e1fcb3 100644 --- a/src/EventListener/AssetFrontendPathListener.php +++ b/src/EventListener/AssetFrontendPathListener.php @@ -11,7 +11,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; class AssetFrontendPathListener implements EventSubscriberInterface { diff --git a/src/EventListener/AuthenticationListener.php b/src/EventListener/AuthenticationListener.php index eed388c..7d0c771 100644 --- a/src/EventListener/AuthenticationListener.php +++ b/src/EventListener/AuthenticationListener.php @@ -12,13 +12,10 @@ class AuthenticationListener implements EventSubscriberInterface { - private LoginManagerInterface $loginManager; - private string $firewallName; - - public function __construct(LoginManagerInterface $loginManager, string $firewallName = 'members_fe') - { - $this->loginManager = $loginManager; - $this->firewallName = $firewallName; + public function __construct( + private LoginManagerInterface $loginManager, + private string $firewallName = 'members_fe' + ) { } /** diff --git a/src/EventListener/FlashListener.php b/src/EventListener/FlashListener.php index 67696a4..366b07c 100755 --- a/src/EventListener/FlashListener.php +++ b/src/EventListener/FlashListener.php @@ -19,8 +19,10 @@ class FlashListener implements EventSubscriberInterface MembersEvents::OAUTH_PROFILE_CONNECTION_SUCCESS => 'members.oauth.connection.success', ]; - public function __construct(protected RequestStack $requestStack, protected Translator $translator) - { + public function __construct( + protected RequestStack $requestStack, + protected Translator $translator + ) { } public static function getSubscribedEvents(): array diff --git a/src/EventListener/ForbiddenRouteListener.php b/src/EventListener/ForbiddenRouteListener.php index 5b46a76..29e8ce6 100644 --- a/src/EventListener/ForbiddenRouteListener.php +++ b/src/EventListener/ForbiddenRouteListener.php @@ -22,15 +22,11 @@ class ForbiddenRouteListener implements EventSubscriberInterface { use PimcoreContextAwareTrait; - protected RestrictionManagerInterface $restrictionManager; - protected RouterInterface $router; - protected RequestHelper $requestHelper; - - public function __construct(RestrictionManagerInterface $restrictionManager, RouterInterface $router, RequestHelper $requestHelper) - { - $this->restrictionManager = $restrictionManager; - $this->router = $router; - $this->requestHelper = $requestHelper; + public function __construct( + protected RestrictionManagerInterface $restrictionManager, + protected RouterInterface $router, + protected RequestHelper $requestHelper + ) { } public static function getSubscribedEvents(): array diff --git a/src/EventListener/Frontend/HeadMetaListener.php b/src/EventListener/Frontend/HeadMetaListener.php index 02fff4d..63c6708 100644 --- a/src/EventListener/Frontend/HeadMetaListener.php +++ b/src/EventListener/Frontend/HeadMetaListener.php @@ -3,10 +3,8 @@ namespace MembersBundle\EventListener\Frontend; use MembersBundle\Manager\RestrictionManager; -use MembersBundle\Manager\RestrictionManagerInterface; use MembersBundle\Restriction\ElementRestriction; use Pimcore\Bundle\CoreBundle\EventListener\Traits\PimcoreContextAwareTrait; -use Pimcore\Http\Request\Resolver\DocumentResolver as DocumentResolverService; use Pimcore\Http\Request\Resolver\PimcoreContextResolver; use Pimcore\Twig\Extension\Templating\HeadMeta; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -17,18 +15,8 @@ class HeadMetaListener implements EventSubscriberInterface { use PimcoreContextAwareTrait; - protected DocumentResolverService $documentResolverService; - protected HeadMeta $headMeta; - protected RestrictionManagerInterface $restrictionManager; - - public function __construct( - RestrictionManagerInterface $restrictionManager, - DocumentResolverService $documentResolverService, - HeadMeta $headMeta - ) { - $this->documentResolverService = $documentResolverService; - $this->headMeta = $headMeta; - $this->restrictionManager = $restrictionManager; + public function __construct(protected HeadMeta $headMeta) + { } public static function getSubscribedEvents(): array diff --git a/src/EventListener/LastLoginListener.php b/src/EventListener/LastLoginListener.php index 2c855b7..31f2e51 100644 --- a/src/EventListener/LastLoginListener.php +++ b/src/EventListener/LastLoginListener.php @@ -13,11 +13,8 @@ class LastLoginListener implements EventSubscriberInterface { - protected UserManagerInterface $userManager; - - public function __construct(UserManagerInterface $userManager) + public function __construct(protected UserManagerInterface $userManager) { - $this->userManager = $userManager; } public static function getSubscribedEvents(): array diff --git a/src/EventListener/Maintenance/SsoCleanUpExpiredTokenListener.php b/src/EventListener/Maintenance/SsoCleanUpExpiredTokenListener.php index 85bd676..0e39c22 100644 --- a/src/EventListener/Maintenance/SsoCleanUpExpiredTokenListener.php +++ b/src/EventListener/Maintenance/SsoCleanUpExpiredTokenListener.php @@ -11,24 +11,13 @@ class SsoCleanUpExpiredTokenListener implements TaskInterface { - protected bool $oauthEnabled; - protected bool $cleanUpExpiredTokens; - protected int $expiredTokensTtl; - protected SsoIdentityManagerInterface $ssoIdentityManager; - protected SsoIdentityStatusServiceInterface $ssoIdentityStatusService; - public function __construct( - bool $oauthEnabled, - bool $cleanUpExpiredTokens, - int $expiredTokensTtl, - SsoIdentityManagerInterface $ssoIdentityManager, - SsoIdentityStatusServiceInterface $ssoIdentityStatusService + protected bool $oauthEnabled, + protected bool $cleanUpExpiredTokens, + protected int $expiredTokensTtl, + protected SsoIdentityManagerInterface $ssoIdentityManager, + protected SsoIdentityStatusServiceInterface $ssoIdentityStatusService ) { - $this->oauthEnabled = $oauthEnabled; - $this->cleanUpExpiredTokens = $cleanUpExpiredTokens; - $this->expiredTokensTtl = $expiredTokensTtl; - $this->ssoIdentityManager = $ssoIdentityManager; - $this->ssoIdentityStatusService = $ssoIdentityStatusService; } /** diff --git a/src/EventListener/OAuthRegistrationListener.php b/src/EventListener/OAuthRegistrationListener.php index 315fc75..e35b043 100644 --- a/src/EventListener/OAuthRegistrationListener.php +++ b/src/EventListener/OAuthRegistrationListener.php @@ -14,18 +14,11 @@ class OAuthRegistrationListener implements EventSubscriberInterface { - protected OAuthRegistrationHandler $oAuthRegistrationHandler; - protected OAuthTokenStorageInterface $oAuthTokenStorage; - protected ResourceMappingService $resourceMappingService; - public function __construct( - OAuthRegistrationHandler $oAuthRegistrationHandler, - OAuthTokenStorageInterface $oAuthTokenStorage, - ResourceMappingService $resourceMappingService + protected OAuthRegistrationHandler $oAuthRegistrationHandler, + protected OAuthTokenStorageInterface $oAuthTokenStorage, + protected ResourceMappingService $resourceMappingService ) { - $this->oAuthRegistrationHandler = $oAuthRegistrationHandler; - $this->oAuthTokenStorage = $oAuthTokenStorage; - $this->resourceMappingService = $resourceMappingService; } public static function getSubscribedEvents(): array diff --git a/src/EventListener/ResettingListener.php b/src/EventListener/ResettingListener.php index ea9e0f2..4c045c3 100755 --- a/src/EventListener/ResettingListener.php +++ b/src/EventListener/ResettingListener.php @@ -13,18 +13,11 @@ class ResettingListener implements EventSubscriberInterface { - private UserManagerInterface $userManager; - private UrlGeneratorInterface $router; - private int $tokenTtl; - public function __construct( - UserManagerInterface $userManager, - UrlGeneratorInterface $router, - int $tokenTtl + private UserManagerInterface $userManager, + private UrlGeneratorInterface $router, + private int $tokenTtl ) { - $this->userManager = $userManager; - $this->router = $router; - $this->tokenTtl = $tokenTtl; } public static function getSubscribedEvents(): array diff --git a/src/EventListener/RestrictionStoreListener.php b/src/EventListener/RestrictionStoreListener.php index 656235d..3e1b886 100644 --- a/src/EventListener/RestrictionStoreListener.php +++ b/src/EventListener/RestrictionStoreListener.php @@ -13,11 +13,8 @@ class RestrictionStoreListener implements EventSubscriberInterface { - protected RestrictionService $serviceRestriction; - - public function __construct(RestrictionService $serviceRestriction) + public function __construct(protected RestrictionService $serviceRestriction) { - $this->serviceRestriction = $serviceRestriction; } public static function getSubscribedEvents(): array diff --git a/src/EventListener/UserChangeListener.php b/src/EventListener/UserChangeListener.php index efc8488..9fc534e 100644 --- a/src/EventListener/UserChangeListener.php +++ b/src/EventListener/UserChangeListener.php @@ -11,18 +11,11 @@ class UserChangeListener implements EventSubscriberInterface { - protected UserManagerInterface $userManager; - protected MailerInterface $mailer; - protected string $postEventType; - public function __construct( - UserManagerInterface $userManager, - MailerInterface $mailer, - string $postEventType + protected UserManagerInterface $userManager, + protected MailerInterface $mailer, + protected string $postEventType ) { - $this->userManager = $userManager; - $this->mailer = $mailer; - $this->postEventType = $postEventType; } public static function getSubscribedEvents(): array diff --git a/src/Form/Extension/RegistrationAuthIdentifierTypeExtension.php b/src/Form/Extension/RegistrationAuthIdentifierTypeExtension.php index 7eb600d..6d6b28a 100644 --- a/src/Form/Extension/RegistrationAuthIdentifierTypeExtension.php +++ b/src/Form/Extension/RegistrationAuthIdentifierTypeExtension.php @@ -10,13 +10,10 @@ class RegistrationAuthIdentifierTypeExtension extends AbstractTypeExtension { - protected string $authIdentifier; - protected bool $onlyAuthIdentifierRegistration; - - public function __construct(string $authIdentifier, bool $onlyAuthIdentifierRegistration) - { - $this->authIdentifier = $authIdentifier; - $this->onlyAuthIdentifierRegistration = $onlyAuthIdentifierRegistration; + public function __construct( + protected string $authIdentifier, + protected bool $onlyAuthIdentifierRegistration + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Extension/RegistrationTypeExtension.php b/src/Form/Extension/RegistrationTypeExtension.php index 32c7d58..2343e22 100644 --- a/src/Form/Extension/RegistrationTypeExtension.php +++ b/src/Form/Extension/RegistrationTypeExtension.php @@ -11,11 +11,8 @@ class RegistrationTypeExtension extends AbstractTypeExtension { - protected RequestStack $requestStack; - - public function __construct(RequestStack $requestStack) + public function __construct(protected RequestStack $requestStack) { - $this->requestStack = $requestStack; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Factory/FormFactory.php b/src/Form/Factory/FormFactory.php index 78549b4..70a32df 100644 --- a/src/Form/Factory/FormFactory.php +++ b/src/Form/Factory/FormFactory.php @@ -8,17 +8,13 @@ class FormFactory implements FactoryInterface { - private FormFactoryInterface $formFactory; - private string $name; - private string $type; - private null|array|ValidationGroupResolverInterface $validationGroups; - - public function __construct(FormFactoryInterface $formFactory, string $name, string $type, null|array|ValidationGroupResolverInterface $validationGroups = null) + public function __construct( + private FormFactoryInterface $formFactory, + private string $name, + private string $type, + private null|array|ValidationGroupResolverInterface $validationGroups = null + ) { - $this->formFactory = $formFactory; - $this->name = $name; - $this->type = $type; - $this->validationGroups = $validationGroups; } public function createForm(array $options = []): FormInterface diff --git a/src/Form/Type/ChangePasswordFormType.php b/src/Form/Type/ChangePasswordFormType.php index b111c61..58e3b5b 100755 --- a/src/Form/Type/ChangePasswordFormType.php +++ b/src/Form/Type/ChangePasswordFormType.php @@ -12,11 +12,8 @@ class ChangePasswordFormType extends AbstractType { - private string $class; - - public function __construct(string $class) + public function __construct(private string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/DeleteAccountFormType.php b/src/Form/Type/DeleteAccountFormType.php index 2192aeb..31af4ed 100644 --- a/src/Form/Type/DeleteAccountFormType.php +++ b/src/Form/Type/DeleteAccountFormType.php @@ -14,11 +14,8 @@ class DeleteAccountFormType extends AbstractType { - private string $class; - - public function __construct(string $class) + public function __construct(private string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/ProfileFormType.php b/src/Form/Type/ProfileFormType.php index 1dbc729..8bb8412 100755 --- a/src/Form/Type/ProfileFormType.php +++ b/src/Form/Type/ProfileFormType.php @@ -13,11 +13,8 @@ class ProfileFormType extends AbstractType { - private string $class; - - public function __construct(string $class) + public function __construct(private string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/RegistrationFormType.php b/src/Form/Type/RegistrationFormType.php index 25c991a..ce62ec0 100644 --- a/src/Form/Type/RegistrationFormType.php +++ b/src/Form/Type/RegistrationFormType.php @@ -12,11 +12,8 @@ class RegistrationFormType extends AbstractType { - protected string $class; - - public function __construct(string $class) + public function __construct(protected string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/ResettingFormType.php b/src/Form/Type/ResettingFormType.php index 45e8743..94da759 100755 --- a/src/Form/Type/ResettingFormType.php +++ b/src/Form/Type/ResettingFormType.php @@ -11,11 +11,8 @@ class ResettingFormType extends AbstractType { - private string $class; - - public function __construct(string $class) + public function __construct(private string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/Sso/CompleteProfileFormType.php b/src/Form/Type/Sso/CompleteProfileFormType.php index c345dbd..5a931c1 100755 --- a/src/Form/Type/Sso/CompleteProfileFormType.php +++ b/src/Form/Type/Sso/CompleteProfileFormType.php @@ -13,11 +13,8 @@ class CompleteProfileFormType extends AbstractType { - protected string $class; - - public function __construct(string $class) + public function __construct(protected string $class) { - $this->class = $class; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Mailer/Mailer.php b/src/Mailer/Mailer.php index e87ae3d..6e611ca 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -11,13 +11,11 @@ class Mailer implements MailerInterface { - protected UrlGeneratorInterface $router; - protected Configuration $configuration; - - public function __construct(UrlGeneratorInterface $router, Configuration $configuration) + public function __construct( + protected UrlGeneratorInterface $router, + protected Configuration $configuration + ) { - $this->router = $router; - $this->configuration = $configuration; } public function sendConfirmationEmailMessage(UserInterface $user): void diff --git a/src/Manager/ClassManager.php b/src/Manager/ClassManager.php index 4412337..0327426 100644 --- a/src/Manager/ClassManager.php +++ b/src/Manager/ClassManager.php @@ -8,11 +8,8 @@ class ClassManager implements ClassManagerInterface { - protected Configuration $configuration; - - public function __construct(Configuration $configuration) + public function __construct(protected Configuration $configuration) { - $this->configuration = $configuration; } public function getGroupListing(): Listing diff --git a/src/Manager/LoginManager.php b/src/Manager/LoginManager.php index 7a86429..3978c8c 100755 --- a/src/Manager/LoginManager.php +++ b/src/Manager/LoginManager.php @@ -8,29 +8,18 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface; +use Symfony\Component\Security\Http\RememberMe\RememberMeHandlerInterface; use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface; class LoginManager implements LoginManagerInterface { - private TokenStorageInterface $tokenStorage; - private UserChecker $userChecker; - private SessionAuthenticationStrategyInterface $sessionStrategy; - private RequestStack $requestStack; - private ?RememberMeServicesInterface $rememberMeService; - public function __construct( - TokenStorageInterface $tokenStorage, - UserChecker $userChecker, - SessionAuthenticationStrategyInterface $sessionStrategy, - RequestStack $requestStack, - ?RememberMeServicesInterface $rememberMeService = null + private TokenStorageInterface $tokenStorage, + private UserChecker $userChecker, + private SessionAuthenticationStrategyInterface $sessionStrategy, + private RequestStack $requestStack, + private ?RememberMeHandlerInterface $rememberMeService = null ) { - $this->tokenStorage = $tokenStorage; - $this->userChecker = $userChecker; - $this->sessionStrategy = $sessionStrategy; - $this->requestStack = $requestStack; - $this->rememberMeService = $rememberMeService; } final public function logInUser(string $firewallName, UserInterface $user, Response $response = null): void @@ -44,7 +33,7 @@ final public function logInUser(string $firewallName, UserInterface $user, Respo $this->sessionStrategy->onAuthentication($request, $token); if (null !== $response && null !== $this->rememberMeService) { - $this->rememberMeService->loginSuccess($request, $response, $token); + $this->rememberMeService->createRememberMeCookie($user); } } @@ -53,6 +42,6 @@ final public function logInUser(string $firewallName, UserInterface $user, Respo protected function createToken(string $firewall, UserInterface $user): UsernamePasswordToken { - return new UsernamePasswordToken($user, null, $firewall, $user->getRoles()); + return new UsernamePasswordToken($user, $firewall, $user->getRoles()); } } diff --git a/src/Manager/RestrictionManager.php b/src/Manager/RestrictionManager.php index 8b26992..6e2fbbc 100644 --- a/src/Manager/RestrictionManager.php +++ b/src/Manager/RestrictionManager.php @@ -25,13 +25,10 @@ class RestrictionManager implements RestrictionManagerInterface public const RESTRICTION_SECTION_REFUSED = 'members.restriction.refused'; public const REQUEST_RESTRICTION_STORAGE = 'members.restriction.store'; - protected Configuration $configuration; - protected TokenStorageInterface $tokenStorage; - - public function __construct(Configuration $configuration, TokenStorageInterface $tokenStorage) - { - $this->configuration = $configuration; - $this->tokenStorage = $tokenStorage; + public function __construct( + protected Configuration $configuration, + protected TokenStorageInterface $tokenStorage + ) { } public function getElementRestrictedGroups(ElementInterface $element): array diff --git a/src/Manager/SsoIdentityManager.php b/src/Manager/SsoIdentityManager.php index 99cc605..785adc7 100644 --- a/src/Manager/SsoIdentityManager.php +++ b/src/Manager/SsoIdentityManager.php @@ -11,18 +11,11 @@ class SsoIdentityManager implements SsoIdentityManagerInterface { - protected Connection $connection; - protected UserManagerInterface $userManager; - protected ClassManagerInterface $classManager; - public function __construct( - Connection $connection, - UserManagerInterface $userManager, - ClassManagerInterface $classManager + protected Connection $connection, + protected UserManagerInterface $userManager, + protected ClassManagerInterface $classManager ) { - $this->connection = $connection; - $this->userManager = $userManager; - $this->classManager = $classManager; } public function getClass(): string diff --git a/src/Security/OAuth/AccountConnector.php b/src/Security/OAuth/AccountConnector.php index 48ece57..3469bb2 100755 --- a/src/Security/OAuth/AccountConnector.php +++ b/src/Security/OAuth/AccountConnector.php @@ -10,15 +10,10 @@ class AccountConnector implements AccountConnectorInterface { - protected SsoIdentityManagerInterface $ssoIdentityManager; - protected ResourceMappingService $resourceMappingService; - public function __construct( - SsoIdentityManagerInterface $ssoIdentityManager, - ResourceMappingService $resourceMappingService + protected SsoIdentityManagerInterface $ssoIdentityManager, + protected ResourceMappingService $resourceMappingService ) { - $this->ssoIdentityManager = $ssoIdentityManager; - $this->resourceMappingService = $resourceMappingService; } public function connectToSsoIdentity(UserInterface $user, OAuthResponseInterface $oAuthResponse): SsoIdentityInterface diff --git a/src/Security/OAuth/Dispatcher/ConnectDispatcher.php b/src/Security/OAuth/Dispatcher/ConnectDispatcher.php index 3887907..edfb212 100644 --- a/src/Security/OAuth/Dispatcher/ConnectDispatcher.php +++ b/src/Security/OAuth/Dispatcher/ConnectDispatcher.php @@ -13,18 +13,11 @@ class ConnectDispatcher implements DispatcherInterface { - protected TokenStorageInterface $tokenStorage; - protected EventDispatcherInterface $eventDispatcher; - protected OAuthRegistrationHandler $oAuthRegistrationHandler; - public function __construct( - TokenStorageInterface $tokenStorage, - EventDispatcherInterface $eventDispatcher, - OAuthRegistrationHandler $oAuthRegistrationHandler + protected TokenStorageInterface $tokenStorage, + protected EventDispatcherInterface $eventDispatcher, + protected OAuthRegistrationHandler $oAuthRegistrationHandler ) { - $this->tokenStorage = $tokenStorage; - $this->eventDispatcher = $eventDispatcher; - $this->oAuthRegistrationHandler = $oAuthRegistrationHandler; } public function dispatch(string $provider, OAuthResponse $oAuthResponse): UserInterface diff --git a/src/Security/OAuth/Dispatcher/LoginDispatcher.php b/src/Security/OAuth/Dispatcher/LoginDispatcher.php index 3841f85..3e4467d 100644 --- a/src/Security/OAuth/Dispatcher/LoginDispatcher.php +++ b/src/Security/OAuth/Dispatcher/LoginDispatcher.php @@ -9,15 +9,10 @@ class LoginDispatcher implements DispatcherInterface { - protected Configuration $configuration; - protected OAuthLoginProcessorRegistryInterface $loginProcessorRegistry; - public function __construct( - Configuration $configuration, - OAuthLoginProcessorRegistryInterface $loginProcessorRegistry + protected Configuration $configuration, + protected OAuthLoginProcessorRegistryInterface $loginProcessorRegistry ) { - $this->configuration = $configuration; - $this->loginProcessorRegistry = $loginProcessorRegistry; } public function dispatch(string $provider, OAuthResponse $oAuthResponse): ?UserInterface diff --git a/src/Security/OAuth/OAuthRegistrationHandler.php b/src/Security/OAuth/OAuthRegistrationHandler.php index 1d1b03a..1245873 100644 --- a/src/Security/OAuth/OAuthRegistrationHandler.php +++ b/src/Security/OAuth/OAuthRegistrationHandler.php @@ -11,21 +11,12 @@ class OAuthRegistrationHandler { - protected SsoIdentityManagerInterface $ssoIdentityManager; - protected AccountConnectorInterface $accountConnector; - protected UserManagerInterface $userManager; - protected RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService; - public function __construct( - SsoIdentityManagerInterface $ssoIdentityManager, - AccountConnectorInterface $accountConnector, - UserManagerInterface $userManager, - RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService + protected SsoIdentityManagerInterface $ssoIdentityManager, + protected AccountConnectorInterface $accountConnector, + protected UserManagerInterface $userManager, + protected RequestPropertiesForUserExtractorServiceInterface $requestPropertiesForUserExtractorService ) { - $this->ssoIdentityManager = $ssoIdentityManager; - $this->accountConnector = $accountConnector; - $this->userManager = $userManager; - $this->requestPropertiesForUserExtractorService = $requestPropertiesForUserExtractorService; } public function getUserFromUserResponse(OAuthResponseInterface $OAuthResponse): ?UserInterface diff --git a/src/Security/OAuth/OAuthResponse.php b/src/Security/OAuth/OAuthResponse.php index 6aebae0..a3da30f 100644 --- a/src/Security/OAuth/OAuthResponse.php +++ b/src/Security/OAuth/OAuthResponse.php @@ -7,17 +7,12 @@ class OAuthResponse implements OAuthResponseInterface { - protected string $provider; - protected AccessToken $accessToken; - protected ResourceOwnerInterface $resourceOwner; - protected array $parameter; - - public function __construct(string $provider, AccessToken $accessToken, ResourceOwnerInterface $resourceOwner, array $parameter = []) - { - $this->provider = $provider; - $this->accessToken = $accessToken; - $this->resourceOwner = $resourceOwner; - $this->parameter = $parameter; + public function __construct( + protected string $provider, + protected AccessToken $accessToken, + protected ResourceOwnerInterface $resourceOwner, + protected array $parameter = [] + ) { } public function getProvider(): string diff --git a/src/Security/OAuth/OAuthScopeAllocator.php b/src/Security/OAuth/OAuthScopeAllocator.php index a5e8287..6596c2e 100644 --- a/src/Security/OAuth/OAuthScopeAllocator.php +++ b/src/Security/OAuth/OAuthScopeAllocator.php @@ -4,11 +4,8 @@ class OAuthScopeAllocator implements OAuthScopeAllocatorInterface { - protected array $scopes; - - public function __construct(array $scopes) + public function __construct(protected array $scopes) { - $this->scopes = $scopes; } public function allocate(string $client): array diff --git a/src/Security/RestrictionQuery.php b/src/Security/RestrictionQuery.php index 7e11a8b..5e5f2e0 100644 --- a/src/Security/RestrictionQuery.php +++ b/src/Security/RestrictionQuery.php @@ -11,14 +11,11 @@ class RestrictionQuery { - protected RestrictionManagerInterface $restrictionManager; - - public function __construct(RestrictionManagerInterface $restrictionManager) + public function __construct(protected RestrictionManagerInterface $restrictionManager) { - $this->restrictionManager = $restrictionManager; } - public function addRestrictionInjection(QueryBuilder $query, Model\Listing\AbstractListing $listing, string $queryIdentifier = 'id', ?string $aliasFrom = null) + public function addRestrictionInjection(QueryBuilder $query, Model\Listing\AbstractListing $listing, string $queryIdentifier = 'id', ?string $aliasFrom = null): void { $additionalQuery = ''; $allowedGroups = []; diff --git a/src/Security/RestrictionUri.php b/src/Security/RestrictionUri.php index 40ff466..910f6e8 100644 --- a/src/Security/RestrictionUri.php +++ b/src/Security/RestrictionUri.php @@ -7,19 +7,9 @@ use MembersBundle\Restriction\Restriction; use Pimcore\Model; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; class RestrictionUri { - /** - * @deprecated since 4.1 and will be removed with 5.0 - */ - public const PROTECTED_ASSET_FOLDER = 'restricted-assets'; - /** - * @deprecated since 4.1 and will be removed with 5.0 - */ - public const MEMBERS_REQUEST_URL = '/members/request-data/'; - public function __construct( protected RouterInterface $router, protected RestrictionManagerInterface $restrictionManager diff --git a/src/Security/UserProvider.php b/src/Security/UserProvider.php index c87007d..6d003dd 100644 --- a/src/Security/UserProvider.php +++ b/src/Security/UserProvider.php @@ -11,13 +11,10 @@ class UserProvider implements UserProviderInterface { - protected string $authIdentifier; - protected UserManagerInterface $userManager; - - public function __construct(string $authIdentifier, UserManagerInterface $userManager) - { - $this->authIdentifier = $authIdentifier; - $this->userManager = $userManager; + public function __construct( + protected string $authIdentifier, + protected UserManagerInterface $userManager + ) { } public function loadUserByUsername(string $username) diff --git a/src/Service/RequestPropertiesForUserExtractorService.php b/src/Service/RequestPropertiesForUserExtractorService.php index cfba3a2..e3e5001 100644 --- a/src/Service/RequestPropertiesForUserExtractorService.php +++ b/src/Service/RequestPropertiesForUserExtractorService.php @@ -8,11 +8,8 @@ class RequestPropertiesForUserExtractorService implements RequestPropertiesForUserExtractorServiceInterface { - protected SiteResolver $siteResolver; - - public function __construct(SiteResolver $siteResolver) + public function __construct(protected SiteResolver $siteResolver) { - $this->siteResolver = $siteResolver; } public function extract(Request $request): array diff --git a/src/Service/ResourceMappingService.php b/src/Service/ResourceMappingService.php index 4bc1a8c..9493a2d 100644 --- a/src/Service/ResourceMappingService.php +++ b/src/Service/ResourceMappingService.php @@ -14,13 +14,10 @@ class ResourceMappingService public const MAP_FOR_PROFILE = 'profile'; public const MAP_FOR_REGISTRATION = 'registration'; - protected string $authIdentifier; - protected EventDispatcherInterface $eventDispatcher; - - public function __construct(string $authIdentifier, EventDispatcherInterface $eventDispatcher) - { - $this->authIdentifier = $authIdentifier; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + protected string $authIdentifier, + protected EventDispatcherInterface $eventDispatcher + ) { } /** diff --git a/src/Service/RestrictionService.php b/src/Service/RestrictionService.php index 6ba9fdb..2c94468 100644 --- a/src/Service/RestrictionService.php +++ b/src/Service/RestrictionService.php @@ -14,11 +14,8 @@ class RestrictionService { public const ALLOWED_RESTRICTION_CTYPES = ['asset', 'page', 'object']; - protected EventDispatcherInterface $eventDispatcher; - - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(protected EventDispatcherInterface $eventDispatcher) { - $this->eventDispatcher = $eventDispatcher; } /** diff --git a/src/Service/SsoIdentityStatusService.php b/src/Service/SsoIdentityStatusService.php index 37f025d..22ec37c 100644 --- a/src/Service/SsoIdentityStatusService.php +++ b/src/Service/SsoIdentityStatusService.php @@ -11,15 +11,10 @@ class SsoIdentityStatusService implements SsoIdentityStatusServiceInterface { - protected SsoIdentityManagerInterface $ssoIdentityManager; - protected EventDispatcherInterface $eventDispatcher; - public function __construct( - SsoIdentityManagerInterface $ssoIdentityManager, - EventDispatcherInterface $eventDispatcher + protected SsoIdentityManagerInterface $ssoIdentityManager, + protected EventDispatcherInterface $eventDispatcher ) { - $this->ssoIdentityManager = $ssoIdentityManager; - $this->eventDispatcher = $eventDispatcher; } public function identityCanCompleteProfile(UserInterface $user): bool diff --git a/src/Twig/Extension/NavigationExtension.php b/src/Twig/Extension/NavigationExtension.php index 94a36a5..071135a 100644 --- a/src/Twig/Extension/NavigationExtension.php +++ b/src/Twig/Extension/NavigationExtension.php @@ -18,18 +18,11 @@ class NavigationExtension extends AbstractExtension { - protected Navigation $navigationExtension; - protected RestrictionManagerInterface $restrictionManager; - protected TokenStorageInterface $tokenStorage; - public function __construct( - Navigation $navigationExtension, - RestrictionManagerInterface $restrictionManager, - TokenStorageInterface $tokenStorage + protected Navigation $navigationExtension, + protected RestrictionManagerInterface $restrictionManager, + protected TokenStorageInterface $tokenStorage ) { - $this->navigationExtension = $navigationExtension; - $this->restrictionManager = $restrictionManager; - $this->tokenStorage = $tokenStorage; } public function getFunctions(): array diff --git a/src/Twig/Extension/OAuthExtension.php b/src/Twig/Extension/OAuthExtension.php index 583b7d0..6c40986 100644 --- a/src/Twig/Extension/OAuthExtension.php +++ b/src/Twig/Extension/OAuthExtension.php @@ -13,21 +13,12 @@ class OAuthExtension extends AbstractExtension { - protected ClientRegistry $oauthRegistry; - protected SsoIdentityManagerInterface $ssoIdentityManager; - protected TokenStorageInterface $tokenStorage; - protected SsoIdentityStatusServiceInterface $identityStatusService; - public function __construct( - ClientRegistry $oauthRegistry, - SsoIdentityManagerInterface $ssoIdentityManager, - TokenStorageInterface $tokenStorage, - SsoIdentityStatusServiceInterface $identityStatusService + protected ClientRegistry $oauthRegistry, + protected SsoIdentityManagerInterface $ssoIdentityManager, + protected TokenStorageInterface $tokenStorage, + protected SsoIdentityStatusServiceInterface $identityStatusService ) { - $this->oauthRegistry = $oauthRegistry; - $this->ssoIdentityManager = $ssoIdentityManager; - $this->tokenStorage = $tokenStorage; - $this->identityStatusService = $identityStatusService; } public function getFunctions(): array diff --git a/src/Twig/Extension/RestrictionUriExtension.php b/src/Twig/Extension/RestrictionUriExtension.php index 47dafb4..c88e5a0 100644 --- a/src/Twig/Extension/RestrictionUriExtension.php +++ b/src/Twig/Extension/RestrictionUriExtension.php @@ -9,11 +9,8 @@ class RestrictionUriExtension extends AbstractExtension { - protected RestrictionUri $restrictionUri; - - public function __construct(RestrictionUri $restrictionUri) + public function __construct(protected RestrictionUri $restrictionUri) { - $this->restrictionUri = $restrictionUri; } public function getFunctions(): array diff --git a/src/Twig/Extension/SystemExtension.php b/src/Twig/Extension/SystemExtension.php index e2443d8..e032de6 100644 --- a/src/Twig/Extension/SystemExtension.php +++ b/src/Twig/Extension/SystemExtension.php @@ -7,11 +7,8 @@ class SystemExtension extends AbstractExtension { - protected bool $oauthEnabled; - - public function __construct(bool $oauthEnabled) + public function __construct(protected bool $oauthEnabled) { - $this->oauthEnabled = $oauthEnabled; } public function getFunctions(): array diff --git a/tests/Unit/Manager/LoginManagerTest.php b/tests/Unit/Manager/LoginManagerTest.php index 2d72821..1b194d5 100644 --- a/tests/Unit/Manager/LoginManagerTest.php +++ b/tests/Unit/Manager/LoginManagerTest.php @@ -11,29 +11,24 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface; +use Symfony\Component\Security\Http\RememberMe\RememberMeHandlerInterface; use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface; class LoginManagerTest extends TestCase { - public function testLogInUserWithRequestStack() + public function testLogInUserWithRequestStack(): void { $loginManager = $this->createLoginManager(); $loginManager->logInUser('main', $this->mockUser()); } - public function testLogInUserWithRememberMeAndRequestStack() + public function testLogInUserWithRememberMeAndRequestStack(): void { $response = $this->getMockBuilder(Response::class)->getMock(); $loginManager = $this->createLoginManager($response); $loginManager->logInUser('main', $this->mockUser(), $response); } - /** - * @param Response|null $response - * - * @return LoginManager - */ private function createLoginManager(Response $response = null) { $tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock(); @@ -60,23 +55,20 @@ private function createLoginManager(Response $response = null) $requestStack ->expects($this->once()) ->method('getCurrentRequest') - ->will($this->returnValue($request)); + ->willReturn($request); $rememberMe = null; if (null !== $response) { - $rememberMe = $this->getMockBuilder(RememberMeServicesInterface::class)->getMock(); - $rememberMe - ->expects($this->once()) - ->method('loginSuccess') - ->with($request, $response, $this->isInstanceOf(TokenInterface::class)); + $user = $this->mockUser(); + $rememberMeHandler = $this->createMock(RememberMeHandlerInterface::class); + $rememberMeHandler->expects($this->once()) + ->method('createRememberMeCookie') + ->with($user); } return new LoginManager($tokenStorage, $userChecker, $sessionStrategy, $requestStack, $rememberMe); } - /** - * @return mixed - */ private function mockUser() { $user = $this->getMockBuilder(UserInterface::class)->getMock(); @@ -84,6 +76,7 @@ private function mockUser() ->expects($this->once()) ->method('getRoles') ->will($this->returnValue(['ROLE_USER'])); + return $user; } } diff --git a/tests/_etc/config/app/config.yaml b/tests/_etc/config/app/config.yaml index ac916c7..ffb68cc 100755 --- a/tests/_etc/config/app/config.yaml +++ b/tests/_etc/config/app/config.yaml @@ -10,7 +10,7 @@ services: calls: - [setContainer, ['@service_container']] - DachcomBundle\Test\Services\TestRestrictedStaticRouteListener: + DachcomBundle\Test\Support\Services\TestRestrictedStaticRouteListener: tags: - { name: kernel.event_subscriber } diff --git a/tests/_etc/config/app/security.yaml b/tests/_etc/config/app/security.yaml index d028ced..c8f2f05 100644 --- a/tests/_etc/config/app/security.yaml +++ b/tests/_etc/config/app/security.yaml @@ -22,15 +22,15 @@ security: members_fe: pattern: ^/(?!(admin)($|/)).*$ provider: members + entry_point: form_login form_login: login_path: members_user_security_login check_path: members_user_security_check - csrf_token_generator: security.csrf.token_manager + enable_csrf: true logout: path: members_user_security_logout invalidate_session: false target: / - anonymous: true user_checker: MembersBundle\Security\UserChecker access_control: @@ -41,9 +41,9 @@ security: - { path: ^/admin/login/(login|lostpassword|deeplink|csrf-token)$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/admin, roles: ROLE_PIMCORE_USER } - - { path: ^/_locale/members/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/_locale/members/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/_locale/members/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/_locale/members/login$, role: PUBLIC_ACCESS } + - { path: ^/_locale/members/register, role: PUBLIC_ACCESS } + - { path: ^/_locale/members/resetting, role: PUBLIC_ACCESS } role_hierarchy: ROLE_PIMCORE_ADMIN: [ROLE_PIMCORE_USER]