1
|
|
|
<?php |
2
|
|
|
namespace AOE\Crawler\Service; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2016 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\Sv\AbstractAuthenticationService; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class AuthenticationService |
32
|
|
|
* |
33
|
|
|
* @package AOE\Crawler\Service |
34
|
|
|
*/ |
35
|
|
|
class AuthenticationService extends AbstractAuthenticationService |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Find user by HTTP_X_T3CRAWLER Header |
40
|
|
|
* |
41
|
|
|
* @return mixed user array or false |
42
|
|
|
*/ |
43
|
|
|
public function getUser() |
44
|
|
|
{ |
45
|
|
|
$user = false; |
46
|
|
|
if (isset($_SERVER['HTTP_X_T3CRAWLER'])) { |
47
|
|
|
$user = $this->fetchUserRecord('_cli_crawler'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $user; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Authenticate user |
55
|
|
|
* |
56
|
|
|
* @param array user |
57
|
|
|
* |
58
|
|
|
* @return int 100="don't know", 0="no", 200="yes" |
59
|
|
|
*/ |
60
|
|
|
public function authUser(array $user) |
61
|
|
|
{ |
62
|
|
|
if (isset($_SERVER['HTTP_X_T3CRAWLER'])) { |
63
|
|
|
return ($user['username'] == '_cli_crawler') ? 200 : 100; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return 100; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|