Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make aoe_ipauth compatible with TYPO3 11 #63

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Domain/Service/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\SingletonInterface;
use AOE\AoeIpauth\Utility\EnableFieldsUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -34,7 +34,7 @@
*
* @package AOE\AoeIpauth\Domain\Service
*/
class ContentService implements \TYPO3\CMS\Core\SingletonInterface
class ContentService implements SingletonInterface
{

const CONTENT_TABLE = 'tt_content';
Expand Down
15 changes: 8 additions & 7 deletions Classes/Domain/Service/FeEntityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\SingletonInterface;
use AOE\AoeIpauth\Service\IpMatchingService;
use AOE\AoeIpauth\Utility\EnableFieldsUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -34,19 +35,19 @@
*
* @package AOE\AoeIpauth\Domain\Service
*/
class FeEntityService implements \TYPO3\CMS\Core\SingletonInterface
class FeEntityService implements SingletonInterface
{

const TABLE_GROUP = 'fe_groups';
const TABLE_USER = 'fe_users';

/**
* @var \AOE\AoeIpauth\Domain\Service\IpService
* @var IpService
*/
protected $ipService = null;

/**
* @var \AOE\AoeIpauth\Service\IpMatchingService
* @var IpMatchingService
*/
protected $ipMatchingService = null;

Expand Down Expand Up @@ -144,7 +145,7 @@ protected function findEntitiesWithIpAuthentication($table)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$entities = $queryBuilder->select('uid','pid')
$entities = $queryBuilder->select('*')
->from($table)
->where(
$queryBuilder->expr()->gt('tx_aoeipauth_ip', '0' . EnableFieldsUtility::enableFields($table))
Expand Down Expand Up @@ -182,7 +183,7 @@ protected function findEntitiesWithIpAuthentication($table)
}

/**
* @return \AOE\AoeIpauth\Domain\Service\IpService
* @return IpService
*/
protected function getIpService()
{
Expand All @@ -193,7 +194,7 @@ protected function getIpService()
}

/**
* @return \AOE\AoeIpauth\Service\IpMatchingService
* @return IpMatchingService
*/
protected function getIpMatchingService()
{
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Service/IpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\SingletonInterface;
use AOE\AoeIpauth\Utility\EnableFieldsUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -34,7 +34,7 @@
*
* @package AOE\AoeIpauth\Domain\Service
*/
class IpService implements \TYPO3\CMS\Core\SingletonInterface
class IpService implements SingletonInterface
{

const TABLE = 'tx_aoeipauth_domain_model_ip';
Expand Down
23 changes: 23 additions & 0 deletions Classes/EventListener/ModifyFeGroups.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace AOE\AoeIpauth\EventListener;

use AOE\AoeIpauth\Domain\Service\FeEntityService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Authentication\ModifyResolvedFrontendGroupsEvent;

class ModifyFeGroups
{
public function __invoke(ModifyResolvedFrontendGroupsEvent $event): void
{
$ip = GeneralUtility::getIndpEnv('REMOTE_ADDR');
$feEntityService = GeneralUtility::makeInstance(FeEntityService::class);
$groups = $feEntityService->findAllGroupsAuthenticatedByIp($ip);
if (!empty($groups)) {
$newGroups = array_merge($event->getGroups(), $groups);
$event->setGroups($newGroups);
}
}
}
6 changes: 3 additions & 3 deletions Classes/Hooks/Tcemain.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\Messaging\AbstractMessage;
use AOE\AoeIpauth\Service\IpMatchingService;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Messaging\FlashMessage;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie
return;
}

/** @var \AOE\AoeIpauth\Service\IpMatchingService $ipMatchingService */
/** @var IpMatchingService $ipMatchingService */
$ipMatchingService = $this->objectManager->get(IpMatchingService::class);

$potentialIp = $fieldArray['ip'];
Expand Down Expand Up @@ -107,7 +107,7 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie
'The new IP (<strong>' . $potentialIp . '</strong>) ' .
'you entered was neither a valid IP nor a valid range. ' .
'The change was rejected.',
FlashMessage::ERROR
AbstractMessage::ERROR
);
}

Expand Down
15 changes: 9 additions & 6 deletions Classes/Report/IpGroupAuthenticationStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Reports\StatusProviderInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use AOE\AoeIpauth\Domain\Service\FeEntityService;
use TYPO3\CMS\Reports\Status;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -33,11 +36,11 @@
*
* @package AOE\AoeIpauth\Report
*/
class IpGroupAuthenticationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
class IpGroupAuthenticationStatus implements StatusProviderInterface
{

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
* @var ObjectManager
*/
protected $objectManager;

Expand Down Expand Up @@ -73,7 +76,7 @@ public function getStatus()
*/
protected function analyseUserGroups(&$reports)
{
/** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */
/** @var FeEntityService $service */
$service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService');

$userGroups = $service->findAllGroupsWithIpAuthentication();
Expand All @@ -86,7 +89,7 @@ protected function analyseUserGroups(&$reports)
'No user groups with IP authentication found',
'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' .
'Your current IP is: <strong>' . $this->myIp . '</strong>',
\TYPO3\CMS\Reports\Status::INFO
Status::INFO
);
} else {
$thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
Expand Down Expand Up @@ -119,7 +122,7 @@ protected function analyseUserGroups(&$reports)
'IP Usergroup Authentication',
'Some groups with automatic IP authentication were found.',
$userGroupInfo,
\TYPO3\CMS\Reports\Status::OK
Status::OK
);
}
}
Expand Down
15 changes: 9 additions & 6 deletions Classes/Report/IpUserAuthenticationStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Reports\StatusProviderInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use AOE\AoeIpauth\Domain\Service\FeEntityService;
use TYPO3\CMS\Reports\Status;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -33,11 +36,11 @@
*
* @package AOE\AoeIpauth\Report
*/
class IpUserAuthenticationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
class IpUserAuthenticationStatus implements StatusProviderInterface
{

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
* @var ObjectManager
*/
protected $objectManager;

Expand Down Expand Up @@ -73,7 +76,7 @@ public function getStatus()
*/
protected function analyseUses(&$reports)
{
/** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */
/** @var FeEntityService $service */
$service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService');

$users = $service->findAllUsersWithIpAuthentication();
Expand All @@ -86,7 +89,7 @@ protected function analyseUses(&$reports)
'No users with IP authentication found',
'No users were found anywhere that are active and have an automatic IP authentication enabled.' .
'Your current IP is: <strong>' . $this->myIp . '</strong>',
\TYPO3\CMS\Reports\Status::INFO
Status::INFO
);
} else {
$thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
Expand Down Expand Up @@ -119,7 +122,7 @@ protected function analyseUses(&$reports)
'IP User Authentication',
'Some users with automatic IP authentication were found.',
$userInfo,
\TYPO3\CMS\Reports\Status::OK
Status::OK
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Service/IpMatchingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class IpMatchingService
*
* @package AOE\AoeIpauth\Service
*/
class IpMatchingService implements \TYPO3\CMS\Core\SingletonInterface
class IpMatchingService implements SingletonInterface
{

const NORMAL_IP_TYPE = 0;
Expand Down
Loading
Loading