1 | <?php |
||
9 | class Model |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | protected static $authCodeModel = '\CodexShaper\OAuth2\Server\Models\AuthCode'; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | protected static $clientModel = '\CodexShaper\OAuth2\Server\Models\Client'; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected static $refreshTokenModel = '\CodexShaper\OAuth2\Server\Models\RefreshToken'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected static $tokenModel = '\CodexShaper\OAuth2\Server\Models\Token'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected static $userModel = '\CodexShaper\OAuth2\Server\Models\User'; |
||
35 | |||
36 | /** |
||
37 | * Create a new model instance. |
||
38 | * |
||
39 | * @param string $model The model name |
||
40 | * |
||
41 | * @return \CodexShaper\OAuth2\Server\Models\AuthCode|\CodexShaper\OAuth2\Server\Models\Client|\CodexShaper\OAuth2\Server\Models\RefreshToken|\CodexShaper\OAuth2\Server\Models\Token|\CodexShaper\OAuth2\Server\Models\User|null |
||
42 | */ |
||
43 | public static function instance($model) |
||
51 | |||
52 | /** |
||
53 | * Get a client. |
||
54 | * |
||
55 | * @param string $clientIdentifier The client's identifier |
||
56 | * |
||
57 | * @return \League\OAuth2\Server\Entities\ClientEntityInterface|null |
||
58 | */ |
||
59 | public static function getClientEntity($clientIdentifier) |
||
76 | |||
77 | /** |
||
78 | * store a new auth code to permanent storage. |
||
79 | * |
||
80 | * @param \League\OAuth2\Server\Entities\AuthCodeEntityInterface $accessTokenEntity |
||
|
|||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public static function storeAuthCode($authCodeEntity) |
||
95 | |||
96 | /** |
||
97 | * store a new access token to permanent storage. |
||
98 | * |
||
99 | * @param \League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessTokenEntity |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | public static function storeAccessToken($accessTokenEntity) |
||
116 | |||
117 | /** |
||
118 | * store a new access refresh token to permanent storage. |
||
119 | * |
||
120 | * @param \League\OAuth2\Server\Entities\RefreshTokenEntityInterface $refreshTokenEntity |
||
121 | * |
||
122 | * @return void |
||
123 | */ |
||
124 | public static function storeRefreshToken($refreshTokenEntity) |
||
133 | |||
134 | /** |
||
135 | * Validate a client's secret. |
||
136 | * |
||
137 | * @param string $clientIdentifier The client's identifier |
||
138 | * @param null|string $clientSecret The client's secret (if sent) |
||
139 | * @param null|string $grantType The type of grant the client is using (if sent) |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | public static function validateClientCredentials($clientIdentifier, $clientSecret, $grantType) |
||
144 | { |
||
145 | $client = static::instance('clientModel'); |
||
146 | |||
147 | $record = $client->where($client->getKeyName(), $clientIdentifier)->first(); |
||
148 | |||
149 | if (!$record || !static::handlesGrant($record, $grantType)) { |
||
150 | return false; |
||
151 | } |
||
152 | |||
153 | $scopes = is_array($record->scopes) ? $record->scopes : []; |
||
154 | Manager::setScopes($scopes); |
||
155 | |||
156 | return !$record->isConfidential() || hash_equals($record->secret, (string) $clientSecret); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Determine if the given client can handle the given grant type. |
||
161 | * |
||
162 | * @param \CodexShaper\OAuth2\Server\Models\Client $record |
||
163 | * @param string $grantType |
||
164 | * |
||
165 | * @return bool |
||
166 | */ |
||
167 | protected static function handlesGrant($record, $grantType) |
||
184 | |||
185 | /** |
||
186 | * Veryfy user credentials for current grant. |
||
187 | * |
||
188 | * @param string $username |
||
189 | * @param string $password |
||
190 | * @param string $grantType |
||
191 | * @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity |
||
192 | * |
||
193 | * @return \CodexShaper\OAuth2\Server\Models\User|null |
||
194 | */ |
||
195 | public static function verifyUserForGrant($username, $password, $grantType, $clientEntity) |
||
213 | |||
214 | /** |
||
215 | * Revoke provided token id. |
||
216 | * |
||
217 | * @param string $model |
||
218 | * @param string $grantType |
||
219 | * |
||
220 | * @return void |
||
221 | */ |
||
222 | public static function revoke($model, $tokenId) |
||
226 | |||
227 | /** |
||
228 | * Determine if the given token id is revoked or not. |
||
229 | * |
||
230 | * @param string $model |
||
231 | * @param string $grantType |
||
232 | * |
||
233 | * @return bool |
||
234 | */ |
||
235 | public static function isRevoked($model, $tokenId) |
||
239 | |||
240 | /** |
||
241 | * Authorization token. |
||
242 | * |
||
243 | * @param string $model |
||
244 | * @param array $data |
||
245 | * |
||
246 | * @return \CodexShaper\OAuth2\Server\Models\AuthCode|\CodexShaper\OAuth2\Server\Models\Client|\CodexShaper\OAuth2\Server\Models\RefreshToken|\CodexShaper\OAuth2\Server\Models\Token|\CodexShaper\OAuth2\Server\Models\User|null |
||
247 | */ |
||
248 | public static function findToken($model, $authRequest, $user) |
||
259 | } |
||
260 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.