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

OAuthFilter:oauth2_token to rejects headers that explicitly state oauth_version="1.0" #86

Merged
merged 1 commit into from Oct 20, 2011

Conversation

KentonWhite
Copy link
Contributor

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):

  1. Parameters are separated by a "," character (ASCII code 44) and
    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):

   oauth_version
     OPTIONAL.  If present, MUST be set to "1.0".  Provides the
     version of the authentication process as defined in this
     specification.

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!

…th_version="1.0"

OAuth 1 allows whitespace between the header parameters, but this is optional.  OAuthFilter was using this optionsl 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.

oauth2_token now checks if oauth_version="1.0".  If this is present, then the token is rejected.  oauth_version is an optional paramter.  When it is missing, oauth2_token then defaults to checking for whitespace between the parameters.
pelle added a commit that referenced this pull request Oct 20, 2011
OAuthFilter:oauth2_token to rejects headers that explicitly state oauth_version="1.0"
@pelle pelle merged commit 3fa9f93 into pelle:master Oct 20, 2011
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

Successfully merging this pull request may close these issues.

None yet

2 participants