Commit 52b113cc authored by David Lawrence's avatar David Lawrence

Backout of Bug 1001462 - Bug.search causes error when using simple token auth…

Backout of Bug 1001462 - Bug.search causes error when using simple token auth and specifying 'token' instead of 'Bugzilla_token'
parent d694e688
...@@ -115,7 +115,6 @@ our @ISA = qw(XMLRPC::Deserializer); ...@@ -115,7 +115,6 @@ our @ISA = qw(XMLRPC::Deserializer);
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::WebService::Constants qw(XMLRPC_CONTENT_TYPE_WHITELIST); use Bugzilla::WebService::Constants qw(XMLRPC_CONTENT_TYPE_WHITELIST);
use Bugzilla::WebService::Util qw(fix_credentials);
use Scalar::Util qw(tainted); use Scalar::Util qw(tainted);
sub deserialize { sub deserialize {
...@@ -139,11 +138,6 @@ sub deserialize { ...@@ -139,11 +138,6 @@ sub deserialize {
my $params = $som->paramsin; my $params = $som->paramsin;
# This allows positional parameters for Testopia. # This allows positional parameters for Testopia.
$params = {} if ref $params ne 'HASH'; $params = {} if ref $params ne 'HASH';
# Update the params to allow for several convenience key/values
# use for authentication
fix_credentials($params);
Bugzilla->input_params($params); Bugzilla->input_params($params);
return $som; return $som;
} }
......
...@@ -54,10 +54,16 @@ sub login { ...@@ -54,10 +54,16 @@ sub login {
# Username and password params are required # Username and password params are required
foreach my $param ("login", "password") { foreach my $param ("login", "password") {
(!defined $params->{$param} && !defined $params->{'Bugzilla_' . $param}) defined $params->{$param}
|| ThrowCodeError('param_required', { param => $param }); || ThrowCodeError('param_required', { param => $param });
} }
# Make sure the CGI user info class works if necessary.
my $input_params = Bugzilla->input_params;
$input_params->{'Bugzilla_login'} = $params->{login};
$input_params->{'Bugzilla_password'} = $params->{password};
$input_params->{'Bugzilla_restrictlogin'} = $params->{restrict_login};
my $user = Bugzilla->login(); my $user = Bugzilla->login();
my $result = { id => $self->type('int', $user->id) }; my $result = { id => $self->type('int', $user->id) };
......
...@@ -261,17 +261,18 @@ sub params_to_objects { ...@@ -261,17 +261,18 @@ sub params_to_objects {
sub fix_credentials { sub fix_credentials {
my ($params) = @_; my ($params) = @_;
# Allow user to pass in login=foo&password=bar as a convenience
# Allow user to pass in login, password, restrict_login, and # even if not calling GET /login. We also do not delete them as
# token as short-cuts to the longer versions. # GET /login requires "login" and "password".
$params->{'Bugzilla_login'} = delete $params->{'login'} if (exists $params->{'login'} && exists $params->{'password'}) {
if exists $params->{'login'}; $params->{'Bugzilla_login'} = $params->{'login'};
$params->{'Bugzilla_password'} = delete $params->{'password'} $params->{'Bugzilla_password'} = $params->{'password'};
if exists $params->{'password'}; }
$params->{'Bugzilla_restrictlogin'} = delete $params->{'restrict_login'} # Allow user to pass token=12345678 as a convenience which becomes
if exists $params->{'restrict_login'}; # "Bugzilla_token" which is what the auth code looks for.
$params->{'Bugzilla_token'} = delete $params->{'token'} if (exists $params->{'token'}) {
if exists $params->{'token'}; $params->{'Bugzilla_token'} = $params->{'token'};
}
# Allow extensions to modify the credential data before login # Allow extensions to modify the credential data before login
Bugzilla::Hook::process('webservice_fix_credentials', { params => $params }); Bugzilla::Hook::process('webservice_fix_credentials', { params => $params });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment