1 | <?php |
||
32 | class AuthorizationServer implements EmitterAwareInterface |
||
33 | { |
||
34 | use EmitterAwareTrait; |
||
35 | |||
36 | /** |
||
37 | * @var GrantTypeInterface[] |
||
38 | */ |
||
39 | protected $enabledGrantTypes = []; |
||
40 | |||
41 | /** |
||
42 | * @var \DateInterval[] |
||
43 | */ |
||
44 | protected $grantTypeAccessTokenTTL = []; |
||
45 | |||
46 | /** |
||
47 | * @var CryptKey |
||
48 | */ |
||
49 | protected $privateKey; |
||
50 | |||
51 | /** |
||
52 | * @var CryptKey |
||
53 | */ |
||
54 | protected $publicKey; |
||
55 | |||
56 | /** |
||
57 | * @var ResponseTypeInterface |
||
58 | */ |
||
59 | protected $responseTypePrototype; |
||
60 | |||
61 | /** |
||
62 | * @var null|IntrospectionResponse |
||
63 | */ |
||
64 | protected $introspectionResponseType; |
||
65 | |||
66 | /** |
||
67 | * @var null|IntrospectionValidatorInterface |
||
68 | */ |
||
69 | protected $introspectionValidator; |
||
70 | |||
71 | /** |
||
72 | * @var null|Introspector |
||
73 | */ |
||
74 | protected $introspector; |
||
75 | |||
76 | /** |
||
77 | * @var ClientRepositoryInterface |
||
78 | */ |
||
79 | private $clientRepository; |
||
80 | |||
81 | /** |
||
82 | * @var AccessTokenRepositoryInterface |
||
83 | */ |
||
84 | private $accessTokenRepository; |
||
85 | |||
86 | /** |
||
87 | * @var ScopeRepositoryInterface |
||
88 | */ |
||
89 | private $scopeRepository; |
||
90 | |||
91 | /** |
||
92 | * @var string|Key |
||
93 | */ |
||
94 | private $encryptionKey; |
||
95 | |||
96 | /** |
||
97 | * @var string |
||
98 | */ |
||
99 | private $defaultScope = ''; |
||
100 | |||
101 | /** |
||
102 | * New server instance. |
||
103 | * |
||
104 | * @param ClientRepositoryInterface $clientRepository |
||
105 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
106 | * @param ScopeRepositoryInterface $scopeRepository |
||
107 | * @param CryptKey|string $privateKey |
||
108 | * @param string|Key $encryptionKey |
||
109 | * @param null|ResponseTypeInterface $responseTypePrototype |
||
110 | */ |
||
111 | 10 | public function __construct( |
|
144 | |||
145 | /** |
||
146 | * Enable a grant type on the server. |
||
147 | * |
||
148 | * @param GrantTypeInterface $grantType |
||
149 | * @param null|\DateInterval $accessTokenTTL |
||
150 | */ |
||
151 | 7 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
168 | |||
169 | /** |
||
170 | * Validate an authorization request |
||
171 | * |
||
172 | * @param ServerRequestInterface $request |
||
173 | * |
||
174 | * @throws OAuthServerException |
||
175 | * |
||
176 | * @return AuthorizationRequest |
||
177 | */ |
||
178 | 3 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
|
188 | |||
189 | /** |
||
190 | * Complete an authorization request |
||
191 | * |
||
192 | * @param AuthorizationRequest $authRequest |
||
193 | * @param ResponseInterface $response |
||
194 | * |
||
195 | * @return ResponseInterface |
||
196 | */ |
||
197 | 1 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
|
203 | |||
204 | /** |
||
205 | * Return an access token response. |
||
206 | * |
||
207 | * @param ServerRequestInterface $request |
||
208 | * @param ResponseInterface $response |
||
209 | * |
||
210 | * @throws OAuthServerException |
||
211 | * |
||
212 | * @return ResponseInterface |
||
213 | */ |
||
214 | 4 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
233 | |||
234 | /** |
||
235 | * @param IntrospectionResponse $reponseType |
||
236 | */ |
||
237 | public function setIntrospectionReponseType(IntrospectionResponse $reponseType) |
||
241 | |||
242 | /** |
||
243 | * @param IntrospectionValidatorInterface $introspectionValidator |
||
244 | */ |
||
245 | public function setIntrospectionValidator(IntrospectionValidatorInterface $introspectionValidator) |
||
249 | |||
250 | /** |
||
251 | * Get the introspection response |
||
252 | * |
||
253 | * @return IntrospectionResponse |
||
254 | */ |
||
255 | protected function getIntrospectionResponseType() |
||
263 | |||
264 | /** |
||
265 | * Get the introspection response |
||
266 | * |
||
267 | * @return IntrospectionValidatorInterface |
||
268 | */ |
||
269 | protected function getIntrospectionValidator() |
||
277 | |||
278 | /** |
||
279 | * Return an introspection response. |
||
280 | * |
||
281 | * @param ServerRequestInterface $request |
||
282 | * @param ResponseInterface $response |
||
283 | * |
||
284 | * @return ResponseInterface |
||
285 | */ |
||
286 | public function respondToIntrospectionRequest(ServerRequestInterface $request, ResponseInterface $response) |
||
297 | |||
298 | /** |
||
299 | * Validate an introspection request. |
||
300 | * |
||
301 | * @param ServerRequestInterface $request |
||
302 | */ |
||
303 | public function validateIntrospectionRequest(ServerRequestInterface $request) |
||
308 | |||
309 | /** |
||
310 | * Returns the introspector. |
||
311 | * |
||
312 | * @return Introspector |
||
313 | */ |
||
314 | private function getIntrospector() |
||
326 | |||
327 | /** |
||
328 | * Get the token type that grants will return in the HTTP response. |
||
329 | * |
||
330 | * @return ResponseTypeInterface |
||
331 | */ |
||
332 | 5 | protected function newResponseType() |
|
336 | |||
337 | /** |
||
338 | * Set the default scope for the authorization server. |
||
339 | * |
||
340 | * @param string $defaultScope |
||
341 | */ |
||
342 | 3 | public function setDefaultScope($defaultScope) |
|
346 | } |
||
347 |