Skip to content

Commit 2c3a839

Browse files
author
Dylan Hardison
committed
Bug 1209625 - MozReview API Keys should use a more specific error message
1 parent 771547c commit 2c3a839

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Bugzilla/WebService/Server.pm

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ use Bugzilla::Error;
2222
use Bugzilla::Util qw(datetime_from);
2323

2424
use Digest::MD5 qw(md5_base64);
25-
use Encode;
2625
use Scalar::Util qw(blessed);
2726
use Storable qw(freeze);
28-
use Sys::Syslog qw(:DEFAULT);
2927

3028
sub handle_login {
3129
my ($self, $class, $method, $full_method) = @_;
@@ -38,13 +36,7 @@ sub handle_login {
3836
}
3937

4038
eval "require $class";
41-
my $error = $@;
42-
if ($error) {
43-
openlog('apache', 'cons,pid', 'local4');
44-
syslog('notice', '[rpc_error] ' . encode_utf8($error));
45-
closelog();
46-
}
47-
ThrowCodeError('unknown_method', {method => $full_method}) if $error;
39+
ThrowCodeError('unknown_method', {method => $full_method}) if $@;
4840
return if ($class->login_exempt($method)
4941
and !defined Bugzilla->input_params->{Bugzilla_login});
5042
Bugzilla->login();

extensions/MozReview/Extension.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ sub webservice_before_call {
100100
my $app_id = $getter->app_id;
101101
if ($app_id eq $mozreview_app_id) {
102102
unless (any { $full_method eq $_ } @METHOD_WHITELIST) {
103-
ThrowCodeError('unknown_method', { method => $full_method });
103+
ThrowUserError('forbidden_method', { method => $full_method });
104104
}
105105
}
106106
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[%# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# This Source Code Form is "Incompatible With Secondary Licenses", as
6+
# defined by the Mozilla Public License, v. 2.0.
7+
#%]
8+
9+
[% IF error == "forbidden_method" %]
10+
The requested method '[% method FILTER html %]' is not allowed to be called using the current API Key.
11+
[% END %]

0 commit comments

Comments
 (0)