]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/AccessControl.pm
add experimental code for yubico OTP verification
[pve-access-control.git] / PVE / API2 / AccessControl.pm
index 8daf10cf5f9763750af85cb70b7126d259bde296..5e132920cdedf197728a22133a4413d3a0788ecb 100644 (file)
@@ -2,7 +2,6 @@ package PVE::API2::AccessControl;
 
 use strict;
 use warnings;
-use Time::HiRes qw(usleep gettimeofday tv_interval);
 
 use PVE::Exception qw(raise raise_perm_exc);
 use PVE::SafeSyslog;
@@ -207,6 +206,18 @@ my $compute_api_permission = sub {
     return $res;
 };
 
+__PACKAGE__->register_method ({
+    name => 'get_ticket', 
+    path => 'ticket', 
+    method => 'GET',
+    permissions => { user => 'world' },
+    description => "Dummy. Useful for formaters which want to priovde a login page.",
+    parameters => {
+       additionalProperties => 0,
+    },
+    returns => { type => "null" },
+    code => sub { return undef; }});
+  
 __PACKAGE__->register_method ({
     name => 'create_ticket', 
     path => 'ticket', 
@@ -265,9 +276,6 @@ __PACKAGE__->register_method ({
        my $rpcenv = PVE::RPCEnvironment::get();
 
        my $res;
-
-       my $starttime = [gettimeofday];
-
        eval {
            # test if user exists and is enabled
            $rpcenv->check_user_enabled($username);
@@ -283,12 +291,7 @@ __PACKAGE__->register_method ({
            my $clientip = $rpcenv->get_client_ip() || '';
            syslog('err', "authentication failure; rhost=$clientip user=$username msg=$err");
            # do not return any info to prevent user enumeration attacks
-           # always try to delay exactly 3 seconds to prevent timing attacks
-           my $elapsed;
-           while (($elapsed = tv_interval($starttime)) < 3) {
-               usleep(int((3 - $elapsed)*1000000));
-           }
-           die "authentication failure\n"; 
+           die PVE::Exception->new("authentication failure\n", code => 401);
        }
 
        $res->{cap} = &$compute_api_permission($rpcenv, $username);