1 | <?php |
||
18 | class Google2FA extends Google2FAService |
||
19 | { |
||
20 | use Auth, Config, Request, Session; |
||
21 | |||
22 | /** |
||
23 | * Authenticator constructor. |
||
24 | * |
||
25 | * @param IlluminateRequest $request |
||
26 | */ |
||
27 | 11 | public function __construct(IlluminateRequest $request) |
|
33 | |||
34 | /** |
||
35 | * Authenticator boot. |
||
36 | * |
||
37 | * @param $request |
||
38 | * |
||
39 | * @return Google2FA |
||
40 | */ |
||
41 | 11 | public function boot($request) |
|
47 | |||
48 | /** |
||
49 | * Get the user Google2FA secret. |
||
50 | * |
||
51 | * @throws InvalidSecretKey |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | 8 | protected function getGoogle2FASecretKey() |
|
59 | |||
60 | /** |
||
61 | * Check if the 2FA is activated for the user. |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | 8 | public function isActivated() |
|
71 | |||
72 | /** |
||
73 | * Store the old OTP timestamp. |
||
74 | * |
||
75 | * @param $key |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | 5 | protected function storeOldTimestamp($key) |
|
85 | |||
86 | /** |
||
87 | * Get the previous OTP timestamp. |
||
88 | * |
||
89 | * @return null|mixed |
||
90 | */ |
||
91 | 6 | protected function getOldTimestamp() |
|
97 | |||
98 | /** |
||
99 | * Keep this OTP session alive. |
||
100 | */ |
||
101 | 4 | protected function keepAlive() |
|
107 | |||
108 | /** |
||
109 | * Get minutes since last activity. |
||
110 | * |
||
111 | * @return int |
||
112 | */ |
||
113 | 1 | protected function minutesSinceLastActivity() |
|
119 | |||
120 | /** |
||
121 | * Check if no user is authenticated using OTP. |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | 7 | protected function noUserIsAuthenticated() |
|
129 | |||
130 | /** |
||
131 | * Check if OTP has expired. |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | 4 | protected function passwordExpired() |
|
149 | |||
150 | /** |
||
151 | * Verifies, in the current session, if a 2fa check has already passed. |
||
152 | * |
||
153 | * @return bool |
||
154 | */ |
||
155 | 7 | protected function twoFactorAuthStillValid() |
|
161 | |||
162 | /** |
||
163 | * Check if the module is enabled. |
||
164 | * |
||
165 | * @return mixed |
||
166 | */ |
||
167 | 7 | protected function isEnabled() |
|
171 | |||
172 | /** |
||
173 | * Set current auth as valid. |
||
174 | */ |
||
175 | 4 | public function login() |
|
181 | |||
182 | /** |
||
183 | * OTP logout. |
||
184 | */ |
||
185 | 3 | public function logout() |
|
193 | |||
194 | /** |
||
195 | * Update the current auth time. |
||
196 | */ |
||
197 | 4 | protected function updateCurrentAuthTime() |
|
201 | |||
202 | /** |
||
203 | * Verify the OTP. |
||
204 | * |
||
205 | * @param $secret |
||
206 | * @param $one_time_password |
||
207 | * |
||
208 | * @return mixed |
||
209 | */ |
||
210 | 6 | public function verifyGoogle2FA($secret, $one_time_password) |
|
220 | |||
221 | /** |
||
222 | * Verify the OTP and store the timestamp. |
||
223 | * |
||
224 | * @param $one_time_password |
||
225 | * |
||
226 | * @return mixed |
||
227 | */ |
||
228 | 5 | protected function verifyAndStoreOneTimePassword($one_time_password) |
|
237 | } |
||
238 |