]> git.proxmox.com Git - pve-access-control.git/commitdiff
store the tfa type in user.cfg
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 11 Apr 2019 09:31:58 +0000 (11:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 12 Apr 2019 14:27:53 +0000 (16:27 +0200)
This allows some improvements to the user experience on the
web ui.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
PVE/AccessControl.pm

index bec962f752d1f9fcf361a0e6e51ac4e8cac17509..de353b1bf139ada2573c717b0d40980b419a0fe5 100644 (file)
@@ -1434,7 +1434,7 @@ sub user_set_tfa {
        $tfa->{data} = $data;
        cfs_write_file('priv/tfa.cfg', $tfa_cfg);
 
        $tfa->{data} = $data;
        cfs_write_file('priv/tfa.cfg', $tfa_cfg);
 
-       $user->{keys} = 'x';
+       $user->{keys} = "x!$type";
     } else {
        delete $tfa_cfg->{users}->{$userid};
        cfs_write_file('priv/tfa.cfg', $tfa_cfg);
     } else {
        delete $tfa_cfg->{users}->{$userid};
        cfs_write_file('priv/tfa.cfg', $tfa_cfg);
@@ -1463,7 +1463,8 @@ sub user_get_tfa {
     $realm_tfa = PVE::Auth::Plugin::parse_tfa_config($realm_tfa)
        if $realm_tfa;
 
     $realm_tfa = PVE::Auth::Plugin::parse_tfa_config($realm_tfa)
        if $realm_tfa;
 
-    if ($keys ne 'x') {
+    # new style config starts with an 'x' and optionally contains a !<type> suffix
+    if ($keys != /^x(?:!.*)?$/) {
        # old style config, find the type via the realm
        return if !$realm_tfa;
        return ($realm_tfa->{type}, {
        # old style config, find the type via the realm
        return if !$realm_tfa;
        return ($realm_tfa->{type}, {