]> git.proxmox.com Git - pmg-api.git/commitdiff
fix #2013 spamreport: remove ticket if authmode is ldap
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 17 May 2021 14:02:57 +0000 (16:02 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 28 Jun 2021 13:28:57 +0000 (15:28 +0200)
Currently the 'authmode' setting for the spamquarantine is not used
anywhere. According to documentation setting it to 'ldap' should allow
access to the quarantine only with ldap credentials.

This patch addresses the issue by not generating a quarantineticket,
and adapting all links accordingly if the authmode is 'ldap'.

tested by changing the authmode and running
`pmgqm send -receiver <email-address> -debug 1`

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Dominik Csapak <d.csapak@proxmox.com>
src/PMG/CLI/pmgqm.pm

index 39253dbfe0ae632798b2c537acae3f50a538a875..1e21bf06b743344dfa23e2933ef6345cbc459be1 100755 (executable)
@@ -70,8 +70,12 @@ sub get_item_data {
     $item->{file} = $ref->{file};
 
     my $basehref = "$data->{protocol_fqdn_port}/quarantine";
-    my $ticket = uri_escape($data->{ticket});
-    $item->{href} = "$basehref?ticket=$ticket&cselect=$item->{id}&date=$item->{date}";
+    if ($data->{authmode} ne 'ldap') {
+       my $ticket = uri_escape($data->{ticket});
+       $item->{href} = "$basehref?ticket=$ticket&cselect=$item->{id}&date=$item->{date}";
+    } else {
+       $item->{href} = "$basehref?cselect=$item->{id}&date=$item->{date}";
+    }
 
     return $item;
 }
@@ -229,6 +233,8 @@ __PACKAGE__->register_method ({
            $protocol_fqdn_port .= ":$port";
        }
 
+       my $authmode = $cfg->get ('spamquar', 'authmode') // 'ticket';
+
        my $global_data = {
            protocol => $protocol,
            port => $port,
@@ -238,6 +244,7 @@ __PACKAGE__->register_method ({
            timespan => $timespan,
            items => [],
            protocol_fqdn_port => $protocol_fqdn_port,
+           authmode => $authmode,
        };
 
        my $mailfrom = $cfg->get ('spamquar', 'mailfrom') //
@@ -306,9 +313,13 @@ __PACKAGE__->register_method ({
                $mailcount = 0;
 
                $data->{pmail} = $creceiver;
-               $data->{ticket} = PMG::Ticket::assemble_quarantine_ticket($data->{pmail});
-               my $esc_ticket = uri_escape($data->{ticket});
-               $data->{managehref} = "$protocol_fqdn_port/quarantine?ticket=${esc_ticket}";
+               $data->{managehref} = "$protocol_fqdn_port/quarantine";
+               if ($data->{authmode} ne 'ldap') {
+                   $data->{ticket} = PMG::Ticket::assemble_quarantine_ticket($data->{pmail});
+                   my $esc_ticket = uri_escape($data->{ticket});
+                   $data->{managehref} .= "?ticket=${esc_ticket}";
+               }
+
            }
 
            push @{$data->{items}}, get_item_data($data, $ref);