forked from CakeDC/cakephp-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
149 lines (141 loc) · 5.17 KB
/
api.php
File metadata and controls
149 lines (141 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* Copyright 2016 - 2019, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2016 - 2019, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
use Authentication\AuthenticationService;
use Authentication\Middleware\AuthenticationMiddleware;
use Authorization\Middleware\AuthorizationMiddleware;
use Authorization\Middleware\RequestAuthorizationMiddleware;
use Cake\Http\Middleware\BodyParserMiddleware;
use CakeDC\Api\Middleware\ParseApiRequestMiddleware;
use CakeDC\Api\Middleware\ProcessApiRequestMiddleware;
use CakeDC\Api\ApiInitializer;
return [
'Api' => [
// if service class is not defined we use crud fallback service
'ServiceFallback' => '\\CakeDC\\Api\\Service\\FallbackService',
// response rendered as JSend
'renderer' => 'CakeDC/Api.JSend',
// Data parse from cakephp request object
'parser' => 'CakeDC/Api.Form',
//routes inflector: specify underscore, dasherize, or false for neither/no inflection
'routesInflectorMethod' => false,
// version is not used
'useVersioning' => false,
'versionPrefix' => 'v',
'serviceLookupPlugins' => null,
'lookupMode' => 'underscore',
'2fa' => [
'enabled' => false,
],
'OneTimePasswordAuthenticator' => [
'login' => false,
'checker' => \CakeDC\Api\Service\Auth\TwoFactorAuthentication\DefaultOneTimePasswordAuthenticationChecker::class,
],
'Webauthn2fa' => [
'checker' => \CakeDC\Api\Service\Auth\TwoFactorAuthentication\DefaultWebauthn2fAuthenticationChecker::class,
'localhost' => [
'enabled' => false,
'appName' => 'apilocal',
'id' => 'localhost',
],
],
// auth permission uses require auth strategy
'Auth' => [
'Crud' => [
'default' => 'auth'
],
],
'Jwt' => [
'enabled' => false,
'AccessToken' => [
'lifetime' => 600,
'secret' => '',
],
'RefreshToken' => [
'lifetime' => 14 * 86400,
'secret' => '',
],
],
'Middleware' => [
'authentication' => [
'class' => AuthenticationMiddleware::class,
'request' => ApiInitializer::class,
'method' => 'getAuthenticationService',
],
'bodyParser' => [
'class' => BodyParserMiddleware::class,
],
'apiParser' => [
'class' => ParseApiRequestMiddleware::class,
],
'apiAuthorize' => [
'class' => AuthorizationMiddleware::class,
'request' => ApiInitializer::class,
'params' => [
'unauthorizedHandler' => 'CakeDC/Api.ApiException',
],
],
'apiAuthorizeRequest' => [
'class' => RequestAuthorizationMiddleware::class,
],
'apiProcessor' => [
'class' => ProcessApiRequestMiddleware::class,
],
],
'Service' => [
'default' => [
'options' => [],
'Action' => [
'default' => [
//auth configuration
'Auth' => [
'allow' => '*', // PUBLIC ACCESS for all API endpoints, remove this line to secure
'authorize' => [
'CakeDC/Api.Crud' => []
],
'authenticate' => [
'CakeDC/Api.Token' => [
'require_ssl' => false,
]
],
],
// default app extensions
'Extension' => [
// allow request from other domains
'CakeDC/Api.Cors',
// enable sort
'CakeDC/Api.Sort',
// load Hateoas
'CakeDC/Api.CrudHateoas',
// enable relations
'CakeDC/Api.CrudRelations',
]
],
// all index actions configuration
'Index' => [
'Extension' => [
// enable pagination for index actions
'CakeDC/Api.Paginate',
],
],
],
],
],
'Log' => [
'className' => 'File',
'scopes' => ['api'],
'levels' => ['error', 'info'],
'file' => 'api.log',
],
'Flysystem' => [
'expire' => '+1 day'
]
]
];