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 Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; |
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class ClearInvalidRefreshTokensCommand. |
22
|
|
|
*/ |
23
|
|
|
class RevokeRefreshTokenCommand extends ContainerAwareCommand |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
protected static $defaultName = 'gesdinet:jwt:revoke'; |
26
|
|
|
|
27
|
5 |
|
private $refreshTokenManager; |
28
|
|
|
|
29
|
5 |
|
public function __construct(RefreshTokenManagerInterface $refreshTokenManager) |
30
|
5 |
|
{ |
31
|
5 |
|
parent::__construct(); |
32
|
5 |
|
|
33
|
5 |
|
$this->refreshTokenManager = $refreshTokenManager; |
34
|
5 |
|
} |
35
|
5 |
|
|
36
|
|
|
/** |
37
|
|
|
* @see Command |
38
|
|
|
*/ |
39
|
|
|
protected function configure() |
40
|
2 |
|
{ |
41
|
|
|
$this |
42
|
2 |
|
->setDescription('Revoke a refresh token') |
43
|
|
|
->setDefinition(array( |
44
|
2 |
|
new InputArgument('refresh_token', InputArgument::REQUIRED, 'The refresh token to revoke'), |
45
|
2 |
|
)); |
46
|
|
|
} |
47
|
2 |
|
|
48
|
1 |
|
/** |
49
|
|
|
* @see Command |
50
|
1 |
|
*/ |
51
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
52
|
|
|
{ |
53
|
1 |
|
$refreshTokenParam = $input->getArgument('refresh_token'); |
54
|
|
|
|
55
|
1 |
|
$refreshToken = $this->refreshTokenManager->get($refreshTokenParam); |
|
|
|
|
56
|
1 |
|
|
57
|
|
|
if (null === $refreshToken) { |
58
|
|
|
$output->writeln(sprintf('<error>Not Found:</error> Refresh Token <comment>%s</comment> doesn\'t exists', $refreshTokenParam)); |
59
|
|
|
|
60
|
|
|
return -1; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$this->refreshTokenManager->delete($refreshToken); |
64
|
|
|
|
65
|
|
|
$output->writeln(sprintf('Revoke <comment>%s</comment>', $refreshToken->getRefreshToken())); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.