diff options
author | mkanat%bugzilla.org <> | 2007-02-05 00:23:20 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-02-05 00:23:20 +0000 |
commit | d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411 (patch) | |
tree | b953958a9f9cfe5d94a09e86696d08469e4e84e1 | |
parent | 5d158911752d6135900efc160569fa2d8afcb076 (diff) | |
download | bugs-d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411.tar bugs-d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411.tar.gz bugs-d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411.tar.bz2 bugs-d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411.tar.xz bugs-d26bc5f16b26e6e28d1ce952f7f6fd2c36e88411.zip |
Bug 358354: WebService should perform a login in xmlrpc.cgi
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
-rwxr-xr-x | Bugzilla/WebService.pm | 7 | ||||
-rwxr-xr-x | Bugzilla/WebService/Constants.pm | 11 | ||||
-rwxr-xr-x | Bugzilla/WebService/User.pm | 3 | ||||
-rwxr-xr-x | xmlrpc.cgi | 1 |
4 files changed, 19 insertions, 3 deletions
diff --git a/Bugzilla/WebService.pm b/Bugzilla/WebService.pm index b38596f2a..0f32e74be 100755 --- a/Bugzilla/WebService.pm +++ b/Bugzilla/WebService.pm @@ -41,6 +41,13 @@ sub datetime_format { return $iso_datetime; } +sub handle_login { + my ($self, $module, $method) = @_; + my $exempt = LOGIN_EXEMPT->{$module}; + return if $exempt && grep { $_ eq $method } @$exempt; + Bugzilla->login; +} + package Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI; use strict; diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index d1f816c84..39d25298d 100755 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -27,6 +27,8 @@ use base qw(Exporter); ERROR_AUTH_NODATA ERROR_UNIMPLEMENTED + + LOGIN_EXEMPT ); # This maps the error names in global/*-error.html.tmpl to numbers. @@ -98,4 +100,13 @@ use constant ERROR_AUTH_NODATA => 410; use constant ERROR_UNIMPLEMENTED => 910; use constant ERROR_GENERAL => 999; +# For some methods, we shouldn't call Bugzilla->login before we call them. +# This is a hash--package names pointing to an arrayref of method names. +use constant LOGIN_EXEMPT => { + # Callers may have to know the Bugzilla version before logging in, + # even on a requirelogin installation. + Bugzilla => ['version'], + User => ['offer_account_by_email', 'login'], +}; + 1; diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index 74e8f8e03..db02ff75a 100755 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -60,10 +60,7 @@ sub login { sub logout { my $self = shift; - - Bugzilla->login(LOGIN_OPTIONAL); Bugzilla->logout; - return undef; } diff --git a/xmlrpc.cgi b/xmlrpc.cgi index e4dfacc43..c17cab86c 100755 --- a/xmlrpc.cgi +++ b/xmlrpc.cgi @@ -35,4 +35,5 @@ my $response = Bugzilla::WebService::XMLRPC::Transport::HTTP::CGI 'User' => 'Bugzilla::WebService::User', 'Product' => 'Bugzilla::WebService::Product', }) + ->on_action(\&Bugzilla::WebService::handle_login) ->handle; |