-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTokenManagerInterface.php
More file actions
61 lines (54 loc) · 1.75 KB
/
Copy pathTokenManagerInterface.php
File metadata and controls
61 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Yokai\SecurityTokenBundle\Manager;
use DateTime;
use Yokai\SecurityTokenBundle\Entity\Token;
use Yokai\SecurityTokenBundle\Exception\TokenConsumedException;
use Yokai\SecurityTokenBundle\Exception\TokenExpiredException;
use Yokai\SecurityTokenBundle\Exception\TokenNotFoundException;
/**
* A token manager is the entry point to deal with tokens.
*
* @author Yann Eugoné <eugone.yann@gmail.com>
*/
interface TokenManagerInterface
{
/**
* Get a token instance.
*
* @param string $purpose The token purpose
* @param string $value The token value
*
* @return Token The token from storage
*
* @throws TokenNotFoundException if the token cannot be found
* @throws TokenExpiredException if the token is expired
* @throws TokenConsumedException if the token is consumed
*/
public function get(string $purpose, string $value): Token;
/**
* Create a token.
*
* @param string $purpose The token purpose
* @param mixed $user The user to associate to the token
* @param array $payload Some additional payload for the token
*
* @return Token The created token
*/
public function create(string $purpose, $user, array $payload = []): Token;
/**
* Consume a token.
*
* @param Token $token The token to consume
* @param DateTime|null $at The date/time at which the token was consumed (defaults to now)
*/
public function consume(Token $token, DateTime|null $at = null): void;
/**
* Get the user associated to a token.
*
* @param Token $token The token
*
* @return mixed The user associated to the provided token
*/
public function getUser(Token $token);
}