1 | <?php |
||
28 | class AuthorizationServer implements EmitterAwareInterface |
||
29 | { |
||
30 | use EmitterAwareTrait; |
||
31 | |||
32 | /** |
||
33 | * @var GrantTypeInterface[] |
||
34 | */ |
||
35 | protected $enabledGrantTypes = []; |
||
36 | |||
37 | /** |
||
38 | * @var \DateInterval[] |
||
39 | */ |
||
40 | protected $grantTypeAccessTokenTTL = []; |
||
41 | |||
42 | /** |
||
43 | * @var CryptKey |
||
44 | */ |
||
45 | protected $privateKey; |
||
46 | |||
47 | /** |
||
48 | * @var CryptKey |
||
49 | */ |
||
50 | protected $publicKey; |
||
51 | |||
52 | /** |
||
53 | * @var null|ResponseTypeInterface |
||
54 | */ |
||
55 | protected $responseType; |
||
56 | |||
57 | /** |
||
58 | * @var ClientRepositoryInterface |
||
59 | */ |
||
60 | private $clientRepository; |
||
61 | |||
62 | /** |
||
63 | * @var AccessTokenRepositoryInterface |
||
64 | */ |
||
65 | private $accessTokenRepository; |
||
66 | |||
67 | /** |
||
68 | * @var ScopeRepositoryInterface |
||
69 | */ |
||
70 | private $scopeRepository; |
||
71 | |||
72 | /** |
||
73 | * @var string|Key |
||
74 | */ |
||
75 | private $encryptionKey; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | private $defaultScope = ''; |
||
81 | |||
82 | /** |
||
83 | * New server instance. |
||
84 | * |
||
85 | * @param ClientRepositoryInterface $clientRepository |
||
86 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
87 | * @param ScopeRepositoryInterface $scopeRepository |
||
88 | * @param CryptKey|string $privateKey |
||
89 | * @param string|Key $encryptionKey |
||
90 | * @param null|ResponseTypeInterface $responseType |
||
91 | */ |
||
92 | 9 | public function __construct( |
|
111 | |||
112 | /** |
||
113 | * Enable a grant type on the server. |
||
114 | * |
||
115 | * @param GrantTypeInterface $grantType |
||
116 | * @param null|\DateInterval $accessTokenTTL |
||
117 | */ |
||
118 | 7 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
135 | |||
136 | /** |
||
137 | * Validate an authorization request |
||
138 | * |
||
139 | * @param ServerRequestInterface $request |
||
140 | * |
||
141 | * @throws OAuthServerException |
||
142 | * |
||
143 | * @return AuthorizationRequest |
||
144 | */ |
||
145 | 3 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
|
155 | |||
156 | /** |
||
157 | * Complete an authorization request |
||
158 | * |
||
159 | * @param AuthorizationRequest $authRequest |
||
160 | * @param ResponseInterface $response |
||
161 | * |
||
162 | * @return ResponseInterface |
||
163 | */ |
||
164 | 1 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
|
170 | |||
171 | /** |
||
172 | * Return an access token response. |
||
173 | * |
||
174 | * @param ServerRequestInterface $request |
||
175 | * @param ResponseInterface $response |
||
176 | * |
||
177 | * @throws OAuthServerException |
||
178 | * |
||
179 | * @return ResponseInterface |
||
180 | */ |
||
181 | 4 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
200 | |||
201 | /** |
||
202 | * Return an introspection response. |
||
203 | * |
||
204 | * @param ServerRequestInterface $request |
||
205 | * @param ResponseInterface $response |
||
206 | * |
||
207 | * @return ResponseInterface |
||
208 | */ |
||
209 | public function respondToIntrospectionRequest(ServerRequestInterface $request, ResponseInterface $response) |
||
216 | |||
217 | /** |
||
218 | * Get the token type that grants will return in the HTTP response. |
||
219 | * |
||
220 | * @return ResponseTypeInterface |
||
221 | */ |
||
222 | 4 | protected function getResponseType() |
|
235 | |||
236 | /** |
||
237 | * Set the default scope for the authorization server. |
||
238 | * |
||
239 | * @param string $defaultScope |
||
240 | */ |
||
241 | 3 | public function setDefaultScope($defaultScope) |
|
245 | } |
||
246 |