1 | <?php |
||
36 | class Authentication extends AbstractAuthenticationService |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * @var \AOE\AoeIpauth\Service\IpMatchingService |
||
41 | */ |
||
42 | protected $ipMatchingService = null; |
||
43 | |||
44 | /** |
||
45 | * @var \AOE\AoeIpauth\Domain\Service\FeEntityService |
||
46 | */ |
||
47 | protected $feEntityService = null; |
||
48 | |||
49 | /** |
||
50 | * @var \AOE\AoeIpauth\Domain\Service\IpService |
||
51 | */ |
||
52 | protected $ipService = null; |
||
53 | |||
54 | /** |
||
55 | * Makes sure the TCA is readable, necessary for enableFields to work |
||
56 | * Is de-facto called when using the Preview BE Module |
||
57 | * |
||
58 | * @return void |
||
59 | 6 | */ |
|
60 | protected function safeguardContext() |
||
61 | 6 | { |
|
62 | 6 | if (!isset($GLOBALS['TSFE'])) { |
|
63 | return; |
||
64 | } |
||
65 | |||
66 | if (!isset($GLOBALS['TCA'][\AOE\AoeIpauth\Domain\Service\FeEntityService::TABLE_USER])) { |
||
67 | if (empty($GLOBALS['TSFE']->sys_page)) { |
||
68 | $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); |
||
69 | } |
||
70 | if (version_compare(TYPO3_version, '7.0.0', '<')) { |
||
71 | $GLOBALS['TSFE']->getCompressedTCarray(); |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Gets the user automatically |
||
78 | * |
||
79 | * @return bool |
||
80 | 3 | */ |
|
81 | public function getUser() |
||
82 | { |
||
83 | 3 | // Do not respond to non-fe users and login attempts |
|
84 | if ('getUserFE' != $this->mode || 'login' == $this->login['status']) { |
||
85 | return false; |
||
86 | } |
||
87 | 3 | ||
88 | $this->safeguardContext(); |
||
89 | 3 | ||
90 | 3 | $clientIp = $this->authInfo['REMOTE_ADDR']; |
|
91 | $ipAuthenticatedUsers = $this->findAllUsersByIpAuthentication($clientIp); |
||
92 | 3 | if (empty($ipAuthenticatedUsers)) { |
|
93 | 1 | return false; |
|
94 | } |
||
95 | |||
96 | 2 | $user = array_pop($ipAuthenticatedUsers); |
|
97 | 2 | return $user; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Authenticate a user |
||
102 | * Return 200 if the IP is right. |
||
103 | * This means that no more checks are needed. |
||
104 | * Otherwise authentication may fail because we may don't have a password. |
||
105 | * |
||
106 | * @param array Data of user. |
||
107 | * @return int |
||
108 | */ |
||
109 | 2 | public function authUser($user) |
|
134 | |||
135 | /** |
||
136 | * Get the group list |
||
137 | * |
||
138 | * @param string $user |
||
139 | * @param array $knownGroups |
||
140 | * @return array |
||
141 | */ |
||
142 | 1 | public function getGroups($user, $knownGroups) |
|
160 | |||
161 | /** |
||
162 | * Returns TRUE if the userId's associated IPs match the client IP |
||
163 | * |
||
164 | * @param int $userId |
||
165 | * @param string $clientIp |
||
166 | * @return bool |
||
167 | */ |
||
168 | protected function doesCurrentUsersIpMatch($userId, $clientIp) |
||
181 | |||
182 | /** |
||
183 | * Finds all users with IP authentication enabled |
||
184 | * |
||
185 | * @param string $ip |
||
186 | * @return array |
||
187 | */ |
||
188 | protected function findAllUsersByIpAuthentication($ip) |
||
193 | |||
194 | /** |
||
195 | * Finds all groups with IP authentication enabled |
||
196 | * |
||
197 | * @param string $ip |
||
198 | * @return array |
||
199 | */ |
||
200 | protected function findAllGroupsByIpAuthentication($ip) |
||
205 | |||
206 | /** |
||
207 | * @return \AOE\AoeIpauth\Domain\Service\FeEntityService |
||
208 | */ |
||
209 | protected function getFeEntityService() |
||
216 | |||
217 | /** |
||
218 | * @return \AOE\AoeIpauth\Domain\Service\IpService |
||
219 | */ |
||
220 | protected function getIpService() |
||
227 | |||
228 | /** |
||
229 | * @return \AOE\AoeIpauth\Service\IpMatchingService |
||
230 | */ |
||
231 | protected function getIpMatchingService() |
||
238 | } |
||
239 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.