@@ -65,7 +65,7 @@ |
||
65 | 65 | /** |
66 | 66 | * Get the services provided by the provider. |
67 | 67 | * |
68 | - * @return array |
|
68 | + * @return string[] |
|
69 | 69 | */ |
70 | 70 | public function provides() { |
71 | 71 | return array('api-proxy.proxy'); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function boot() { |
34 | 34 | $this->publishes([ |
35 | - __DIR__.'/config/proxy.php' => config_path('proxy.php'), |
|
35 | + __DIR__ . '/config/proxy.php' => config_path('proxy.php'), |
|
36 | 36 | ]); |
37 | 37 | |
38 | 38 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return void |
53 | 53 | */ |
54 | 54 | public function registerApiProxy() { |
55 | - $this->app->bindShared('api-proxy.proxy', function ($app) { |
|
55 | + $this->app->bindShared('api-proxy.proxy', function($app) { |
|
56 | 56 | $params = $app['config']['proxy']; |
57 | 57 | $proxy = new Proxy($params); |
58 | 58 | return $proxy; |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | if (isset($parsedCookie)) { |
40 | 40 | $parsedCookie = json_decode($parsedCookie, true); |
41 | 41 | $this->validateCookie($parsedCookie); |
42 | - } |
|
43 | - else { |
|
42 | + } else { |
|
44 | 43 | if ($callMode !== ProxyAux::MODE_LOGIN) { |
45 | 44 | throw new CookieExpiredException(); |
46 | 45 | } |
@@ -56,8 +55,7 @@ discard block |
||
56 | 55 | public function createCookie(Array $content) { |
57 | 56 | if (!isset($this->info[CookieManager::COOKIE_TIME]) || $this->info[CookieManager::COOKIE_TIME] == null) { |
58 | 57 | $cookie = Cookie::forever($this->info[CookieManager::COOKIE_NAME], json_encode($content)); |
59 | - } |
|
60 | - else { |
|
58 | + } else { |
|
61 | 59 | $cookie = Cookie::make($this->info[CookieManager::COOKIE_NAME], json_encode($content), $this->info[CookieManager::COOKIE_TIME]); |
62 | 60 | } |
63 | 61 |
@@ -164,7 +164,7 @@ |
||
164 | 164 | if ($this->callMode === ProxyAux::MODE_TOKEN && $this->useHeader === true) { |
165 | 165 | $accessToken = ProxyAux::getQueryValue($inputs, ProxyAux::ACCESS_TOKEN); |
166 | 166 | $inputs = ProxyAux::removeQueryValue($inputs, ProxyAux::ACCESS_TOKEN); |
167 | - $options = array_add($options, 'headers', [ ProxyAux::HEADER_AUTH => 'Bearer ' . $accessToken ]); |
|
167 | + $options = array_add($options, 'headers', [ProxyAux::HEADER_AUTH => 'Bearer ' . $accessToken]); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | if ($method === 'GET') { |
@@ -68,8 +68,7 @@ discard block |
||
68 | 68 | if ($proxyResponse->getStatusCode() != 200) { |
69 | 69 | if (array_key_exists(ProxyAux::REFRESH_TOKEN, $parsedCookie)) { |
70 | 70 | $ret = $this->tryRefreshToken($inputs, $parsedCookie); |
71 | - } |
|
72 | - else { |
|
71 | + } else { |
|
73 | 72 | $cookie = $this->cookieManager->destroyCookie(); |
74 | 73 | } |
75 | 74 | } |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | |
112 | 111 | //Set a new cookie with updated access token and refresh token |
113 | 112 | $cookie = $this->cookieManager->createCookie($parsedCookie); |
114 | - } |
|
115 | - else { |
|
113 | + } else { |
|
116 | 114 | $cookie = $this->cookieManager->destroyCookie(); |
117 | 115 | } |
118 | 116 | |
@@ -169,8 +167,7 @@ discard block |
||
169 | 167 | |
170 | 168 | if ($method === 'GET') { |
171 | 169 | $options = array_add($options, 'query', $inputs); |
172 | - } |
|
173 | - else { |
|
170 | + } else { |
|
174 | 171 | $options = array_add($options, 'body', $inputs); |
175 | 172 | } |
176 | 173 | |
@@ -178,8 +175,7 @@ discard block |
||
178 | 175 | |
179 | 176 | try { |
180 | 177 | $response = $client->send($request); |
181 | - } |
|
182 | - catch (ClientException $ex) { |
|
178 | + } catch (ClientException $ex) { |
|
183 | 179 | $response = $ex->getResponse(); |
184 | 180 | } |
185 | 181 | |
@@ -200,8 +196,7 @@ discard block |
||
200 | 196 | } |
201 | 197 | $info['id'] = $clientId; |
202 | 198 | $info['secret'] = $this->clientSecrets[$clientId]; |
203 | - } |
|
204 | - else if (count($this->clientSecrets) >= 1) { |
|
199 | + } else if (count($this->clientSecrets) >= 1) { |
|
205 | 200 | $firstKey = key($this->clientSecrets); |
206 | 201 | $info['id'] = $firstKey; |
207 | 202 | $info['secret'] = $this->clientSecrets[$firstKey]; |
@@ -27,6 +27,10 @@ discard block |
||
27 | 27 | private $cookieManager = null; |
28 | 28 | private $useHeader = false; |
29 | 29 | |
30 | + /** |
|
31 | + * @param string $callMode |
|
32 | + * @param CookieManager $cookieManager |
|
33 | + */ |
|
30 | 34 | public function __construct($uri, $method, $clientSecrets, $callMode, $cookieManager) { |
31 | 35 | $this->uri = $uri; |
32 | 36 | $this->method = $method; |
@@ -136,7 +140,7 @@ discard block |
||
136 | 140 | } |
137 | 141 | |
138 | 142 | /** |
139 | - * @param $response |
|
143 | + * @param \GuzzleHttp\Message\ResponseInterface $response |
|
140 | 144 | * @return mixed |
141 | 145 | */ |
142 | 146 | private function getResponseContent($response) { |
@@ -155,7 +159,7 @@ discard block |
||
155 | 159 | * @param $method |
156 | 160 | * @param $uriVal |
157 | 161 | * @param $inputs |
158 | - * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|mixed|null |
|
162 | + * @return \GuzzleHttp\Message\ResponseInterface |
|
159 | 163 | */ |
160 | 164 | private function sendGuzzleRequest($method, $uriVal, $inputs) { |
161 | 165 | $options = array(); |
@@ -18,8 +18,8 @@ |
||
18 | 18 | class ProxyMissingParamException extends ProxyException { |
19 | 19 | |
20 | 20 | public function __construct($parameter) { |
21 | - $this->httpStatusCode = 400; |
|
22 | - $this->errorType = 'proxy_missing_param'; |
|
21 | + $this->httpStatusCode = 400; |
|
22 | + $this->errorType = 'proxy_missing_param'; |
|
23 | 23 | parent::__construct(\Lang::get('api-proxy-laravel::messages.proxy_missing_param', array('param' => $parameter))); |
24 | 24 | } |
25 | 25 |
@@ -18,8 +18,8 @@ |
||
18 | 18 | class CookieInvalidException extends ProxyException { |
19 | 19 | |
20 | 20 | public function __construct($parameter) { |
21 | - $this->httpStatusCode = 500; |
|
22 | - $this->errorType = 'proxy_cookie_invalid'; |
|
21 | + $this->httpStatusCode = 500; |
|
22 | + $this->errorType = 'proxy_cookie_invalid'; |
|
23 | 23 | parent::__construct(\Lang::get('api-proxy-laravel::messages.proxy_cookie_invalid', array('param' => $parameter))); |
24 | 24 | } |
25 | 25 |
@@ -18,8 +18,8 @@ |
||
18 | 18 | class MissingClientSecretException extends ProxyException { |
19 | 19 | |
20 | 20 | public function __construct($parameter) { |
21 | - $this->httpStatusCode = 500; |
|
22 | - $this->errorType = 'missing_client_secret'; |
|
21 | + $this->httpStatusCode = 500; |
|
22 | + $this->errorType = 'missing_client_secret'; |
|
23 | 23 | parent::__construct(\Lang::get('api-proxy-laravel::messages.missing_client_secret', array('client' => $parameter))); |
24 | 24 | } |
25 | 25 |
@@ -18,8 +18,8 @@ |
||
18 | 18 | class CookieExpiredException extends ProxyException { |
19 | 19 | |
20 | 20 | public function __construct() { |
21 | - $this->httpStatusCode = 403; |
|
22 | - $this->errorType = 'proxy_cookie_expired'; |
|
21 | + $this->httpStatusCode = 403; |
|
22 | + $this->errorType = 'proxy_cookie_expired'; |
|
23 | 23 | parent::__construct(\Lang::get('api-proxy-laravel::messages.proxy_cookie_expired')); |
24 | 24 | } |
25 | 25 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | //Create the new request |
76 | - $requestManager = new RequestManager($this->uri, $method, $this->clientSecrets, $this->callMode, $this->cookieManager); |
|
76 | + $requestManager = new RequestManager($this->uri, $method, $this->clientSecrets, $this->callMode, $this->cookieManager); |
|
77 | 77 | if ($this->useHeader) { |
78 | 78 | $requestManager->enableHeader(); |
79 | 79 | } |
@@ -95,8 +95,7 @@ |
||
95 | 95 | if ($grantType === ProxyAux::PASSWORD_GRANT) { |
96 | 96 | $mode = ProxyAux::MODE_LOGIN; |
97 | 97 | } |
98 | - } |
|
99 | - else if (isset($skip) && strtolower($skip) === 'true') { |
|
98 | + } else if (isset($skip) && strtolower($skip) === 'true') { |
|
100 | 99 | $mode = ProxyAux::MODE_SKIP; |
101 | 100 | } |
102 | 101 |
@@ -11,9 +11,9 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | return array( |
14 | - 'access_token_ok' => 'Access token retrieved successfully', |
|
15 | - 'proxy_missing_param' => 'Missing mandatory parameter <b>:param</b> in the request call', |
|
16 | - 'missing_client_secret' => 'Missing secret key for client id <b>:client</b>', |
|
17 | - 'proxy_cookie_expired' => 'Cookie expired or not found. Return to the login form.', |
|
18 | - 'proxy_cookie_invalid' => 'Cookie format not valid. Missing attribute <b>:param</b>.' |
|
14 | + 'access_token_ok' => 'Access token retrieved successfully', |
|
15 | + 'proxy_missing_param' => 'Missing mandatory parameter <b>:param</b> in the request call', |
|
16 | + 'missing_client_secret' => 'Missing secret key for client id <b>:client</b>', |
|
17 | + 'proxy_cookie_expired' => 'Cookie expired or not found. Return to the login form.', |
|
18 | + 'proxy_cookie_invalid' => 'Cookie format not valid. Missing attribute <b>:param</b>.' |
|
19 | 19 | ); |
20 | 20 | \ No newline at end of file |