Tester aussi le referer sans quoi ça ne peut pas fonctionner (à squasher avec le commit précédent).

This commit is contained in:
Luc Didry
2022-05-12 14:19:07 +00:00
committed by b_b
parent 691e0c3592
commit 3a0f39761c
+14 -12
View File
@@ -288,19 +288,21 @@ sub add {
my $wm = $c->param('watermark');
if ($c->config('disable_api')) {
my $msg = $c->l('Sorry, the API is disabled');
$c->app->log->info('Blocked API call for '.$ip);
return $c->respond_to(
json => { json => { success => Mojo::JSON->false, msg => $msg } },
any => sub {
shift->render(
template => 'index',
msg => $msg,
);
}
);
$unauthorized_api = (!defined($c->req->headers->referrer) || Mojo::URL->new($c->req->headers->referrer)->host ne Mojo::URL->new('https://'.$c->req->headers->host)->host);
if ($unauthorized_api) {
my $msg = $c->l('Sorry, the API is disabled');
$c->app->log->info('Blocked API call for '.$ip);
return $c->respond_to(
json => { json => { success => Mojo::JSON->false, msg => $msg } },
any => sub {
shift->render(
template => 'index',
msg => $msg,
);
}
);
}
}
if(!defined($c->stash('stop_upload'))) {
if (defined($file_url) && $file_url) {
if (is_http_uri($file_url) || is_https_uri($file_url)) {