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