summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorbbaetz%acm.org <>2008-04-17 20:26:12 +0200
committerbbaetz%acm.org <>2008-04-17 20:26:12 +0200
commit22ac4064da3f75f68df8bc939e6d5399f57a3ba8 (patch)
tree9ed8f59fbe364c2c4efc7c96c6e250e60126418a /Bugzilla
parent32b928bab4ad3715e151bad7aa1609a2dc91266d (diff)
downloadbugzilla-22ac4064da3f75f68df8bc939e6d5399f57a3ba8.tar.gz
bugzilla-22ac4064da3f75f68df8bc939e6d5399f57a3ba8.tar.xz
Bug 428941 – Allow extension webservices to override LOGIN_EXEMPT
r/a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/WebService.pm20
-rwxr-xr-xBugzilla/WebService/Bugzilla.pm6
-rwxr-xr-xBugzilla/WebService/Constants.pm11
-rwxr-xr-xBugzilla/WebService/User.pm6
4 files changed, 29 insertions, 14 deletions
diff --git a/Bugzilla/WebService.pm b/Bugzilla/WebService.pm
index 72994cb65..a2313803d 100755
--- a/Bugzilla/WebService.pm
+++ b/Bugzilla/WebService.pm
@@ -42,10 +42,24 @@ sub datetime_format {
}
sub handle_login {
- my ($self, $module, $method) = @_;
- my $exempt = LOGIN_EXEMPT->{$module};
- return if $exempt && grep { $_ eq $method } @$exempt;
+ my ($classes, $action, $uri, $method) = @_;
+
+ my $class = $classes->{$uri};
+ eval "require $class";
+
+ return if $class->login_exempt($method);
Bugzilla->login;
+
+ return;
+}
+
+# For some methods, we shouldn't call Bugzilla->login before we call them
+use constant LOGIN_EXEMPT => { };
+
+sub login_exempt {
+ my ($class, $method) = @_;
+
+ return $class->LOGIN_EXEMPT->{$method};
}
1;
diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm
index c6b0218cf..dde9cfd4b 100755
--- a/Bugzilla/WebService/Bugzilla.pm
+++ b/Bugzilla/WebService/Bugzilla.pm
@@ -26,6 +26,12 @@ import SOAP::Data qw(type);
use Time::Zone;
+# Basic info that is needed before logins
+use constant LOGIN_EXEMPT => {
+ timezone => 1,
+ version => 1,
+};
+
sub version {
return { version => type('string')->value(BUGZILLA_VERSION) };
}
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm
index 85640d1bc..42ad43120 100755
--- a/Bugzilla/WebService/Constants.pm
+++ b/Bugzilla/WebService/Constants.pm
@@ -27,8 +27,6 @@ use base qw(Exporter);
ERROR_AUTH_NODATA
ERROR_UNIMPLEMENTED
-
- LOGIN_EXEMPT
);
# This maps the error names in global/*-error.html.tmpl to numbers.
@@ -108,13 +106,4 @@ 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', 'timezone'],
- User => ['offer_account_by_email', 'login'],
-};
-
1;
diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm
index f839e2a9d..d0ce706f0 100755
--- a/Bugzilla/WebService/User.pm
+++ b/Bugzilla/WebService/User.pm
@@ -30,6 +30,12 @@ use Bugzilla::User;
use Bugzilla::Util qw(trim);
use Bugzilla::Token;
+# Don't need auth to login
+use constant LOGIN_EXEMPT => {
+ login => 1,
+ offer_account_by_email => 1,
+};
+
##############
# User Login #
##############