__getWWWAuthenticateString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Aoe\Restler\Controller;
4
5
/***************************************************************
6
 *  Copyright notice
7
 *
8
 *  (c) 2024 AOE GmbH <[email protected]>
9
 *
10
 *  All rights reserved
11
 *
12
 *  This script is part of the TYPO3 project. The TYPO3 project is
13
 *  free software; you can redistribute it and/or modify
14
 *  it under the terms of the GNU General Public License as published by
15
 *  the Free Software Foundation; either version 3 of the License, or
16
 *  (at your option) any later version.
17
 *
18
 *  The GNU General Public License can be found at
19
 *  http://www.gnu.org/copyleft/gpl.html.
20
 *
21
 *  This script is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 *  GNU General Public License for more details.
25
 *
26
 *  This copyright notice MUST APPEAR in all copies of the script!
27
 ***************************************************************/
28
29
use Luracast\Restler\Explorer\v2\Explorer;
30
use Luracast\Restler\iAuthenticate;
31
use Luracast\Restler\Restler;
32
use Luracast\Restler\Scope;
33
34
/**
35
 * This class checks, if client is allowed to access the API-online-documentation
36
 * This class is very simple, it doesn't check any API-keys! If you have the need to
37
 * support (different) API-keys, you must write your own authentication-controller!
38
 * @see http://restler3.luracast.com/examples/_010_access_control/readme.html
39
 */
40
class ExplorerAuthenticationController implements iAuthenticate
41
{
42
    /**
43
     * Instance of Restler class injected at runtime.
44
     *
45
     * @var Restler
46
     */
47
    public $restler;
48
49
    /**
50
     * initialize controller
51
     */
52 3
    public function __construct()
53
    {
54 3
        $this->restler = Scope::get('Restler');
55 3
    }
56
57
    /**
58
     * This method checks, if client is allowed to access the API-online-documentation
59
     *
60
     * @return boolean
61
     */
62
    // phpcs:ignore
63 2
    public function __isAllowed()
64
    {
65 2
        // this controller is not responsible for the authentication
66
        return $this->restler->apiMethodInfo->className === Explorer::class;
67 1
    }
68
69 1
    /**
70
     * @return string
71
     * @see \Luracast\Restler\iAuthenticate
72
     */
73
    // phpcs:ignore
74
    public function __getWWWAuthenticateString()
75
    {
76
        return 'Query name="api_key"';
77 1
    }
78
}
79