summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService/Util.pm
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-08-29 23:25:24 +0200
committerDave Lawrence <dlawrence@mozilla.com>2013-08-29 23:25:24 +0200
commit99589d82d943bedcd9a8ade3d91f84d770fcd5c5 (patch)
tree25d4f8baedfe28e592a7226b4276523423132963 /Bugzilla/WebService/Util.pm
parentbbf877a6b1500f59988245954f40cee5ebec0a85 (diff)
downloadbugzilla-99589d82d943bedcd9a8ade3d91f84d770fcd5c5.tar.gz
bugzilla-99589d82d943bedcd9a8ade3d91f84d770fcd5c5.tar.xz
Bug 909634 - backport upstream bug 893195 to bmo/4.2 for token auth support in webservices
Diffstat (limited to 'Bugzilla/WebService/Util.pm')
-rw-r--r--Bugzilla/WebService/Util.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/Bugzilla/WebService/Util.pm b/Bugzilla/WebService/Util.pm
index cda88e260..622e6890b 100644
--- a/Bugzilla/WebService/Util.pm
+++ b/Bugzilla/WebService/Util.pm
@@ -33,6 +33,7 @@ our @EXPORT_OK = qw(
taint_data
validate
params_to_objects
+ fix_credentials
);
sub filter ($$;$) {
@@ -146,6 +147,22 @@ sub params_to_objects {
return \@objects;
}
+sub fix_credentials {
+ my ($params) = @_;
+ # Allow user to pass in login=foo&password=bar as a convenience
+ # even if not calling GET /login. We also do not delete them as
+ # GET /login requires "login" and "password".
+ if (exists $params->{'login'} && exists $params->{'password'}) {
+ $params->{'Bugzilla_login'} = $params->{'login'};
+ $params->{'Bugzilla_password'} = $params->{'password'};
+ }
+ # Allow user to pass token=12345678 as a convenience which becomes
+ # "Bugzilla_token" which is what the auth code looks for.
+ if (exists $params->{'token'}) {
+ $params->{'Bugzilla_token'} = $params->{'token'};
+ }
+}
+
__END__
=head1 NAME
@@ -201,6 +218,12 @@ Helps make life simpler for WebService methods that internally create objects
via both "ids" and "names" fields. Also de-duplicates objects that were loaded
by both "ids" and "names". Returns an arrayref of objects.
+=head2 fix_credentials
+
+Allows for certain parameters related to authentication such as Bugzilla_login,
+Bugzilla_password, and Bugzilla_token to have shorter named equivalents passed in.
+This function converts the shorter versions to their respective internal names.
+
=head1 B<Methods in need of POD>
=over