Commit 163ba109 authored by Jérome Perrin's avatar Jérome Perrin

fixup! fixup! oauth2_authorisation: py3

parent 5ea407ba
Pipeline #34141 failed with stage
in 0 seconds
......@@ -497,7 +497,7 @@ class TestOAuth2(ERP5TypeTestCase):
b'',
# XXX: Tolerate the redirect URL being returned in the body.
# This is a bug, body should really be empty.
header_dict.get('location', b''),
str2bytes(header_dict.get('location', '')),
),
)
parsed_location = urlsplit(header_dict.get('location', ''))
......
......@@ -227,13 +227,16 @@ class _OAuth2AuthorisationServerProxy(object):
)
else:
Connection = HTTPConnection
if six.PY2:
# Changed in version 3.4: The strict parameter was removed.
# HTTP 0.9-style “Simple Responses” are no longer supported.
Connection = functools.partial(Connection, strict=True)
timeout = getTimeLeft()
if timeout is None or timeout > self._timeout:
timeout = self._timeout
http_connection = Connection(
host=parsed_url.hostname,
port=parsed_url.port,
strict=True,
timeout=timeout,
source_address=self._bind_address,
)
......@@ -274,7 +277,7 @@ class _OAuth2AuthorisationServerProxy(object):
def _queryOAuth2(self, method, REQUEST, RESPONSE):
header_dict, body, status = self._query(
method,
body=urlencode(REQUEST.form.items()),
body=urlencode(REQUEST.form),
header_dict={
'CONTENT_TYPE': REQUEST.environ['CONTENT_TYPE'],
},
......@@ -864,7 +867,7 @@ class OAuth2AuthorisationClientConnector(
try:
state_dict = json.loads(
self.__getMultiFernet().decrypt(
state,
str2bytes(state),
ttl=self._SESSION_STATE_VALIDITY,
),
)
......
......@@ -46,6 +46,7 @@ from Products.ERP5Type.TransactionalVariable import \
getTransactionalVariable, TransactionalResource
from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
from Products.ERP5Type.mixin.response_header_generator import ResponseHeaderGenerator
from Products.ERP5Type.Utils import str2bytes, bytes2str
from zLOG import LOG, INFO, WARNING, ERROR
from zExceptions import BadRequest
......@@ -248,10 +249,10 @@ class AutorisationExtractorBeforeTraverseHook(object):
ERP5_AUTHORISATION_EXTRACTOR_PASSWORD_NAME in form_dict
):
username = form_dict[ERP5_AUTHORISATION_EXTRACTOR_USERNAME_NAME]
request._auth = 'Basic ' + base64.b64encode('%s:%s' % (
request._auth = 'Basic ' + bytes2str(base64.b64encode(str2bytes('%s:%s' % (
username,
form_dict[ERP5_AUTHORISATION_EXTRACTOR_PASSWORD_NAME],
))
))))
request.response._auth = 1
_setUserNameForAccessLog(username, request)
......
......@@ -48,7 +48,7 @@ from Products.PluggableAuthService.interfaces.plugins import (
)
from Products.ERP5Security import _setUserNameForAccessLog
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Utils import bytes2str, str2bytes, unicode2str
from Products.ERP5Type.Utils import bytes2str, str2bytes, str2unicode, unicode2str
# Public constants. Must not change once deployed.
......@@ -426,7 +426,7 @@ class ERP5OAuth2ResourceServerPlugin(BasePlugin):
The schema of this dictionary is purely an internal implementation detail
of this plugin.
"""
client_address = request.getClientAddr().decode('utf-8')
client_address = str2unicode(request.getClientAddr())
token = self.__checkTokenSignature(access_token)
if token is None and can_update_key:
self.__updateAccessTokenSignatureKeyList(request=request)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment