1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the U2F Security bundle. |
5
|
|
|
* |
6
|
|
|
* (c) Michael Barbey <[email protected]> |
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 Mbarbey\U2fSecurityBundle\Event\Authentication; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\EventDispatcher\Event; |
15
|
|
|
use Mbarbey\U2fSecurityBundle\Model\User\U2fUserInterface; |
16
|
|
|
use Mbarbey\U2fSecurityBundle\Model\Key\U2fKeyInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* U2F authentication success event |
20
|
|
|
* |
21
|
|
|
* An event dispatched when a user successfully authenticate with it U2F security key. |
22
|
|
|
* |
23
|
|
|
* This event contain the user and the key used to authenticate. The counter of the key has already been updated. |
24
|
|
|
* |
25
|
|
|
* @author Michael Barbey <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class U2fAuthenticationSuccessEvent extends Event |
28
|
|
|
{ |
29
|
|
|
private $user; |
30
|
|
|
private $key; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Return the name of the event to use when dispatching this event. |
34
|
|
|
* |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
1 |
|
public static function getName(): string |
38
|
|
|
{ |
39
|
1 |
|
return 'u2f.authentication.success'; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param U2fUserInterface $user The user who successfully authenticated |
44
|
|
|
* @param U2fKeyInterface $key The security key used during the authentication |
45
|
|
|
*/ |
46
|
3 |
|
public function __construct(U2fUserInterface $user, U2fKeyInterface $key) |
47
|
|
|
{ |
48
|
3 |
|
$this->user = $user; |
49
|
3 |
|
$this->key = $key; |
50
|
3 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Return the user who successfully authenticated with it U2F key. |
54
|
|
|
* |
55
|
|
|
* @return U2fUserInterface |
56
|
|
|
*/ |
57
|
1 |
|
public function getUser(): U2fUserInterface |
58
|
|
|
{ |
59
|
1 |
|
return $this->user; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Return the key used to authenticate. The counter of the key has already been updated. |
64
|
|
|
* |
65
|
|
|
* @return U2fKeyInterface |
66
|
|
|
*/ |
67
|
1 |
|
public function getKey(): U2fKeyInterface |
68
|
|
|
{ |
69
|
1 |
|
return $this->key; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|