summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIb Lundgren <ib.lundgren@gmail.com>2013-06-21 12:22:38 +0100
committerIb Lundgren <ib.lundgren@gmail.com>2013-06-21 12:22:38 +0100
commite720baf5b38fe722dfa19b76d0ebbb4d5fbb20ec (patch)
treed7126ec214f6ebb94836eb8d6c8146701fff3bb4
parent035d46c73ab7feb4719e4642dafc9bb21aa8bd2c (diff)
downloadoauthlib-e720baf5b38fe722dfa19b76d0ebbb4d5fbb20ec.tar.gz
Allow realm to be passed in URI and Body. Fix #139.
-rw-r--r--oauthlib/oauth1/rfc5849/endpoints/base.py11
-rw-r--r--tests/oauth1/rfc5849/endpoints/test_request_token.py10
2 files changed, 16 insertions, 5 deletions
diff --git a/oauthlib/oauth1/rfc5849/endpoints/base.py b/oauthlib/oauth1/rfc5849/endpoints/base.py
index 4d85c9a..a510ded 100644
--- a/oauthlib/oauth1/rfc5849/endpoints/base.py
+++ b/oauthlib/oauth1/rfc5849/endpoints/base.py
@@ -2,8 +2,8 @@
from __future__ import absolute_import, unicode_literals
"""
-oauthlib.oauth1.rfc5849
-~~~~~~~~~~~~~~
+oauthlib.oauth1.rfc5849.endpoints.base
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This module is an implementation of various logic needed
for signing and checking OAuth 1.0 RFC 5849 requests.
@@ -99,7 +99,10 @@ class BaseEndpoint(object):
# Parameters to Client depend on signature method which may vary
# for each request. Note that HMAC-SHA1 and PLAINTEXT share parameters
- request.params = filter(lambda x: x[0] not in ("oauth_signature", "realm"), params)
+ request.params = [(k, v) for k, v in params if k != "oauth_signature"]
+
+ if 'realm' in request.headers.get('Authorization', ''):
+ request.params = [(k, v) for k, v in request.params if k != "realm"]
return request
@@ -159,8 +162,6 @@ class BaseEndpoint(object):
# To avoid the need to retain an infinite number of nonce values for
# future checks, servers MAY choose to restrict the time period after
# which a request with an old timestamp is rejected.
- print(self.request_validator.timestamp_lifetime)
- print(float(self.request_validator.timestamp_lifetime))
if abs(time.time() - ts) > self.request_validator.timestamp_lifetime:
raise errors.InvalidRequestError(
description=('Timestamp given is invalid, differ from '
diff --git a/tests/oauth1/rfc5849/endpoints/test_request_token.py b/tests/oauth1/rfc5849/endpoints/test_request_token.py
index a6855ab..38d871f 100644
--- a/tests/oauth1/rfc5849/endpoints/test_request_token.py
+++ b/tests/oauth1/rfc5849/endpoints/test_request_token.py
@@ -76,3 +76,13 @@ class RequestTokenEndpointTest(TestCase):
self.uri, headers=self.headers)
self.assertEqual(s, 200)
self.assertIn('oauth_token', b)
+
+ def test_uri_provided_realm(self):
+ client = Client('foo', callback_uri='https://c.b/cb',
+ client_secret='bar')
+ uri = self.uri + '?realm=foo'
+ _, headers, _ = client.sign(uri)
+ u, h, b, s = self.endpoint.create_request_token_response(
+ uri, headers=headers)
+ self.assertEqual(s, 200)
+ self.assertIn('oauth_token', b)