handler: only allow downloads for annotated endpoints

only a few API endpoints should allow downloads, mark them explicitly and
forbid downloading for the rest.

Fixes: 6d832db ("allow 'download' to be passed from API handler")

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2024-09-19 15:19:44 +02:00 committed by Thomas Lamprecht
parent 9ecc949c68
commit e1f830d1e3

View File

@ -989,8 +989,12 @@ sub handle_api2_request {
$download //= $res->{data}->{download}
if defined($res->{data}) && ref($res->{data}) eq 'HASH';
if (defined($download)) {
if ($res->{info}->{download}) {
send_file_start($self, $reqstate, $download);
return;
} else {
warn "Download attempted for non-marked API endpoint '$path'\n";
}
}
my ($raw, $ct, $nocomp) = $formatter->($res, $res->{data}, $params, $path,