1
|
|
|
<?php |
2
|
|
|
namespace AOE\AoeIpauth\Report; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2019 AOE GmbH <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
29
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class IpGroupAuthenticationStatus |
33
|
|
|
* |
34
|
|
|
* @package AOE\AoeIpauth\Report |
35
|
|
|
*/ |
36
|
|
|
class IpGroupAuthenticationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \TYPO3\CMS\Extbase\Object\ObjectManager |
41
|
|
|
*/ |
42
|
|
|
protected $objectManager; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $myIp; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @see typo3/sysext/reports/interfaces/tx_reports_StatusProvider::getStatus() |
52
|
|
|
*/ |
53
|
|
|
public function getStatus() |
54
|
|
|
{ |
55
|
|
|
$reports = array(); |
56
|
|
|
|
57
|
|
|
// create object manager |
58
|
|
|
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); |
59
|
|
|
$this->objectManager = clone $objectManager; |
60
|
|
|
|
61
|
|
|
$this->myIp = GeneralUtility::getIndpEnv('REMOTE_ADDR'); |
62
|
|
|
|
63
|
|
|
$this->analyseUserGroups($reports); |
64
|
|
|
|
65
|
|
|
return $reports; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Analyses user groups |
70
|
|
|
* |
71
|
|
|
* @param array $reports |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
protected function analyseUserGroups(&$reports) |
75
|
|
|
{ |
76
|
|
|
/** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ |
77
|
|
|
$service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); |
78
|
|
|
|
79
|
|
|
$userGroups = $service->findAllGroupsWithIpAuthentication(); |
80
|
|
|
|
81
|
|
|
if (empty($userGroups)) { |
82
|
|
|
// Message that no user group has IP authentication |
83
|
|
|
$reports[] = $this->objectManager->get( |
84
|
|
|
'TYPO3\\CMS\\Reports\\Status', |
85
|
|
|
'IP Usergroup Authentication', |
86
|
|
|
'No user groups with IP authentication found', |
87
|
|
|
'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' . |
88
|
|
|
'Your current IP is: <strong>' . $this->myIp . '</strong>', |
89
|
|
|
\TYPO3\CMS\Reports\Status::INFO |
90
|
|
|
); |
91
|
|
|
} else { |
92
|
|
|
$thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); |
93
|
|
|
|
94
|
|
|
$userGroupInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; |
95
|
|
|
$userGroupInfo .= '<thead><tr><th style="padding-bottom: 10px;">User Group</th><th>IP/Range</th></tr></thead>'; |
96
|
|
|
$userGroupInfo .= '<tbody>'; |
97
|
|
|
|
98
|
|
|
foreach ($userGroups as $group) { |
99
|
|
|
$uid = $group['uid']; |
100
|
|
|
$ips = implode(', ', $group['tx_aoeipauth_ip']); |
101
|
|
|
|
102
|
|
|
$fullRecord = BackendUtility::getRecord('fe_groups', $uid); |
103
|
|
|
$title = $fullRecord['title']; |
104
|
|
|
|
105
|
|
|
$button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . $thisUrl . |
106
|
|
|
'&edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . |
107
|
|
|
'<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open"> </span>' . |
108
|
|
|
'</a>'; |
109
|
|
|
|
110
|
|
|
$userGroupInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
$userGroupInfo .= '</tbody>'; |
114
|
|
|
$userGroupInfo .= '</table>'; |
115
|
|
|
|
116
|
|
|
$userGroupInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; |
117
|
|
|
|
118
|
|
|
$reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', |
119
|
|
|
'IP Usergroup Authentication', |
120
|
|
|
'Some groups with automatic IP authentication were found.', |
121
|
|
|
$userGroupInfo, |
122
|
|
|
\TYPO3\CMS\Reports\Status::OK |
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|