1 | <?php |
||
21 | class EnhancedAuthenticate extends Authenticate |
||
22 | { |
||
23 | use ClassOptionsTrait; |
||
24 | |||
25 | /** |
||
26 | * @var array An associative array containing options |
||
27 | */ |
||
28 | protected $options = [ |
||
29 | 'maxAttemptsForUserName' => 5, |
||
30 | 'maxAttemptsForSessionId' => 10, |
||
31 | 'maxAttemptsForIpAddress' => 20, |
||
32 | 'maxAttemptsForSecond' => 40, |
||
33 | 'banTimeInSeconds' => 900 //15 minutes |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @var EnhancedAuthenticateMapperInterface Enhanced Authenticate Mapper |
||
38 | */ |
||
39 | private $enhancedAuthenticateMapper; |
||
40 | |||
41 | /** |
||
42 | * Class Constructor |
||
43 | * |
||
44 | * @param Session $session |
||
45 | * @param Password $password |
||
46 | * @param array $options |
||
47 | */ |
||
48 | public function __construct( |
||
60 | |||
61 | /** |
||
62 | * Return how many attemps are left for incorrect password. |
||
63 | * |
||
64 | * @param string $userName |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | public function getAttemptsLeftWithSameUser(string $userName) : int |
||
72 | |||
73 | /** |
||
74 | * Return how many attemps are left for same session id. |
||
75 | * |
||
76 | * @param string $sessionId |
||
77 | * |
||
78 | * @return int |
||
79 | */ |
||
80 | public function getAttemptsLeftWithSameSession(string $sessionId) : int |
||
84 | |||
85 | /** |
||
86 | * Return how many attemps are left for same ip. |
||
87 | * |
||
88 | * @param string $ipAddress |
||
89 | * |
||
90 | * @return int |
||
91 | */ |
||
92 | public function getAttemptsLeftWithSameIp(string $ipAddress) : int |
||
96 | |||
97 | /** |
||
98 | * Check if an user is banned from do login. |
||
99 | * |
||
100 | * @param string $userName |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function isUserBanned(string $userName) : bool |
||
108 | |||
109 | /** |
||
110 | * Check if an ip address is banned from do login. |
||
111 | * |
||
112 | * @param string $ipAddress |
||
113 | * |
||
114 | * @return bool |
||
115 | */ |
||
116 | public function isIpBanned(string $ipAddress) : bool |
||
120 | |||
121 | /** |
||
122 | * Check if a session id is banned from do login. |
||
123 | * |
||
124 | * @param string $sessionId |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function isSessionBanned(string $sessionId) : bool |
||
132 | } |
||
133 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.