Conditions | 5 |
Paths | 3 |
Total Lines | 31 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true) |
||
21 | { |
||
22 | $clients = [ |
||
23 | 'myawesomeapp' => [ |
||
24 | 'secret' => password_hash('abc123', PASSWORD_BCRYPT), |
||
25 | 'name' => 'My Awesome App', |
||
26 | 'redirect_uri' => 'http://foo/bar', |
||
27 | 'is_confidential' => true, |
||
28 | ], |
||
29 | ]; |
||
30 | |||
31 | // Check if client is registered |
||
32 | if (array_key_exists($clientIdentifier, $clients) === false) { |
||
33 | return; |
||
34 | } |
||
35 | |||
36 | if ( |
||
37 | $mustValidateSecret === true |
||
38 | && $clients[$clientIdentifier]['is_confidential'] === true |
||
39 | && password_verify($clientSecret, $clients[$clientIdentifier]['secret']) === false |
||
40 | ) { |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | $client = new ClientEntity(); |
||
45 | $client->setIdentifier($clientIdentifier); |
||
46 | $client->setName($clients[$clientIdentifier]['name']); |
||
47 | $client->setRedirectUri($clients[$clientIdentifier]['redirect_uri']); |
||
48 | |||
49 | return $client; |
||
50 | } |
||
51 | } |
||
52 |