Add a config flag to disable API

fix #129
This commit is contained in:
brunob
2022-05-12 15:35:09 +02:00
parent 8e4f6c7b22
commit 691e0c3592
3 changed files with 19 additions and 0 deletions
+14
View File
@@ -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)) {
+1
View File
@@ -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,
+4
View File
@@ -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