When I upgraded from 6.x-0.15 all functions that had key parameter set to TRUE stopped working.
(I have key authentication and Use sessid turned on.)

Here is an example:

// My function
array(
'#method' => 'ri.myFunction',
'#callback' => 'mymodule_myfunction,
'#access callback' => 'mymodule_myfunction_access',
'#file' => array('file' => 'inc', 'module' => 'ri_service'),
'#key' => TRUE,
'#args' => array(
array(
'#name' => 'param1,
'#type' => 'string',
'#description' => t('Param1.')
),
),
'#return' => 'array',
'#help' => t('Gets stuff.')
),

If finally figured out that the problem was that somehow, setting the key parameter to true still makes Services think it is false.
Since default value for the key parameter is TRUE, I solved the problem by removing the parameter altogether. Now, only the functions that should NOT use the key have it.

A more general note - and hoping not to sound as a spoiled brat - I wish that the documentation regarding authentication was more up to date, because now it is really confusing.

Thanks for all your great efforts!

CommentFileSizeAuthor
#2 707120.patch926 bytesgdd

Comments

marcingy’s picture

Component: Code » Documentation

updating component

gdd’s picture

Component: Documentation » Code
Status: Active » Needs review
StatusFileSize
new926 bytes

This is in fact a bug in the code and it lies here in services_keyauth.inc:

        $method['key'] = isset($method['key']) ? FALSE : TRUE;
        $method['auth'] = isset($method['auth']) ? FALSE : TRUE;

This checks to see if the $method['key'] is set, but if its set it never checks the value. It just assumes that nobody would set the default value. The code shouldn't care about the value if it is set, it should just take care of when it is not set.

The attached patch addresses this, although note I have not test it at all. PWG can you try it out?

gdd’s picture

As background this bug was introduced here:

#646620: Auth required even if #auth is set to FALSE

PWG’s picture

Thumbs up from me. Great work!

gdd’s picture

Status: Needs review » Fixed

This is committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.