mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 03:00:11 +00:00
Security HTTP provider fix
This commit is contained in:
parent
89ec335210
commit
e2ae4f35d0
4 changed files with 4 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
|
@ -283,7 +283,7 @@ class TestRequestValidator(object):
|
|||
},
|
||||
)
|
||||
assert result.security == {
|
||||
'petstore_auth': self.api_key,
|
||||
'petstore_auth': self.api_key_encoded,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,4 +30,4 @@ class TestHttpProvider(object):
|
|||
|
||||
result = provider(request)
|
||||
|
||||
assert result == '1'
|
||||
assert result == jwt
|
||||
|
|
Loading…
Reference in a new issue