Skip to content

Commit

Permalink
block rpc if not authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Feb 28, 2023
1 parent bd2e32c commit c146b6b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.10.2 2023-02-28 16:13:17 +0100 Tobias Oetiker <tobi@oetiker.ch>

- block rpc calls if there is no session

0.10.1 2023-02-28 15:30:30 +0100 Tobias Oetiker <tobi@oetiker.ch>

- if openid_url is configured, redirect to openid/auth
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.1
0.10.2
4 changes: 2 additions & 2 deletions lib/EP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ sub startup {
$routes->get('/' => sub {
my $self = shift;
if ($gcfg->{openid_url} and not $self->session->{epUser}){
return $self->redirect_to('./openid/auth');
return $self->redirect_to('openid/auth');
}
return $self->redirect_to('./'.$app->prefix);
return $self->redirect_to('/'.$app->prefix);
});

$app->plugin('EP::DocPlugin', {
Expand Down
6 changes: 3 additions & 3 deletions lib/EP/RpcService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ has 'log' => sub { shift->app->log };
sub allow_rpc_access {
my $self = shift;
my $method = shift;

die mkerror(3993,q{Your session has expired. Please re-connect.}) unless defined $self->user;
if (not defined $self->user or ($self->cfg->{GENERAL}{openid_url} and not $self->session('epUser'))) {
die mkerror(3993,q{Your session has expired. Please re-connect.});
}
return $allow{$method};
}


=head2 getConfig()
Expand Down
4 changes: 2 additions & 2 deletions share/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: ep 0.10.1\n"
"Project-Id-Version: ep 0.10.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-28 15:32+0100\n"
"POT-Creation-Date: 2023-02-28 16:16+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
2 changes: 1 addition & 1 deletion t/00-load-and-ping.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ $t->post_ok('/app/jsonrpc', json => {
})
->status_is(200)
->content_type_is('application/json; charset=utf-8')
->json_is('/error/message' => 'rpc access to method ping denied');
->json_is('/error/message' => 'Your session has expired. Please re-connect.');

done_testing();

0 comments on commit c146b6b

Please sign in to comment.