diff --git a/lib/CallBackery.pm b/lib/CallBackery.pm index 87b0696..9b6341d 100644 --- a/lib/CallBackery.pm +++ b/lib/CallBackery.pm @@ -37,7 +37,7 @@ use CallBackery::Plugin::Doc; use CallBackery::Database; use CallBackery::User; -our $VERSION = '0.46.2'; +our $VERSION = '0.46.3'; =head2 config @@ -169,12 +169,7 @@ sub startup { $c->res->headers->cache_control('no-cache, no-store, must-revalidate') unless $c->req->url->path =~ m{/resource/.+}; }); - - # on initial startup lets get all the 'stuff' into place - # reconfigure will also create the secretFile. - if (not -f $app->config->secretFile){ - $app->config->reConfigure; - } + if (my $secrets = $app->config->secretFile) { if (-r $secrets) { $app->secrets([ path($app->config->secretFile)->slurp ]); diff --git a/lib/CallBackery/Config.pm b/lib/CallBackery/Config.pm index cff3343..27dddf2 100644 --- a/lib/CallBackery/Config.pm +++ b/lib/CallBackery/Config.pm @@ -18,7 +18,7 @@ CallBackery gets much of its configuration from this config file. =cut -use Mojo::Base -base,-async_await; +use Mojo::Base -base,-async_await, -signatures; use CallBackery::Exception qw(mkerror); use CallBackery::Translate qw(trm); use Config::Grammar::Dynamic; @@ -38,8 +38,16 @@ the name of the config file has file => sub { croak "the file parameter is mandatory" }; -has secretFile => sub { - shift->file.'.secret'; +has secretFile => sub ($self) { + my $secretFile = $self->file.'.secret'; + if (not -f $secretFile){ + open my $rand, '>', $secretFile; + chmod 0600,$secretFile; + print $rand sprintf('%x%x',int(rand()*1e14),int(rand()*1e14)); + close $rand; + chmod 0400,$secretFile; + } + return $secretFile; }; has app => sub { croak "the app parameter is mandatory" }; @@ -137,8 +145,9 @@ sub loadAndNewPlugin { my $module; my $ok; for my $path (@{$self->pluginPath}) { + #$self->log->debug("looking for $plugin in $path"); if (my $e = load_class "${path}::$plugin") { - die mkerror(3894,"Exception: $e") if ref $e; + die mkerror(3894,"Loading ${path}::$plugin: $e") if ref $e; } else { return "${path}::${plugin}"->new(); }