|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package cellcote/laravel-proxify |
|
5
|
|
|
* @author Michele Andreoli <michi.andreoli[at]gmail.com> |
|
6
|
|
|
* @copyright Copyright (c) Michele Andreoli |
|
7
|
|
|
* @author Rik Schreurs <rik.schreurs[at]mail.com> |
|
8
|
|
|
* @copyright Copyright (c) Rik Schreurs |
|
9
|
|
|
* @license http://mit-license.org/ |
|
10
|
|
|
* @link https://github.com/cellcote/laravel-proxify |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Cellcote\LaravelProxify; |
|
14
|
|
|
|
|
15
|
|
|
class ProxyAux { |
|
16
|
|
|
|
|
17
|
|
|
const GRANT_TYPE = 'grant_type'; |
|
18
|
|
|
const ACCESS_TOKEN = 'access_token'; |
|
19
|
|
|
const TOKEN_TYPE = 'token_type'; |
|
20
|
|
|
const TOKEN_EXPIRES = 'expires_in'; |
|
21
|
|
|
const REFRESH_TOKEN = 'refresh_token'; |
|
22
|
|
|
const CLIENT_ID = 'client_id'; |
|
23
|
|
|
const CLIENT_SECRET = 'client_secret'; |
|
24
|
|
|
const COOKIE_URI = 'uri'; |
|
25
|
|
|
const COOKIE_METHOD = 'method'; |
|
26
|
|
|
const PASSWORD_GRANT = 'password'; |
|
27
|
|
|
const HEADER_AUTH = "Authorization"; |
|
28
|
|
|
const MODE_SKIP = '0'; |
|
29
|
|
|
const MODE_LOGIN = '1'; |
|
30
|
|
|
const MODE_TOKEN = '2'; |
|
31
|
|
|
const MODE_REFRESH = '3'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param $array |
|
35
|
|
|
* @param $key |
|
36
|
|
|
* @param $value |
|
37
|
|
|
* @return array |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function addQueryValue($array, $key, $value) { |
|
40
|
|
|
if (array_key_exists($key, $array)) { |
|
41
|
|
|
unset($array[$key]); |
|
42
|
|
|
} |
|
43
|
|
|
return array_add($array, $key, $value); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param $array |
|
48
|
|
|
* @param $key |
|
49
|
|
|
* @return null |
|
50
|
|
|
*/ |
|
51
|
|
|
public static function getQueryValue($array, $key) { |
|
52
|
|
|
if (array_key_exists($key, $array)) { |
|
53
|
|
|
return $array[$key]; |
|
54
|
|
|
} |
|
55
|
|
|
return null; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param $array |
|
60
|
|
|
* @param $key |
|
61
|
|
|
* @return array |
|
62
|
|
|
*/ |
|
63
|
|
|
public static function removeQueryValue($array, $key) { |
|
64
|
|
|
if (array_key_exists($key, $array)) { |
|
65
|
|
|
unset($array[$key]); |
|
66
|
|
|
} |
|
67
|
|
|
return $array; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|