1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the GesdinetJWTRefreshTokenBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Gesdinet <http://www.gesdinet.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gesdinet\JWTRefreshTokenBundle\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class ClearInvalidRefreshTokensCommand. |
21
|
|
|
*/ |
22
|
|
|
class ClearInvalidRefreshTokensCommand extends ContainerAwareCommand |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @see Command |
26
|
|
|
*/ |
27
|
4 |
|
protected function configure() |
28
|
|
|
{ |
29
|
|
|
$this |
30
|
4 |
|
->setName('gesdinet:jwt:clear') |
31
|
4 |
|
->setDescription('Clear invalid refresh tokens.') |
32
|
4 |
|
->setDefinition(array( |
33
|
4 |
|
new InputArgument('datetime', InputArgument::OPTIONAL), |
34
|
|
|
)); |
35
|
4 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @see Command |
39
|
|
|
*/ |
40
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
41
|
|
|
{ |
42
|
1 |
|
$datetime = $input->getArgument('datetime'); |
43
|
|
|
|
44
|
1 |
|
if (null === $datetime) { |
45
|
1 |
|
$datetime = new \DateTime(); |
46
|
|
|
} else { |
47
|
|
|
$datetime = new \DateTime($datetime); |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
$manager = $this->getContainer()->get('gesdinet.jwtrefreshtoken.refresh_token_manager'); |
51
|
1 |
|
$revokedTokens = $manager->revokeAllInvalid($datetime); |
52
|
|
|
|
53
|
1 |
|
foreach ($revokedTokens as $revokedToken) { |
54
|
1 |
|
$output->writeln(sprintf('Revoke <comment>%s</comment>', $revokedToken->getRefreshToken())); |
55
|
|
|
} |
56
|
1 |
|
} |
57
|
|
|
} |
58
|
|
|
|