OAuthFilter:oauth2_token to rejects headers that explicitly state oauth_version="1.0" #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Pelle,
I've used your plugin in a couple of projects. Thanks for this contribution!
In my most recent project (Rails3, using pre0.4) I ran into a problem where OAuth1 tokens where being mistaken as OAuth2 tokens. I traced this to requests where there was no whitespace between the parameters in the HTTP_Authorization. Requests with whitespace were correctly identified, requests without whitespace were not.
According to the standard (section 3.5.1 Authorization Header):
OPTIONAL linear whitespace per [RFC2617].
OAuthFilter:oauth2_token was using this optional behavior to discriminate between oauth1 and oauth2 tokens. While most OAuth clients put whitespace between their parameters, some clients do not. The filter was mis-identifying these tokens as OAuth2 tokens, breaking the authentication chain.
I've added an explicit check for oauth_version="1.0". If this is present, then the token is rejected.
According to the standard (section 3.1. Making Requests):
When oauth_version is missing, oauth2_token defaults to checking for whitespace between the parameters.
In oauth_filter_spec I added a section (describe 'without optional whitespace') which creates authentication headers but without white space between the parameters. As these are well formed requests (according to the standard) they should pass. If you comment out the check (oauth_filter.rb , line 88) you will see that these properly formed requests fail.
Thanks again for a great plugin!