1 | <?php |
||
20 | class Cognito extends AbstractProvider |
||
21 | { |
||
22 | use BearerAuthorizationTrait; |
||
23 | |||
24 | const BASE_COGNITO_URL = 'https://%s.auth.%s.amazoncognito.com%s'; |
||
25 | /** |
||
26 | * @var array List of scopes that will be used for authentication. |
||
27 | * |
||
28 | * Valid scopes: phone, email, openid, aws.cognito.signin.user.admin, profile |
||
29 | * Defaults to email, openid |
||
30 | * |
||
31 | */ |
||
32 | protected $scopes = []; |
||
33 | |||
34 | /** |
||
35 | * @var string If set, it will replace default AWS Cognito urls. |
||
36 | */ |
||
37 | protected $hostedDomain; |
||
38 | |||
39 | /** |
||
40 | * @var string If set, it will be added to AWS Cognito urls. |
||
41 | */ |
||
42 | protected $cognitoDomain; |
||
43 | |||
44 | /** |
||
45 | * @var string If set, it will be added to AWS Cognito urls. |
||
46 | */ |
||
47 | protected $region; |
||
48 | |||
49 | /** |
||
50 | * @param array $options |
||
51 | * @param array $collaborators |
||
52 | * |
||
53 | * @throws \InvalidArgumentException |
||
54 | */ |
||
55 | 34 | public function __construct($options = [], array $collaborators = []) |
|
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | 2 | public function getScopes() |
|
82 | |||
83 | /** |
||
84 | * @return mixed |
||
85 | */ |
||
86 | 4 | public function getRegion() |
|
90 | |||
91 | /** |
||
92 | * @param $region |
||
93 | */ |
||
94 | 2 | public function setRegion($region) |
|
98 | |||
99 | /** |
||
100 | * @return string |
||
101 | */ |
||
102 | 4 | public function getHostedDomain() |
|
106 | |||
107 | /** |
||
108 | * @param string $hostedDomain |
||
109 | */ |
||
110 | 2 | public function setHostedDomain($hostedDomain) |
|
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | 4 | public function getCognitoDomain() |
|
122 | |||
123 | /** |
||
124 | * @param string $cognitoDomain |
||
125 | */ |
||
126 | 2 | public function setCognitoDomain($cognitoDomain) |
|
130 | |||
131 | /** |
||
132 | * Returns the url for given action |
||
133 | * |
||
134 | * @param $action |
||
135 | * @return string |
||
136 | */ |
||
137 | 16 | private function getCognitoUrl($action) |
|
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | 6 | public function getBaseAuthorizationUrl() |
|
150 | |||
151 | /** |
||
152 | * @param array $params |
||
153 | * @return string |
||
154 | */ |
||
155 | 10 | public function getBaseAccessTokenUrl(array $params) |
|
159 | |||
160 | /** |
||
161 | * @param AccessToken $token |
||
162 | * @return string |
||
163 | */ |
||
164 | 2 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
168 | |||
169 | /** |
||
170 | * @param array $options |
||
171 | * @return array |
||
172 | */ |
||
173 | 6 | protected function getAuthorizationParameters(array $options) |
|
185 | |||
186 | /** |
||
187 | * @return array |
||
188 | */ |
||
189 | 6 | protected function getDefaultScopes() |
|
193 | |||
194 | /** |
||
195 | * @return string |
||
196 | */ |
||
197 | 8 | protected function getScopeSeparator() |
|
201 | |||
202 | /** |
||
203 | * @param ResponseInterface $response |
||
204 | * @param array|string $data |
||
205 | * @throws IdentityProviderException |
||
206 | */ |
||
207 | 8 | protected function checkResponse(ResponseInterface $response, $data) |
|
218 | |||
219 | /** |
||
220 | * @param array $response |
||
221 | * @param AccessToken $token |
||
222 | * @return CognitoUser|\League\OAuth2\Client\Provider\ResourceOwnerInterface |
||
223 | */ |
||
224 | 2 | protected function createResourceOwner(array $response, AccessToken $token) |
|
230 | } |
||
231 |