Skip to content

Commit

Permalink
do not automatically reconfigure everyting if the secret file is miss…
Browse files Browse the repository at this point in the history
…ing. just create the secret
  • Loading branch information
oetiker committed Jun 14, 2023
1 parent 1479bde commit 8b7481c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 2 additions & 7 deletions lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ]);
Expand Down
17 changes: 13 additions & 4 deletions lib/CallBackery/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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" };
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 8b7481c

Please sign in to comment.