Skip to content

Commit

Permalink
Merge branch 'master' into docs-jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHuot committed Aug 12, 2018
2 parents f0958f0 + 52bd38d commit 21040fb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oauthlib/common.py
Expand Up @@ -114,7 +114,7 @@ def decode_params_utf8(params):
return decoded


urlencoded = set(always_safe) | set('=&;:%+~,*@!()/?')
urlencoded = set(always_safe) | set('=&;:%+~,*@!()/?\'$')


def urldecode(query):
Expand Down
2 changes: 2 additions & 0 deletions oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
Expand Up @@ -312,6 +312,8 @@ def validate_authorization_request(self, request):
log.debug('Using default redirect_uri %s.', request.redirect_uri)
if not request.redirect_uri:
raise errors.MissingRedirectURIError(request=request)
if not is_absolute_uri(request.redirect_uri):
raise errors.InvalidRedirectURIError(request=request)

# Then check for normal errors.

Expand Down
4 changes: 4 additions & 0 deletions oauthlib/oauth2/rfc6749/parameters.py
Expand Up @@ -279,6 +279,10 @@ def parse_implicit_response(uri, state=None, scope=None):
fragment = urlparse.urlparse(uri).fragment
params = dict(urlparse.parse_qsl(fragment, keep_blank_values=True))

for key in ('expires_in',):
if key in params: # cast things to int
params[key] = int(params[key])

if 'scope' in params:
params['scope'] = scope_to_list(params['scope'])

Expand Down
2 changes: 1 addition & 1 deletion tests/oauth2/rfc6749/clients/test_mobile_application.py
Expand Up @@ -40,7 +40,7 @@ class MobileApplicationClientTest(TestCase):
token = {
"access_token": "2YotnFZFEjr1zCsicMWpAA",
"token_type": "example",
"expires_in": "3600",
"expires_in": 3600,
"expires_at": 4600,
"scope": scope,
"example_parameter": "example_value"
Expand Down
16 changes: 16 additions & 0 deletions tests/oauth2/rfc6749/endpoints/test_error_responses.py
Expand Up @@ -44,6 +44,22 @@ def test_invalid_redirect_uri(self):
self.assertRaises(errors.InvalidRedirectURIError,
self.mobile.create_authorization_response, uri.format('token'), scopes=['foo'])

def test_invalid_default_redirect_uri(self):
uri = 'https://example.com/authorize?response_type={0}&client_id=foo'
self.validator.get_default_redirect_uri.return_value = "wrong"

# Authorization code grant
self.assertRaises(errors.InvalidRedirectURIError,
self.web.validate_authorization_request, uri.format('code'))
self.assertRaises(errors.InvalidRedirectURIError,
self.web.create_authorization_response, uri.format('code'), scopes=['foo'])

# Implicit grant
self.assertRaises(errors.InvalidRedirectURIError,
self.mobile.validate_authorization_request, uri.format('token'))
self.assertRaises(errors.InvalidRedirectURIError,
self.mobile.create_authorization_response, uri.format('token'), scopes=['foo'])

def test_missing_redirect_uri(self):
uri = 'https://example.com/authorize?response_type={0}&client_id=foo'

Expand Down
2 changes: 1 addition & 1 deletion tests/oauth2/rfc6749/test_parameters.py
Expand Up @@ -86,7 +86,7 @@ def setUp(self):
'access_token': '2YotnFZFEjr1zCsicMWpAA',
'state': state,
'token_type': 'example',
'expires_in': '3600',
'expires_in': 3600,
'expires_at': 4600,
'scope': ['abc']
}
Expand Down
2 changes: 2 additions & 0 deletions tests/test_common.py
Expand Up @@ -39,6 +39,8 @@ def test_urldecode(self):
self.assertItemsEqual(urldecode('foo=bar@spam'), [('foo', 'bar@spam')])
self.assertItemsEqual(urldecode('foo=bar/baz'), [('foo', 'bar/baz')])
self.assertItemsEqual(urldecode('foo=bar?baz'), [('foo', 'bar?baz')])
self.assertItemsEqual(urldecode('foo=bar\'s'), [('foo', 'bar\'s')])
self.assertItemsEqual(urldecode('foo=$'), [('foo', '$')])
self.assertRaises(ValueError, urldecode, 'foo bar')
self.assertRaises(ValueError, urldecode, '%R')
self.assertRaises(ValueError, urldecode, '%RA')
Expand Down

0 comments on commit 21040fb

Please sign in to comment.