@@ -15,7 +15,7 @@ |
||
15 | 15 | * |
16 | 16 | * @link https://tools.ietf.org/html/rfc6749#section-10.4 |
17 | 17 | */ |
18 | -interface TokenRefresh{ |
|
18 | +interface TokenRefresh { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Tries to refresh an existing AccessToken with an associated refresh token and returns a fresh AccessToken. |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * |
16 | 16 | * @link https://tools.ietf.org/html/rfc6749#section-4.4 |
17 | 17 | */ |
18 | -interface ClientCredentials{ |
|
18 | +interface ClientCredentials { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Obtains an OAuth2 client credentials token and returns an AccessToken |
@@ -13,7 +13,7 @@ |
||
13 | 13 | /** |
14 | 14 | * Specifies the basic methods for an OAuth1 provider. |
15 | 15 | */ |
16 | -interface OAuth1Interface extends OAuthInterface{ |
|
16 | +interface OAuth1Interface extends OAuthInterface { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Obtains an OAuth1 request token and returns an AccessToken object for use in the authentication request. |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * Specifies the basic methods for an OAuth2 provider. |
17 | 17 | */ |
18 | -interface OAuth2Interface extends OAuthInterface{ |
|
18 | +interface OAuth2Interface extends OAuthInterface { |
|
19 | 19 | |
20 | 20 | const AUTH_METHOD_HEADER = 1; |
21 | 21 | const AUTH_METHOD_QUERY = 2; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * |
16 | 16 | * @link https://tools.ietf.org/html/rfc6749#section-10.12 |
17 | 17 | */ |
18 | -interface CSRFToken{ |
|
18 | +interface CSRFToken { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Checks whether the CSRF state was set and verifies against the last known state. |
@@ -40,6 +40,6 @@ |
||
40 | 40 | * @property array $curl_multi_options |
41 | 41 | * @property bool $curl_check_OCSP |
42 | 42 | */ |
43 | -class OAuthOptions extends SettingsContainerAbstract{ |
|
43 | +class OAuthOptions extends SettingsContainerAbstract { |
|
44 | 44 | use OAuthOptionsTrait, HTTPOptionsTrait; |
45 | 45 | } |
@@ -83,11 +83,9 @@ |
||
83 | 83 | |
84 | 84 | if(empty($data)){ |
85 | 85 | throw new ProviderException('unable to parse token response'); |
86 | - } |
|
87 | - elseif(isset($data['error'])){ |
|
86 | + } elseif(isset($data['error'])){ |
|
88 | 87 | throw new ProviderException('error retrieving access token: '.$data['error']); |
89 | - } |
|
90 | - elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
88 | + } elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
91 | 89 | throw new ProviderException('invalid token'); |
92 | 90 | } |
93 | 91 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Implements an abstract OAuth1 provider with all methods required by the OAuth1Interface. |
23 | 23 | */ |
24 | -abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{ |
|
24 | +abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface { |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * The request OAuth1 token URL |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ->withHeader('Content-Length', '0') // tumblr requires a content-length header set |
61 | 61 | ; |
62 | 62 | |
63 | - foreach($this->authHeaders as $header => $value){ |
|
63 | + foreach ($this->authHeaders as $header => $value) { |
|
64 | 64 | $request = $request->withAddedHeader($header, $value); |
65 | 65 | } |
66 | 66 | |
@@ -77,20 +77,20 @@ discard block |
||
77 | 77 | protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{ |
78 | 78 | $data = $this->parseQuery(MessageUtil::decompress($response)); |
79 | 79 | |
80 | - if(empty($data)){ |
|
80 | + if (empty($data)) { |
|
81 | 81 | throw new ProviderException('unable to parse token response'); |
82 | 82 | } |
83 | - elseif(isset($data['error'])){ |
|
83 | + elseif (isset($data['error'])) { |
|
84 | 84 | throw new ProviderException('error retrieving access token: '.$data['error']); |
85 | 85 | } |
86 | - elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
86 | + elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) { |
|
87 | 87 | throw new ProviderException('invalid token'); |
88 | 88 | } |
89 | 89 | |
90 | - if( |
|
90 | + if ( |
|
91 | 91 | $checkCallbackConfirmed |
92 | 92 | && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') |
93 | - ){ |
|
93 | + ) { |
|
94 | 94 | throw new ProviderException('oauth callback unconfirmed'); |
95 | 95 | } |
96 | 96 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ |
133 | 133 | $parsed = QueryUtil::parseUrl($url); |
134 | 134 | |
135 | - if(!isset($parsed['host']) || !isset($parsed['scheme']) || !in_array($parsed['scheme'], ['http', 'https'], true)){ |
|
135 | + if (!isset($parsed['host']) || !isset($parsed['scheme']) || !in_array($parsed['scheme'], ['http', 'https'], true)) { |
|
136 | 136 | throw new ProviderException('getSignature: invalid url'); |
137 | 137 | } |
138 | 138 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ]); |
150 | 150 | |
151 | 151 | // https://tools.ietf.org/html/rfc5849#section-3.4.2 |
152 | - $key = array_map('rawurlencode', [ |
|
152 | + $key = array_map('rawurlencode', [ |
|
153 | 153 | $this->options->secret, |
154 | 154 | $accessTokenSecret ?? '' |
155 | 155 | ]); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $token->accessTokenSecret |
197 | 197 | ); |
198 | 198 | |
199 | - if(isset($query['oauth_session_handle'])){ |
|
199 | + if (isset($query['oauth_session_handle'])) { |
|
200 | 200 | $parameters['oauth_session_handle'] = $query['oauth_session_handle']; // @codeCoverageIgnore |
201 | 201 | } |
202 | 202 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Implements a memory storage adapter. Memory storage is not persistent as tokens are only stored during script runtime. |
19 | 19 | */ |
20 | -class MemoryStorage extends OAuthStorageAbstract{ |
|
20 | +class MemoryStorage extends OAuthStorageAbstract { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * the token storage array |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getAccessToken(string $service):AccessToken{ |
45 | 45 | |
46 | - if($this->hasAccessToken($service)){ |
|
46 | + if ($this->hasAccessToken($service)) { |
|
47 | 47 | return $this->tokens[$service]; |
48 | 48 | } |
49 | 49 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function clearAccessToken(string $service):OAuthStorageInterface{ |
64 | 64 | |
65 | - if(array_key_exists($service, $this->tokens)){ |
|
65 | + if (array_key_exists($service, $this->tokens)) { |
|
66 | 66 | unset($this->tokens[$service]); |
67 | 67 | } |
68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function clearAllAccessTokens():OAuthStorageInterface{ |
76 | 76 | |
77 | - foreach(array_keys($this->tokens) as $service){ |
|
77 | + foreach (array_keys($this->tokens) as $service) { |
|
78 | 78 | unset($this->tokens[$service]); |
79 | 79 | } |
80 | 80 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function getCSRFState(string $service):string{ |
99 | 99 | |
100 | - if($this->hasCSRFState($service)){ |
|
100 | + if ($this->hasCSRFState($service)) { |
|
101 | 101 | return $this->states[$service]; |
102 | 102 | } |
103 | 103 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function clearCSRFState(string $service):OAuthStorageInterface{ |
118 | 118 | |
119 | - if(array_key_exists($service, $this->states)){ |
|
119 | + if (array_key_exists($service, $this->states)) { |
|
120 | 120 | unset($this->states[$service]); |
121 | 121 | } |
122 | 122 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * Implements a session storage adapter. Session storage is half persistent as tokens are stored for the duration of the session. |
22 | 22 | */ |
23 | -class SessionStorage extends OAuthStorageAbstract{ |
|
23 | +class SessionStorage extends OAuthStorageAbstract { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * the key name for the token storage array in $_SESSION |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * SessionStorage constructor. |
37 | 37 | */ |
38 | - public function __construct(SettingsContainerInterface $options = null){ |
|
38 | + public function __construct(SettingsContainerInterface $options = null) { |
|
39 | 39 | parent::__construct($options); |
40 | 40 | |
41 | 41 | $this->tokenVar = $this->options->sessionTokenVar; |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | |
44 | 44 | // Determine if the session has started. |
45 | 45 | // @link http://stackoverflow.com/a/18542272/1470961 |
46 | - if($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)){ |
|
46 | + if ($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)) { |
|
47 | 47 | session_start(); |
48 | 48 | } |
49 | 49 | |
50 | - if(!isset($_SESSION[$this->tokenVar])){ |
|
50 | + if (!isset($_SESSION[$this->tokenVar])) { |
|
51 | 51 | $_SESSION[$this->tokenVar] = []; |
52 | 52 | } |
53 | 53 | |
54 | - if(!isset($_SESSION[$this->stateVar])){ |
|
54 | + if (!isset($_SESSION[$this->stateVar])) { |
|
55 | 55 | $_SESSION[$this->stateVar] = []; |
56 | 56 | } |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @codeCoverageIgnore |
64 | 64 | */ |
65 | - public function __destruct(){ |
|
66 | - if($this->options->sessionStart){ |
|
65 | + public function __destruct() { |
|
66 | + if ($this->options->sessionStart) { |
|
67 | 67 | session_write_close(); |
68 | 68 | } |
69 | 69 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getAccessToken(string $service):AccessToken{ |
84 | 84 | |
85 | - if($this->hasAccessToken($service)){ |
|
85 | + if ($this->hasAccessToken($service)) { |
|
86 | 86 | return $this->fromStorage($_SESSION[$this->tokenVar][$service]); |
87 | 87 | } |
88 | 88 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function clearAccessToken(string $service):OAuthStorageInterface{ |
103 | 103 | |
104 | - if(array_key_exists($service, $_SESSION[$this->tokenVar])){ |
|
104 | + if (array_key_exists($service, $_SESSION[$this->tokenVar])) { |
|
105 | 105 | unset($_SESSION[$this->tokenVar][$service]); |
106 | 106 | } |
107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function clearAllAccessTokens():OAuthStorageInterface{ |
115 | 115 | |
116 | - foreach(array_keys($_SESSION[$this->tokenVar]) as $service){ |
|
116 | + foreach (array_keys($_SESSION[$this->tokenVar]) as $service) { |
|
117 | 117 | unset($_SESSION[$this->tokenVar][$service]); |
118 | 118 | } |
119 | 119 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function getCSRFState(string $service):string{ |
138 | 138 | |
139 | - if($this->hasCSRFState($service)){ |
|
139 | + if ($this->hasCSRFState($service)) { |
|
140 | 140 | return $_SESSION[$this->stateVar][$service]; |
141 | 141 | } |
142 | 142 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function clearCSRFState(string $service):OAuthStorageInterface{ |
157 | 157 | |
158 | - if(array_key_exists($service, $_SESSION[$this->stateVar])){ |
|
158 | + if (array_key_exists($service, $_SESSION[$this->stateVar])) { |
|
159 | 159 | unset($_SESSION[$this->stateVar][$service]); |
160 | 160 | } |
161 | 161 |