Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#5579 closed defect (bug) (fixed)

XMLRPC Authentication

Reported by: PhoenixRises Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.3.2
Component: XML-RPC Keywords:
Focuses: Cc:


Currently, XMLRPC uses the functions login_pass_ok and user_pass_ok in ~/xmlrpc.php and ~/wp-includes/user.php respectively.

Using this method causes XML-RPC to use the WordPress default login method but does not take into account any other method that may be used.

This can be modified by removing the user_pass_ok function from user.php entirely and replacing the call in login_pass_ok with the pluggable wp_login (see diff file).

I have classed this as an optimzation as it does not in any way affect the functionality of XML-RPC.


Attachments (2)

xmlrpc_user_auth.diff (1021 bytes) - added by PhoenixRises 10 years ago.
5579-Remove-user_pass_ok.diff (1.3 KB) - added by brianlayman 10 years ago.
Move user_pass_ok from user.php to xmlrpc.php

Download all attachments as: .zip

Change History (20)

#1 @PhoenixRises
10 years ago

  • Component changed from Optimization to XML-RPC

#2 @brianlayman
10 years ago

That's funny... It's my day off so I was actually looking at this too. I have a slightly different take on the issue.

In my mind, the bug is that this routine WAS actually moved to XMLRPC as intended, however it was never actually removed from USER when this occured. And because of the include structure (user.php is required into settings.php before pluggable.php is and settings.php is included into xmlrpc.php before user_pass_ok is defined), that function cannot be overridden.

I think the correct fix is simply to delete the extra copy of user_pass_ok from user.php. The function's code in xmlrpc.php is identical to what is in user.php. The only change the userbase would see is that those of us who plugged that function would suddenly have their new routines called.

#3 @brianlayman
10 years ago

BTW commenting the code out in user.php DOES indeed allow the plugged version to be used. This change is required to allow third party tools like LiveWriter and BlogDesk to be used on sites which have custom login systems.

#4 @josephscott
10 years ago

  • Cc josephscott added

#5 @josephscott
10 years ago

The problem with removing user_pass_ok() is that plugins make use of it. Changing it to use wp_login() would save plugin authors some grief.

#6 @brianlayman
10 years ago

Yeah, I know the stuff at b5media uses it and the stuff I wrote for blogs.borland.com uses it too IIRC. So I think we should just remove the extra copy that isn't wrapped with an "if ( !function_exists('user_pass_ok') )"

#7 @josephscott
10 years ago

brianlayman - can you put together a new diff and lets see how it goes from there.

#8 @brianlayman
10 years ago

Easy enough to do... btw YOU may call me Brian....

#9 @josephscott
10 years ago

Ok, I must be missing something, I was thinking of making it look like:

function user_pass_ok($user_login,$user_pass) {
    return wp_login( $user_login, $user_pass );

#10 @brianlayman
10 years ago

See this patch fixes actually allows you to do that. It keeps XMLRPC working the way it does now and provides full backwards compatiblity with the current WordPress but it also allows you to put user_pass_ok into the my-hacks.php or whereever you keep your customizations.

If you want to put a routine in that calls wp_login that's fine but there's a lot of stuff in wp_login that may not be appropriate to an xml connection. Is the "password field is empty" error appropriate? How much cookie stuff is dragged into the mix that isn't needed? I suspect wp_login is way heavier than is actually needed by a blogging too and that that's why it wasn't originally used.

But as I said, with this patch, you can now write code that allows you to make that call... if you want to.

#11 @brianlayman
10 years ago

Oh I see now that the original patch DID include that removal, it just also added the functionality you were suggesting. However, as I implied, I think keeping the xmlrpc interface thin should remain part of the goal and allowing the developer to include more if and only if they have the need should be their option.

#12 @josephscott
10 years ago

Ok, let me take a step back here and look at the idea behind this ticket.

The point seems to be that the auth mechanism in xmlrpc isn't pluggable. But that doesn't seem to be the case, since it all funnels down to get_userdatabylogin() and wp_check_password(), both of which are pluggable.

Which leads me to believe that this ticket is a non-issue.

#13 @brianlayman
10 years ago

Look at it this way: user_pass_ok is supposed to be pluggable. It is written that way in xmlrpc.php, but there's a copy of the legacy function abandoned in user.php. It blocks the pluggablity.

We shouldn't have two copies of the same code and functions that are pluggable should function that way. So this needs to be resolved.

Right now the code in xmlrpc.php can never execute but it is what is meant to be the active pluggable function.

#14 @lloydbudd
10 years ago

  • Version set to 2.3.2

#15 @josephscott
10 years ago

I'm a bit lost here, there is no user_pass_ok() function defined in xmlrpc.php. There is a login_pass_ok() function, that makes use of user_pass_ok(). The only place that user_pass_ok() is defined in WP is in wp-includes/user.php.

To make user_pass_ok() pluggable why don't we move it to pluggable.php and wrap it with a function_exists check?

10 years ago

Move user_pass_ok from user.php to xmlrpc.php

#16 @brianlayman
10 years ago

I see what you mean. The xmlrpc I was working with already had the user_pass_ok added to it by Mark J. I hadn't realized it was edited. I've modified my patch so that you will see exactly what I am seeing.

I don't have a problem with it being in pluggable.php. The include structure should allow it, and I don't think it is used anywhere other than xmlrpc.php, but I haven't searched for it this morning to check...

#17 @ryan
10 years ago

I was thinking of adding wp_authenticate() to pluggable functions. This would be a cleaned up version of wp_login() that returned WP_Error for error conditions. login_pass_ok() could use this and pass any WP_Error message back in its IXR_Error.

#18 @ryan
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

user_pass_ok() now calls the pluggable wp_authenticate function. Should be good enough.

Note: See TracTickets for help on using tickets.