Closed (fixed)
Project:
Services
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Jul 2011 at 19:53 UTC
Updated:
17 Aug 2011 at 07:42 UTC
In services_controller_execute() there is this code
$original_user = $user;
$old_state = drupal_save_session();
drupal_save_session(FALSE);
$user = drupal_anonymous_user();
which seems to negate the use of the login service since the access callback is now dealing with the anonymous user. This seem particulary progmatic if you define access arguments and let the callback default to user_access().
Can someone please explain the logic of forcing the anonymous user?
Thanks
Comments
Comment #1
voxpelli commentedDue to some security vulnerabilities involving eg. CSRF-attacks against Services API:s we've changed Services to completely rely on authentication mechanisms to define what user a method should execute as - if no authentication mechanism alters the user then all Services calls are anonymous.
There's a new authentication mechanism that restores the old session based authentication. You should however be aware that certain combinations of request formats, session based authentication and resources will make your API vulnerable to CSRF-attacks.
Comment #2
sitiveni commentedHi there, got a follow up question/remark to authentication in services_controller_execute(): what's the intention behind running this final bit of code in function services_controller_execute():
Function session_save_session() (renamed to drupal_save_session()) expects parameter $status to be either TRUE or FALSE:
So when calling session_save_session() with the user object and verifying then on FALSE, the code in the condition will never get executed.
Isn't the idea to switch back to the original user after the execution process? So wouldn't it make sense to set the user back to the original user in any case (no condition, just execute the code)?
Not sure if I get the meaning of it; I'm open for explanation. Thanks
This affects version 6.x-3.0-rc2 (also dev); haven't checked D7.
Comment #3
voxpelli commentedI'm not sure how it works on D6 - the intention is to restore the old user unless the user has been logged in or logged out or something like that.