Przeglądaj źródła

Force uniform period of 30s on TOTP code

George Baugh 2 lat temu
rodzic
commit
1fb803cb1d
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3 2
      lib/Trog/Auth.pm

+ 3 - 2
lib/Trog/Auth.pm

@@ -79,7 +79,8 @@ sub totp($user, $domain) {
 	my $uri = $totp->generate_otp(
 		user   => "$user\@$domain",
 		issuer => $domain,
-		period => 60,
+        #XXX verifier apps will only do 30s :(
+		period => 30,
 		$secret ? ( secret => $secret ) : (),
 	);
 
@@ -148,7 +149,7 @@ sub mksession ($user, $pass, $token) {
 
     # Validate the 2FA Token.  If we have no secret, allow login so they can see their QR code, and subsequently re-auth.
     if ($secret) {
-        my $rc   = $totp->validate_otp(otp => $token, secret => $secret, tolerance => 1);
+        my $rc   = $totp->validate_otp(otp => $token, secret => $secret, tolerance => 1, period => 30);
         return '' unless $rc;
     }