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