|
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 IpUserAuthenticationStatus |
|
33
|
|
|
* |
|
34
|
|
|
* @package AOE\AoeIpauth\Report |
|
35
|
|
|
*/ |
|
36
|
|
|
class IpUserAuthenticationStatus 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->analyseUses($reports); |
|
64
|
|
|
|
|
65
|
|
|
return $reports; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Analyses users |
|
70
|
|
|
* |
|
71
|
|
|
* @param array $reports |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function analyseUses(&$reports) |
|
75
|
|
|
{ |
|
76
|
|
|
/** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ |
|
77
|
|
|
$service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); |
|
78
|
|
|
|
|
79
|
|
|
$users = $service->findAllUsersWithIpAuthentication(); |
|
80
|
|
|
|
|
81
|
|
|
if (empty($users)) { |
|
82
|
|
|
// Message that no user group has IP authentication |
|
83
|
|
|
$reports[] = $this->objectManager->get( |
|
84
|
|
|
'TYPO3\\CMS\\Reports\\Status', |
|
85
|
|
|
'IP User Authentication', |
|
86
|
|
|
'No users with IP authentication found', |
|
87
|
|
|
'No users 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
|
|
|
$userInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; |
|
95
|
|
|
$userInfo .= '<thead><tr><th style="padding-bottom: 10px;">User</th><th>IP/Range</th></tr></thead>'; |
|
96
|
|
|
$userInfo .= '<tbody>'; |
|
97
|
|
|
|
|
98
|
|
|
foreach ($users as $user) { |
|
99
|
|
|
$uid = $user['uid']; |
|
100
|
|
|
$ips = implode(', ', $user['tx_aoeipauth_ip']); |
|
101
|
|
|
|
|
102
|
|
|
$fullRecord = BackendUtility::getRecord('fe_users', $uid); |
|
103
|
|
|
$title = $fullRecord['username']; |
|
104
|
|
|
|
|
105
|
|
|
$button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . |
|
106
|
|
|
$thisUrl . '&edit[fe_users][' . $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
|
|
|
$userInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
$userInfo .= '</tbody>'; |
|
114
|
|
|
$userInfo .= '</table>'; |
|
115
|
|
|
|
|
116
|
|
|
$userInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; |
|
117
|
|
|
|
|
118
|
|
|
$reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', |
|
119
|
|
|
'IP User Authentication', |
|
120
|
|
|
'Some users with automatic IP authentication were found.', |
|
121
|
|
|
$userInfo, |
|
122
|
|
|
\TYPO3\CMS\Reports\Status::OK |
|
123
|
|
|
); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|