diff --git a/lib/Lutim/Controller/Image.pm b/lib/Lutim/Controller/Image.pm index 6441f9a..8593e75 100644 --- a/lib/Lutim/Controller/Image.pm +++ b/lib/Lutim/Controller/Image.pm @@ -287,6 +287,20 @@ sub add { my $keep_exif = $c->param('keep-exif'); 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, + ); + } + ); + } + if(!defined($c->stash('stop_upload'))) { if (defined($file_url) && $file_url) { if (is_http_uri($file_url) || is_https_uri($file_url)) { diff --git a/lib/Lutim/DefaultConfig.pm b/lib/Lutim/DefaultConfig.pm index e93a981..4765b59 100644 --- a/lib/Lutim/DefaultConfig.pm +++ b/lib/Lutim/DefaultConfig.pm @@ -22,6 +22,7 @@ our $default_config = { watermark_default => 'none', watermark_enforce => 'none', theme => 'default', + disable_api => 0, dbtype => 'sqlite', db_path => 'lutim.db', max_files_in_zip => 15, diff --git a/lutim.conf.template b/lutim.conf.template index 4cde96e..e3b389b 100644 --- a/lutim.conf.template +++ b/lutim.conf.template @@ -135,6 +135,10 @@ # optional, defaut is / #prefix => '/', + # if set to 1, Lutim will try to prevent its use without using the web interface + # optional, default is 0 + #disable_api => 0, + # choose what database you want to use # valid choices are sqlite and postgresql (all lowercase) # optional, default is sqlite