1 | <?php |
||
29 | class AuthorizationServer implements EmitterAwareInterface |
||
30 | { |
||
31 | use EmitterAwareTrait; |
||
32 | |||
33 | /** |
||
34 | * @var GrantTypeInterface[] |
||
35 | */ |
||
36 | protected $enabledGrantTypes = []; |
||
37 | |||
38 | /** |
||
39 | * @var \DateInterval[] |
||
40 | */ |
||
41 | protected $grantTypeAccessTokenTTL = []; |
||
42 | |||
43 | /** |
||
44 | * @var CryptKey |
||
45 | */ |
||
46 | protected $privateKey; |
||
47 | |||
48 | /** |
||
49 | * @var CryptKey |
||
50 | */ |
||
51 | protected $publicKey; |
||
52 | |||
53 | /** |
||
54 | * @var null|ResponseTypeInterface |
||
55 | */ |
||
56 | protected $responseType; |
||
57 | |||
58 | /** |
||
59 | * @var null|IntrospectionResponse |
||
60 | */ |
||
61 | protected $introspectionResponseType; |
||
62 | |||
63 | /** |
||
64 | * @var ClientRepositoryInterface |
||
65 | */ |
||
66 | private $clientRepository; |
||
67 | |||
68 | /** |
||
69 | * @var AccessTokenRepositoryInterface |
||
70 | */ |
||
71 | private $accessTokenRepository; |
||
72 | |||
73 | /** |
||
74 | * @var ScopeRepositoryInterface |
||
75 | */ |
||
76 | private $scopeRepository; |
||
77 | |||
78 | /** |
||
79 | * @var string|Key |
||
80 | */ |
||
81 | private $encryptionKey; |
||
82 | |||
83 | /** |
||
84 | * @var string |
||
85 | */ |
||
86 | private $defaultScope = ''; |
||
87 | |||
88 | /** |
||
89 | * New server instance. |
||
90 | * |
||
91 | * @param ClientRepositoryInterface $clientRepository |
||
92 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
93 | * @param ScopeRepositoryInterface $scopeRepository |
||
94 | * @param CryptKey|string $privateKey |
||
95 | * @param string|Key $encryptionKey |
||
96 | * @param null|ResponseTypeInterface $responseType |
||
97 | */ |
||
98 | 7 | public function __construct( |
|
117 | |||
118 | /** |
||
119 | * Enable a grant type on the server. |
||
120 | * |
||
121 | * @param GrantTypeInterface $grantType |
||
122 | * @param null|\DateInterval $accessTokenTTL |
||
123 | */ |
||
124 | 5 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
141 | |||
142 | /** |
||
143 | * Validate an authorization request |
||
144 | * |
||
145 | * @param ServerRequestInterface $request |
||
146 | * |
||
147 | * @throws OAuthServerException |
||
148 | * |
||
149 | * @return AuthorizationRequest |
||
150 | */ |
||
151 | 3 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
|
161 | |||
162 | /** |
||
163 | * Complete an authorization request |
||
164 | * |
||
165 | * @param AuthorizationRequest $authRequest |
||
166 | * @param ResponseInterface $response |
||
167 | * |
||
168 | * @return ResponseInterface |
||
169 | */ |
||
170 | 1 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
|
176 | |||
177 | /** |
||
178 | * Return an access token response. |
||
179 | * |
||
180 | * @param ServerRequestInterface $request |
||
181 | * @param ResponseInterface $response |
||
182 | * |
||
183 | * @throws OAuthServerException |
||
184 | * |
||
185 | * @return ResponseInterface |
||
186 | */ |
||
187 | 2 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
206 | |||
207 | /** |
||
208 | * @param IntrospectionResponse $reponseType |
||
209 | */ |
||
210 | public function setIntrospectionReponseType(IntrospectionResponse $reponseType) |
||
214 | |||
215 | /** |
||
216 | * Get the introspection response |
||
217 | * |
||
218 | * @return IntrospectionResponse |
||
219 | */ |
||
220 | protected function getIntrospectionResponseType() |
||
228 | |||
229 | /** |
||
230 | * Return an introspection response. |
||
231 | * |
||
232 | * @param ServerRequestInterface $request |
||
233 | * @param ResponseInterface $response |
||
234 | * |
||
235 | * @return ResponseInterface |
||
236 | */ |
||
237 | public function respondToIntrospectionRequest(ServerRequestInterface $request, ResponseInterface $response) |
||
247 | |||
248 | /** |
||
249 | * Get the token type that grants will return in the HTTP response. |
||
250 | * |
||
251 | * @return ResponseTypeInterface |
||
252 | */ |
||
253 | 2 | protected function getResponseType() |
|
266 | |||
267 | /** |
||
268 | * Set the default scope for the authorization server. |
||
269 | * |
||
270 | * @param string $defaultScope |
||
271 | */ |
||
272 | 2 | public function setDefaultScope($defaultScope) |
|
276 | } |
||
277 |