Skip to content

Commit

Permalink
Move github credentials and Mojo secret to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders authored and jberger committed Nov 11, 2018
1 parent b805cab commit 064a001
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/MetaCPAN/API.pm
Expand Up @@ -61,8 +61,9 @@ sub startup {
);
}

# TODO secret from config
$self->secrets( [ $ENV{MOJO_SECRET} ] );
die 'need secret' unless $self->config->{secret};

$self->secrets( [ $self->config->{secret} ] );

$self->static->paths( [ $self->home->child('root') ] );

Expand All @@ -83,7 +84,7 @@ sub startup {
$self->minion->add_task(
index_favorite => $self->_gen_index_task_sub('favorite') );

$self->_maybe_set_up_routes;
$self->_set_up_routes;
}

sub _gen_index_task_sub {
Expand Down Expand Up @@ -119,17 +120,16 @@ sub _gen_index_task_sub {
}
}

sub _maybe_set_up_routes {
sub _set_up_routes {
my $self = shift;
return unless $ENV{MOJO_SECRET} && $ENV{GITHUB_KEY};

my $r = $self->routes;

$self->plugin(
'Web::Auth',
module => 'Github',
key => $ENV{GITHUB_KEY},
secret => $ENV{GITHUB_SECRET},
key => $self->config->{github_key},
secret => $self->config->{github_secret},
on_finished => sub {
my ( $c, $access_token, $account_info ) = @_;
my $login = $account_info->{login};
Expand Down
5 changes: 5 additions & 0 deletions metacpan_server_testing.conf
Expand Up @@ -17,3 +17,8 @@ source_base var/t/tmp/source
captcha_class Captcha::Mock
private_key testing
</controller>

github_key = foo
github_secret = bar

secret weak

0 comments on commit 064a001

Please sign in to comment.