From 17c6c4e1f9852de99d6a248966d3d97ca133d907 Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Tue, 17 Feb 2015 15:14:40 -0800 Subject: [PATCH] Removed rfc3987 library The rfc3987 library is licensed under the GPL, and should not be used. Change-Id: I141e1d94c9eb105749346f0471c93bf6a4e9e01c --- requirements-py3.txt | 1 - requirements.txt | 1 - storyboard/api/auth/openid_client.py | 8 ++++---- storyboard/common/decorators.py | 16 +++++++++------- storyboard/common/exception.py | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/requirements-py3.txt b/requirements-py3.txt index 85ddecfa..b27e63db 100644 --- a/requirements-py3.txt +++ b/requirements-py3.txt @@ -24,6 +24,5 @@ eventlet>=0.13.0 stevedore>=1.0.0 python-crontab>=1.8.1 tzlocal>=1.1.2 -rfc3987>=1.3.4 Jinja2>=2.7.3 PyMySQL>=0.6.2 diff --git a/requirements.txt b/requirements.txt index 2fd7be60..bf0b6fd7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,6 @@ eventlet>=0.13.0 stevedore>=1.0.0 python-crontab>=1.8.1 tzlocal>=1.1.2 -rfc3987>=1.3.4 email>=4.0.2 Jinja2>=2.7.3 PyMySQL>=0.6.2 diff --git a/storyboard/api/auth/openid_client.py b/storyboard/api/auth/openid_client.py index e1b215b5..2388c497 100644 --- a/storyboard/api/auth/openid_client.py +++ b/storyboard/api/auth/openid_client.py @@ -16,8 +16,8 @@ from oslo.config import cfg from oslo_log import log import requests -import rfc3987 import six +from six.moves.urllib.parse import urlparse from storyboard.api.auth import ErrorMessages as e_msg from storyboard.api.auth import utils @@ -45,9 +45,9 @@ class OpenIdClient(object): # Sanity Check: Redirect URI if not redirect_uri: raise InvalidRequest(message=e_msg.NO_REDIRECT_URI) - try: - rfc3987.parse(redirect_uri, 'URI') - except ValueError: + + parts = urlparse(redirect_uri) + if not parts.scheme or not parts.path: raise InvalidRequest(message=e_msg.INVALID_REDIRECT_URI) # Sanity Check: response_type diff --git a/storyboard/common/decorators.py b/storyboard/common/decorators.py index 5ad7e10d..c0f9d4ba 100644 --- a/storyboard/common/decorators.py +++ b/storyboard/common/decorators.py @@ -19,8 +19,9 @@ import functools from pecan import abort from pecan import redirect from pecan import response -import rfc3987 -import six.moves.urllib.parse as urlparse +from six.moves.urllib.parse import urlencode +from six.moves.urllib.parse import urlparse +from six.moves.urllib.parse import urlunparse from storyboard.common import exception as exc from storyboard.openstack.common.gettextutils import _ # noqa @@ -51,19 +52,20 @@ def oauth_exceptions(func): # If we have a redirect URL, build the error redirect. if o_exc.redirect_uri: # Split the redirect_url apart - parts = rfc3987.parse(o_exc.redirect_uri, 'URI') + parts = urlparse(o_exc.redirect_uri) # Add the error and error_description - if parts['query']: - params = urlparse.parse_qsl(parts['query']) + if parts.query: + params = urlparse.parse_qsl(parts.query) else: params = [] params.append(('error', error)) params.append(('error_description', error_description)) # Overwrite the old query params and reconstruct the URL - parts['query'] = urlparse.urlencode(params) - location = rfc3987.compose(**parts) + parts_list = list(parts) + parts_list[4] = urlencode(params) + location = urlunparse(parts_list) redirect(location) else: diff --git a/storyboard/common/exception.py b/storyboard/common/exception.py index b4cca356..bc585f29 100644 --- a/storyboard/common/exception.py +++ b/storyboard/common/exception.py @@ -14,8 +14,8 @@ # limitations under the License. from oslo_log import log -import rfc3987 from six.moves import http_client +from six.moves.urllib.parse import urlparse from wsme.exc import ClientSideError from storyboard.openstack.common.gettextutils import _ # noqa @@ -268,8 +268,8 @@ class OAuthException(ClientSideError): code = http_client.BAD_REQUEST else: try: - parts = rfc3987.parse(redirect_uri, 'URI') - if parts['scheme'] not in ['http', 'https']: + parts = urlparse(redirect_uri) + if parts.scheme not in ['http', 'https']: raise ValueError('Invalid scheme') self.redirect_uri = redirect_uri code = http_client.SEE_OTHER