diff --git a/openapi_core/security/providers.py b/openapi_core/security/providers.py index 9e89fc3..5ee27c5 100644 --- a/openapi_core/security/providers.py +++ b/openapi_core/security/providers.py @@ -1,8 +1,6 @@ -import binascii import warnings from openapi_core.security.exceptions import SecurityError -from openapi_core.security.util import b64decode class BaseProvider(object): @@ -40,7 +38,5 @@ class HttpProvider(BaseProvider): if auth_type.lower() != self.scheme.scheme.value: raise SecurityError( 'Unknown authorization method %s' % auth_type) - try: - return b64decode(encoded_credentials).decode('latin1') - except binascii.Error: - raise SecurityError('Invalid base64 encoding.') + + return encoded_credentials diff --git a/openapi_core/security/util.py b/openapi_core/security/util.py deleted file mode 100644 index ff05ca1..0000000 --- a/openapi_core/security/util.py +++ /dev/null @@ -1,9 +0,0 @@ -from base64 import urlsafe_b64decode - - -def b64decode(s): - # Code from - # https://github.com/GehirnInc/python-jwt/blob/master/jwt/utils.py#L29 - s_bin = s.encode('ascii') - s_bin += b'=' * (4 - len(s_bin) % 4) - return urlsafe_b64decode(s_bin) diff --git a/tests/integration/validation/test_validators.py b/tests/integration/validation/test_validators.py index 07dddd5..e244dfc 100644 --- a/tests/integration/validation/test_validators.py +++ b/tests/integration/validation/test_validators.py @@ -283,7 +283,7 @@ class TestRequestValidator(object): }, ) assert result.security == { - 'petstore_auth': self.api_key, + 'petstore_auth': self.api_key_encoded, } diff --git a/tests/unit/security/test_providers.py b/tests/unit/security/test_providers.py index d79e592..e53798f 100644 --- a/tests/unit/security/test_providers.py +++ b/tests/unit/security/test_providers.py @@ -30,4 +30,4 @@ class TestHttpProvider(object): result = provider(request) - assert result == '1' + assert result == jwt