@@ 218-232 (lines=15) @@ | ||
215 | * |
|
216 | * @return void |
|
217 | */ |
|
218 | protected function enableAuthCodeGrant() |
|
219 | { |
|
220 | $authCodeGrant = new AuthCodeGrant( |
|
221 | new AuthCodeRepository(), |
|
222 | new RefreshTokenRepository(), |
|
223 | new DateInterval('PT10M') |
|
224 | ); |
|
225 | ||
226 | $authCodeGrant->setRefreshTokenTTL(new DateInterval(static::$refreshTokensExpireAt)); |
|
227 | ||
228 | $this->server->enableGrantType( |
|
229 | $authCodeGrant, |
|
230 | new DateInterval(static::$tokensExpireAt) |
|
231 | ); |
|
232 | } |
|
233 | ||
234 | /** |
|
235 | * Enable Password Grant. |
|
@@ 239-253 (lines=15) @@ | ||
236 | * |
|
237 | * @return void |
|
238 | */ |
|
239 | protected function enablePasswordGrant() |
|
240 | { |
|
241 | $passwordGrant = new PasswordGrant( |
|
242 | new UserRepository(), |
|
243 | new RefreshTokenRepository() |
|
244 | ); |
|
245 | ||
246 | $passwordGrant->setRefreshTokenTTL(new DateInterval(static::$refreshTokensExpireAt)); // refresh tokens will expire after 1 month |
|
247 | ||
248 | // Enable the password grant on the server |
|
249 | $this->server->enableGrantType( |
|
250 | $passwordGrant, |
|
251 | new DateInterval(static::$tokensExpireAt) // access tokens will expire after 1 hour |
|
252 | ); |
|
253 | } |
|
254 | ||
255 | /** |
|
256 | * Enable Refresh token Grant. |
|
@@ 260-270 (lines=11) @@ | ||
257 | * |
|
258 | * @return void |
|
259 | */ |
|
260 | protected function enableRefreshTokenGrant() |
|
261 | { |
|
262 | $refreshTokenGrant = new RefreshTokenGrant(new RefreshTokenRepository()); |
|
263 | $refreshTokenGrant->setRefreshTokenTTL(new \DateInterval(static::$refreshTokensExpireAt)); // new refresh tokens will expire after 1 month |
|
264 | ||
265 | // Enable the refresh token grant on the server |
|
266 | $this->server->enableGrantType( |
|
267 | $refreshTokenGrant, |
|
268 | new \DateInterval(static::$tokensExpireAt) // new access tokens will expire after an hour |
|
269 | ); |
|
270 | } |
|
271 | ||
272 | /** |
|
273 | * Create a resource server for validation. |