Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_parameters returns all params, not just oauth_ ones #52

Closed
duncanjbrown opened this issue Jan 30, 2015 · 2 comments
Closed

get_parameters returns all params, not just oauth_ ones #52

duncanjbrown opened this issue Jan 30, 2015 · 2 comments

Comments

@duncanjbrown
Copy link
Contributor

I use nginx, and I have a line in my nginx.conf that looks like this:

try_files $uri $uri/ /index.php?q=$uri&$args; 

This means that when my OAuth client hits /oauth1/request, WP receives a q parameter as well as the usual OAuth params. Because WP_JSON_Authentication_OAuth1::get_parameters doesn't strip it out, it's an automatic 401 from the plugin because the signature doesn't match.

I fixed it by unsetting $params['q'] before get_parameters returns. Obviously this won't work in all cases, so I attempted a patch that stripped all params that weren't in

$param_names = array(
            'oauth_consumer_key',
            'oauth_timestamp',
            'oauth_nonce',
            'oauth_signature',
            'oauth_signature_method'
        );

but that caused some other issue. Happy to investigate further if this is considered worth fixing.

@rmccue
Copy link
Member

rmccue commented Mar 8, 2015

This is correct; the way that OAuth signatures work is by signing the entire request. I'm not sure why you have that line in your nginx.conf (it's certainly not required for WP), but you can fix it on the PHP side by doing unset( $_GET['q'] ) if you're unable to change nginx.

@rmccue rmccue closed this as completed Mar 8, 2015
@sftsk
Copy link

sftsk commented Jul 26, 2016

Hello,

just got into the same problem. The mentioned setup for NGINX is needed so WordPress will work behind a Load Balancer under certain circumstances.

Unfortunately it can't be changed. I do not want to unset unset( $_GET['q'] ) globally like mentioned by you as it might break things in other places.

Wouldn't it be possible to provide a filter/ hook to the parameters you are using so that they could be changed for nginx?

Right now I've added this unset($params['q']); after $params = array_merge( $params, $oauth_params ); and it seems to work but I would prefer not to "hack" the plugin.

Thank you for your help and the great plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants