|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* The MIT License (MIT) |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
|
9
|
|
|
* |
|
10
|
|
|
* This software may be modified and distributed under the terms |
|
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace OAuth2Framework\ServerBundle\Tests\TestBundle\DataFixtures; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\DataFixtures\FixtureInterface; |
|
17
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
18
|
|
|
use OAuth2Framework\Component\Core\Client\ClientId; |
|
19
|
|
|
use OAuth2Framework\Component\Core\DataBag\DataBag; |
|
20
|
|
|
use OAuth2Framework\Component\Core\UserAccount\UserAccountId; |
|
21
|
|
|
use OAuth2Framework\ServerBundle\Tests\TestBundle\Entity\ClientRepository; |
|
22
|
|
|
|
|
23
|
|
|
final class ClientFixtures implements FixtureInterface |
|
24
|
|
|
{ |
|
25
|
|
|
private $clientRepository; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(ClientRepository $clientRepository) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->clientRepository = $clientRepository; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function load(ObjectManager $manager) |
|
33
|
|
|
{ |
|
34
|
|
|
foreach ($this->getData() as $datum) { |
|
35
|
|
|
$client = $this->clientRepository->create( |
|
36
|
|
|
new ClientId($datum['client_id']), |
|
37
|
|
|
new DataBag($datum['parameter']), |
|
38
|
|
|
new UserAccountId($datum['owner_id']) |
|
39
|
|
|
); |
|
40
|
|
|
$this->clientRepository->save($client); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
private function getData(): array |
|
45
|
|
|
{ |
|
46
|
|
|
return [ |
|
47
|
|
|
[ |
|
48
|
|
|
'client_id' => 'CLIENT_ID_1', |
|
49
|
|
|
'owner_id' => 'USER_ACCOUNT_1', |
|
50
|
|
|
'parameter' => [ |
|
51
|
|
|
'token_endpoint_auth_method' => 'none', |
|
52
|
|
|
'grant_types' => [], |
|
53
|
|
|
], |
|
54
|
|
|
], |
|
55
|
|
|
[ |
|
56
|
|
|
'client_id' => 'CLIENT_ID_2', |
|
57
|
|
|
'owner_id' => 'USER_ACCOUNT_1', |
|
58
|
|
|
'parameter' => [ |
|
59
|
|
|
'token_endpoint_auth_method' => 'none', |
|
60
|
|
|
'grant_types' => ['client_credentials', 'refresh_token', 'authorization_code', 'password', 'implicit'], |
|
61
|
|
|
'response_types' => ['code'], |
|
62
|
|
|
'redinect_uris' => [ |
|
63
|
|
|
'https://exxample.com/cb/?foo=bar', |
|
64
|
|
|
], |
|
65
|
|
|
], |
|
66
|
|
|
], |
|
67
|
|
|
[ |
|
68
|
|
|
'client_id' => 'CLIENT_ID_3', |
|
69
|
|
|
'owner_id' => 'USER_ACCOUNT_1', |
|
70
|
|
|
'parameter' => [ |
|
71
|
|
|
'token_endpoint_auth_method' => 'client_secret_post', |
|
72
|
|
|
'grant_types' => ['client_credentials', 'refresh_token', 'authorization_code', 'password', 'implicit'], |
|
73
|
|
|
'client_secret' => 'secret', |
|
74
|
|
|
], |
|
75
|
|
|
], |
|
76
|
|
|
[ |
|
77
|
|
|
'client_id' => 'CLIENT_ID_4', |
|
78
|
|
|
'owner_id' => 'USER_ACCOUNT_1', |
|
79
|
|
|
'parameter' => [ |
|
80
|
|
|
'token_endpoint_auth_method' => 'client_secret_jwt', |
|
81
|
|
|
'grant_types' => ['urn:ietf:params:oauth:grant-type:jwt-bearer'], |
|
82
|
|
|
'client_secret' => 'secret', |
|
83
|
|
|
], |
|
84
|
|
|
], |
|
85
|
|
|
[ |
|
86
|
|
|
'client_id' => 'CLIENT_ID_5', |
|
87
|
|
|
'owner_id' => 'USER_ACCOUNT_1', |
|
88
|
|
|
'parameter' => [ |
|
89
|
|
|
'token_endpoint_auth_method' => 'client_secret_basic', |
|
90
|
|
|
'grant_types' => ['client_credentials', 'refresh_token', 'authorization_code', 'password', 'implicit'], |
|
91
|
|
|
'client_secret' => 'secret', |
|
92
|
|
|
], |
|
93
|
|
|
], |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|