1 | <?php |
||
27 | class AuthorizationServer implements EmitterAwareInterface |
||
28 | { |
||
29 | use EmitterAwareTrait; |
||
30 | |||
31 | /** |
||
32 | * @var GrantTypeInterface[] |
||
33 | */ |
||
34 | protected $enabledGrantTypes = []; |
||
35 | |||
36 | /** |
||
37 | * @var \DateInterval[] |
||
38 | */ |
||
39 | protected $grantTypeAccessTokenTTL = []; |
||
40 | |||
41 | /** |
||
42 | * @var CryptKey |
||
43 | */ |
||
44 | protected $privateKey; |
||
45 | |||
46 | /** |
||
47 | * @var CryptKey |
||
48 | */ |
||
49 | protected $publicKey; |
||
50 | |||
51 | /** |
||
52 | * @var ResponseTypeInterface |
||
53 | */ |
||
54 | protected $responseTypePrototype; |
||
55 | |||
56 | /** |
||
57 | * @var ClientRepositoryInterface |
||
58 | */ |
||
59 | private $clientRepository; |
||
60 | |||
61 | /** |
||
62 | * @var AccessTokenRepositoryInterface |
||
63 | */ |
||
64 | private $accessTokenRepository; |
||
65 | |||
66 | /** |
||
67 | * @var ScopeRepositoryInterface |
||
68 | */ |
||
69 | private $scopeRepository; |
||
70 | |||
71 | /** |
||
72 | * @var string|Key |
||
73 | */ |
||
74 | private $encryptionKey; |
||
75 | |||
76 | /** |
||
77 | * @var string |
||
78 | */ |
||
79 | private $defaultScope = ''; |
||
80 | |||
81 | /** |
||
82 | * New server instance. |
||
83 | * |
||
84 | * @param ClientRepositoryInterface $clientRepository |
||
85 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
86 | * @param ScopeRepositoryInterface $scopeRepository |
||
87 | * @param CryptKey|string $privateKey |
||
88 | * @param string|Key $encryptionKey |
||
89 | * @param null|ResponseTypeInterface $responseTypePrototype |
||
90 | */ |
||
91 | 10 | public function __construct( |
|
120 | |||
121 | /** |
||
122 | * Enable a grant type on the server. |
||
123 | * |
||
124 | * @param GrantTypeInterface $grantType |
||
125 | * @param null|\DateInterval $accessTokenTTL |
||
126 | */ |
||
127 | 7 | public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) |
|
144 | |||
145 | /** |
||
146 | * Validate an authorization request |
||
147 | * |
||
148 | * @param ServerRequestInterface $request |
||
149 | * |
||
150 | * @throws OAuthServerException |
||
151 | * |
||
152 | * @return AuthorizationRequest |
||
153 | */ |
||
154 | 3 | public function validateAuthorizationRequest(ServerRequestInterface $request) |
|
164 | |||
165 | /** |
||
166 | * Complete an authorization request |
||
167 | * |
||
168 | * @param AuthorizationRequest $authRequest |
||
169 | * @param ResponseInterface $response |
||
170 | * |
||
171 | * @return ResponseInterface |
||
172 | */ |
||
173 | 1 | public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response) |
|
179 | |||
180 | /** |
||
181 | * Return an access token response. |
||
182 | * |
||
183 | * @param ServerRequestInterface $request |
||
184 | * @param ResponseInterface $response |
||
185 | * |
||
186 | * @throws OAuthServerException |
||
187 | * |
||
188 | * @return ResponseInterface |
||
189 | */ |
||
190 | 4 | public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) |
|
209 | |||
210 | /** |
||
211 | * Get the token type that grants will return in the HTTP response. |
||
212 | * |
||
213 | * @return ResponseTypeInterface |
||
214 | */ |
||
215 | 5 | protected function newResponseType() |
|
219 | |||
220 | /** |
||
221 | * Set the default scope for the authorization server. |
||
222 | * |
||
223 | * @param string $defaultScope |
||
224 | */ |
||
225 | 3 | public function setDefaultScope($defaultScope) |
|
229 | } |
||
230 |