]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/AccessControl.pm
fix #2079: activate authkey rotation every 24 hours
[pve-access-control.git] / PVE / AccessControl.pm
index de353b1bf139ada2573c717b0d40980b419a0fe5..5de060dfced07b7d370ee451e5388a7de68bbe99 100644 (file)
@@ -47,9 +47,8 @@ my $pve_auth_key_files = {
 
 my $pve_auth_key_cache = {};
 
-my $ticket_lifetime = 3600*2; # 2 hours
-# TODO: set to 24h for PVE 6.0
-my $authkey_lifetime = 3600*0; # rotation disabled
+my $ticket_lifetime = 3600 * 2; # 2 hours
+my $authkey_lifetime = 3600 * 24; # rotate every 24 hours
 
 Crypt::OpenSSL::RSA->import_random_seed();
 
@@ -1453,7 +1452,6 @@ sub user_get_tfa {
        or die "user '$username' not found\n";
 
     my $keys = $user->{keys};
-    return if !$keys;
 
     my $domain_cfg = cfs_read_file('domains.cfg');
     my $realm_cfg = $domain_cfg->{ids}->{$realm};
@@ -1463,8 +1461,13 @@ sub user_get_tfa {
     $realm_tfa = PVE::Auth::Plugin::parse_tfa_config($realm_tfa)
        if $realm_tfa;
 
+    if (!$keys) {
+       return if !$realm_tfa;
+       die "missing required 2nd keys\n";
+    }
+
     # new style config starts with an 'x' and optionally contains a !<type> suffix
-    if ($keys != /^x(?:!.*)?$/) {
+    if ($keys !~ /^x(?:!.*)?$/) {
        # old style config, find the type via the realm
        return if !$realm_tfa;
        return ($realm_tfa->{type}, {