Closed (fixed)
Project:
Services
Version:
6.x-2.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Oct 2008 at 00:35 UTC
Updated:
12 Apr 2011 at 20:33 UTC
Jump to comment: Most recent file
Comments
Comment #1
greg.harveyWeird. It works fine for me. You have set up your services module permissions to allow anonymous access to services, haven't you?
... admin/user/permissions
Comment #2
greenskin commentedWe have given a specific role permissions to use services and the services method page. It his on the services method list page where when the views.get method is selected and then called, that it returns 'access denied'. When permissions are given to the services role to 'access all views' then the proper result is returned for the views.get method. When 'access all views' is not set for the user's role then basic views access is used and even when the specific views access is set to unrestricted, 'access denied' is still given.
Comment #3
greenskin commentedNote: this issue pertains to Views 2. The issue is caused by the function 'views_access' being used in the function 'views_service_get_access'.
Comment #4
greg.harveyI'm using Views 2 as well, but 6.x-2.x-rc1 ... updates to later release candidates caused handlers (amongst other things) to break because of the changes in API between rc1 and rc2, so you may be on to something there.
Comment #5
greenskin commentedCorrect, we are now using the 6.x-2.x-rc4 of Views. Currently we have just set permissions for 'access all views' to all roles needing access via services as all of our views do not need access restricted, so we can get by for now that way.
Comment #6
greg.harveyOk, I can now second this!
We just upgraded for Views 6.x-2.1 - the problem is the views_access() function relied upon by views_service_get_access() (the access callback for views.get) has changed. You used to pass it a view object to check, but it now accepts no object - it assumes the view is already resident in memory somewhere. I'm still picking through how it works, with a view to supplying a patch.
Comment #7
greenskin commentedViews 2 now uses $view->access() to validate instead of views_access(). Thought I'd try to save you a little time if you hadn't found how to do it yet.
Comment #8
greg.harveyAh, brilliant! Thank you. I just posted a support request over in Views too. You couldn't rustle up a patch could you? If not, I'll work it out. =)
Comment #9
greg.harveyI'm not sure what you mean by "users $view->access() to validate" ...? My views (using Views 6.x-2.1) don't have this. The only place access appears is here:
Which would be
$view->display['default']->display_options['access']*and* is not a boolean so could not be used as an access callback...? :-/Maybe there's been another change?
Comment #10
greenskin commentedI've been meaning to test it out but have not found the time yet.
The access() is a method of the views object, so you shouldn't be seeing it in the object when printed out.
http://drupal.org/node/318274
Comment #11
greenskin commentedOk, I did a little more digging at found that $view->access() can take two parameters. The first being the display and the second being the user account object. Neither one is required though I'm not sure why since it looks like if a display is not given then it returns false. The second parameter is not the problem it is the first as I mentioned previously when the first parameter is not given it returns false.
So in order to provide a display, the views service needs another option added of display. Chances are that the other views service methods will need reworked as well.
Comment #12
greg.harveyMe too!
http://views.doc.logrus.com/classview.html#996e7b183eb9d43ec9d535dbf897616a
This works:
$view->access('default');So I guess the service needs another optional parameter - 'display'. Or one can take the view that the default display will always be loaded?
Comment #13
greg.harveyCoincidentally, all of the below are valid:
And also, if you want to check the access to a display for a specific user, you could do something like this:
Hmmm, I feel a blog post coming on! ;-)
Comment #14
greenskin commentedSo then the views service methods should allow for a display arg that is optional. If the display arg is left blank than 'default' display is used, or a string or an array can be used and passed to $view->access($display) successfully.
Good start. :P
Comment #15
greg.harveyOk, patches attached! =)
In a nutshell:
1. New argument for views.get, display_id (terminology taken from Views to be consistent), accepting the display name to use.
2. views_service_get() function updated to accept $display_id and set the view object accordingly
3. views_service_get() documentation updated
4. views_service_get_access() function updated to use the correct access check and check access to the specific requested display_id ('default' if none specified)
They seem to work for me. Please review.
IMPORTANT: Kitten killing patch de-listed and will be re-posted elsewhere.
Comment #16
greg.harveyI always forget to change the status! =)
Comment #17
greenskin commentedSince the display_id is optional and defaults to 'default' then where the function parameters are defined, $default should actually be $default = 'default' and the following is not needed:
Comment #18
greg.harveyI tried that and it wasn't working, hence the lines you highlight. I think it's because of the API.
The problem is this, AFAIK:
When you make a method call over XMP-RPC you must provide an XML element for all arguments. I think this is exposes a small bug in the Services module. In effect, it forces you to send
$default_id = '', which you would expect the Services module to ignore and use defaults instead. It does not - instead it passes the empty string on.Consequently, normally you would be correct but in this case those lines *are* required, to substitute the empty string the Services module passes on from your method call with the string of 'default', and it won't work without them. It receives a string (albeit empty) from the Services module, thus ignores the default value you set and breaks. =(
Comment #19
greenskin commentedYes, but when using xmlrpc, the defaults for all parameters should be used, therefore $display_id should be passed as 'default'. Other servers like amfphp are not as picky. Passing a blank $display_id should return the same errors as if one that doesn't exist is passed. Also, by not setting $display_id = 'default' where the parameters are defined would break any other server that does not require all parameters to be filled even though $display_id is set as optional in services.
Also, I think you forgot to remove 'test' from $fields = array('test') in your patch.
Comment #20
greg.harveyHmm, ok - so what is the point of the "Optional" parameter in the Services API for hook_service() then? Is this for other server types? From what you're saying NOTHING is optional with XML-RPC (which was my experience anyway - I guess this is by design...?)
Anyway, thanks - I'll update the patch. I don't have access to the code today, so I'll do it tomorrow. =)
Comment #21
greenskin commentedThe "Optional" parameter in the Services API is for server types that don't require all of the parameters like XML-RPC does. And for the "optional" part to work, the function needs to define the default value for the variable.
Comment #22
greg.harveyGotcha. Makes perfect sense! Thanks!
I think I need to update a few of my other services, now I properly understand what optional is for in the API and how it should be implemented. =)
Comment #23
greenskin commentedNo problem, glad I could help.
Changing status to code needs work.
Comment #24
greg.harveyOk, new version of the .inc file patch attached. Please re-review, if you get a chance. =)
IMPORTANT: Kitten killing patch de-listed and will be re-posted elsewhere.
Comment #25
voxpelli commentedHere comes a patch fixing this issue.
I first tried out greg.harvey's patch - but I don't like that it breaks my current API-calls.
Adding display_id as a parameter to the view.get service is as far as I understand out of the scope of this issue.
My patch only fixes the access denied problem - if the display_id should be configurable another issue should be started for that I think.
Comment #26
voxpelli commentedThis is a code issue btw.
Comment #27
greg.harveyFair enough - I did a bit of kitten killing there. I'll create a feature request and post my patch there.
I haven't applied yours, but it's so simple it *looks* fine. Won't change the status though having not actually tried to apply it and use it - I'm using my patch now, because I need the extra functionality anyway. =)
Looking for the previously discussed patch? Go here: http://drupal.org/node/339754
Comment #28
danielb commentedOK I'm lost
What did you guys figure out?
I can't get this module to work
Comment #29
danielb commentedhey hey #25 has the answer
This fixes it. Well done mate.
That was posted 3 months ago - and I still downloaded a broken copy of this module from the project home page...
There has been no release in almost 6 months, and the module does not work. Is this project abandoned?
Comment #30
marcingy commentedHmm no, it is called having day jobs ;) If you want to help review patches and help the project move along that would great.
Comment #31
voxpelli commentedIf I understand danielb correctly in #29 the patch I posted in #25 works for him - therefor I'm marking this as reviewed and tested
Comment #32
greg.harveyI've a feeling this is actually superceded by other changes to the module already committed to HEAD, but I'm not sure without checking...
Comment #33
marcingy commentedNo this fixed in the current dev version for 6.x. I will attempt to get this patch up in the next few days.
Comment #34
snelson commentedCommitted to D6 dev #171827
Comment #36
jcgentry0260 commentedhi, I'm still having trouble with the services views.get. I am using services 6.x-2.x-dev. I have all permissions open. I tried the suggested patch but it failed. Can someone help me please?
Comment #37
jcgentry0260 commentedhi, I'm still having trouble with the services views.get. I am using services 6.x-2.x-dev. I have all permissions open. I tried the suggested patch but it failed. Can someone help me please?
Comment #38
juice1492 commentedsimilar to post #37, I'm still having problems with Access Denied when using views.get via XMLRPC, both through the durpal service browser and through a php test client. I'm able to access both the node and file services via the test client but always get Access Denied when attempting a views.get. I'm running Views 6.x-2.11 and Services version 6.x-2.2. I've checked the view_services.inc and it has this function:
My view has Access: Unrestricted.
The Views Service is enabled.
When I go to UserManagement->Permissions, there is no option to set permission for views_service module but there are permissions for node_services, file_services, user_services etc. Should there be permissions for view_services and if so, how do I enable it.
Juice
Comment #39
juice1492 commentedAfter tracing through the code, I found that the _services_keyauth_authenticate_call in services/auth/services_keyauth.inc did a query to the db looking for a value in the services_key_permissions table. On my install, there was no value for the views.get method. I inserted a record into the db with the service key and method name:
INSERT INTO services_key_permissions (`kid`, `method`) VALUES ('yourkeyhere', 'views.get');
After doing this, I realized that there were options under the Administrator/SiteBuilding/Services/Key/Edit that displays which methods the key has permissions to perform. So make sure if your using key authentication to make sure your key has permissions for the services you want to use. Hope this helps someone else.
Juice
Comment #41
kmox83 commentedTo whom it may concearn I still had problems with this patch, I had to fix it with the hook_perm because also when the view was not found the given error was 401 (access denied) instead of 404 (Not Found).
Comment #42
voxpelli commentedPost a new issue instead of bumping old fixed ones.
Comment #43
voxpelli commented@kmox83: That bug has been fixed in http://drupal.org/project/services_views