1 | <?php |
||||||
2 | defined('BASEPATH') OR exit('No direct script access allowed'); |
||||||
3 | |||||||
4 | use PHPUnit\Framework\Assert as Assert; |
||||||
0 ignored issues
–
show
|
|||||||
5 | |||||||
6 | $config['api_key_header'] = "X-API-KEY"; |
||||||
7 | |||||||
8 | $config['uri_auth'] = [ |
||||||
9 | 'basic/auth' => [RESTAuth::BASIC] |
||||||
10 | ]; |
||||||
11 | |||||||
12 | $config['auth_callbacks'] = [ |
||||||
13 | |||||||
14 | RESTAuth::CUSTOM('X-APP-ID') => function (&$context, $value):bool { |
||||||
0 ignored issues
–
show
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$context is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
15 | return true; |
||||||
16 | }, |
||||||
17 | |||||||
18 | RESTAuth::CUSTOM('X-DEVICE-ID') => function (&$context, $value):bool { |
||||||
0 ignored issues
–
show
The parameter
$context is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$value is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
19 | return true; |
||||||
20 | }, |
||||||
21 | |||||||
22 | RESTAuth::BEARER => function (&$context, $token):bool { |
||||||
0 ignored issues
–
show
The parameter
$token is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$context is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
23 | return true; |
||||||
24 | }, |
||||||
25 | |||||||
26 | RESTAuth::OAUTH2 => function (&$context, $token):bool { |
||||||
0 ignored issues
–
show
The parameter
$context is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
The parameter
$token is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
27 | return true; |
||||||
28 | } |
||||||
29 | |||||||
30 | ]; |
||||||
31 | |||||||
32 | $config['response_callbacks'] = [ |
||||||
33 | |||||||
34 | RESTResponse::BAD_REQUEST => function(&$auth):void { |
||||||
0 ignored issues
–
show
The parameter
$auth is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
35 | echo(json_encode([ |
||||||
36 | 'error' => 'Bad Request' |
||||||
37 | ])); |
||||||
38 | }, |
||||||
39 | |||||||
40 | RESTResponse::UN_AUTHORIZED => function(&$auth):void { |
||||||
41 | $ci =& get_instance(); |
||||||
0 ignored issues
–
show
The function
get_instance was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
42 | Assert::assertTrue(uri_string() == $ci->config->item('expected_uri')&& $auth == $ci->config->item('expected_auth')); |
||||||
0 ignored issues
–
show
The function
uri_string was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
43 | }, |
||||||
44 | |||||||
45 | RESTResponse::NOT_ACCEPTABLE => function(&$auth):void { |
||||||
0 ignored issues
–
show
The parameter
$auth is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
Loading history...
|
|||||||
46 | echo (json_encode([ |
||||||
47 | 'error' => 'Not Acceptable' |
||||||
48 | ])); |
||||||
49 | }, |
||||||
50 | |||||||
51 | RESTResponse::NOT_IMPLEMENTED => function(&$auth): void { |
||||||
52 | echo (json_encode([ |
||||||
53 | 'error' => "$auth Authentication not implemented" |
||||||
54 | ])); |
||||||
55 | } |
||||||
56 | ]; |
||||||
57 | |||||||
58 | $config['api_limiter'] = [ |
||||||
59 | 'api_limiter' => true, |
||||||
60 | 'per_hour' => 100, |
||||||
61 | 'show_header' => true, |
||||||
62 | 'header_prefix' => 'X-RateLimit-', |
||||||
63 | 'limit_by_ip' => true, |
||||||
64 | 'ip_per_hour' => 50, |
||||||
65 | 'whitelist' => [ |
||||||
66 | '127.0.0.1', |
||||||
67 | '::1' |
||||||
68 | ] |
||||||
69 | ]; |
||||||
70 | |||||||
71 | $config['basic_auth'] = [ |
||||||
72 | 'users_table' => 'users', |
||||||
73 | 'id_column' => 'id', |
||||||
74 | 'email_column' => 'email', |
||||||
75 | 'password_column' => 'password', |
||||||
76 | 'username_column' => 'username' |
||||||
77 | ]; |
||||||
78 | |||||||
79 | $config['api_key_auth'] = [ |
||||||
80 | 'api_key_table' => 'api_keys', |
||||||
81 | 'api_key_column' => 'api_key', |
||||||
82 | 'api_key_limit_column' => '_limit', |
||||||
83 | ]; |
||||||
84 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths