From 48d00fcca845c2cd1de79cdcced5579991988706 Mon Sep 17 00:00:00 2001 From: Patrik Dufresne Date: Wed, 4 Jul 2018 12:06:54 -0400 Subject: [PATCH] Add support for cherrypy 16 --- .gitlab-ci.yml | 12 ++++++++++++ .travis.yml | 2 ++ rdiffweb/filter_authentication.py | 21 +++++++++++++++++---- tox.ini | 6 +++++- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b6ad454..f2906429 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,6 +54,12 @@ py27-cherrypy13: py27-cherrypy14: <<: *tox + +py27-cherrypy15: + <<: *tox + +py27-cherrypy16: + <<: *tox py3-cherrypy35: <<: *tox @@ -90,6 +96,12 @@ py3-cherrypy13: py3-cherrypy14: <<: *tox + +py3-cherrypy15: + <<: *tox + +py3-cherrypy16: + <<: *tox py27-cherrypy32: <<: *tox diff --git a/.travis.yml b/.travis.yml index b72b430e..acd1dd83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,8 @@ env: - CHERRYPY=12 - CHERRYPY=13 - CHERRYPY=14 + - CHERRYPY=15 + - CHERRYPY=16 # Make sure to exclude python3.4 + CherryPy 3.2.2 # This configuration is not supported. diff --git a/rdiffweb/filter_authentication.py b/rdiffweb/filter_authentication.py index 0be00368..9d2e2c41 100644 --- a/rdiffweb/filter_authentication.py +++ b/rdiffweb/filter_authentication.py @@ -22,7 +22,6 @@ from __future__ import unicode_literals import binascii from builtins import str import cherrypy -from cherrypy._cpcompat import base64_decode from cherrypy._cptools import HandlerTool from future.utils import native_str import logging @@ -31,13 +30,24 @@ from rdiffweb.core import RdiffError, RdiffWarning from rdiffweb.i18n import ugettext as _ from rdiffweb.page_main import MainPage from rdiffweb.rdw_helpers import quote_url -from cherrypy.lib import httpauth - +import base64 # Define the logger logger = logging.getLogger(__name__) +def base64_decode(params): + bytes_params = base64.b64decode(params.encode('ascii')) + decoded_params = bytes_params.decode('ascii', errors='replace') + for e in ['utf-8', 'ISO-8859-1']: + try: + decoded_params = bytes_params.decode(e) + break + except ValueError: + pass + return decoded_params + + class BaseAuth(HandlerTool): session_key = 'user' @@ -195,6 +205,7 @@ class BasicAuth(BaseAuth): """ Tool used to control authentication to various ressources. """ + def __init__(self): BaseAuth.__init__(self, self.run, name='authbasic') # Make sure to run before authform (priority 71) @@ -226,7 +237,9 @@ class BasicAuth(BaseAuth): logger.info('no authorization header, running is_login') if not self.is_login(): # Inform the user-agent this path is protected. - cherrypy.serving.response.headers['www-authenticate'] = httpauth.basicAuth('rdiffweb') + cherrypy.serving.response.headers['www-authenticate'] = ( + 'Basic realm="%s"%s' % ('rdiffweb', 'utf-8') + ) raise cherrypy.HTTPError(401, "You are not authorized to access that resource") diff --git a/tox.ini b/tox.ini index 552202fe..e9a9d717 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,8 @@ deps= cherrypy12: cherrypy>=12.0.0,<13.0.0 cherrypy13: cherrypy>=13.0.0,<14.0.0 cherrypy14: cherrypy>=14.0.0,<15.0.0 + cherrypy15: cherrypy>=15.0.0,<16.0.0 + cherrypy16: cherrypy>=16.0.0,<17.0.0 setenv = COVERAGE_FILE=.coverage.{envname} commands=python setup.py nosetests --xunit-file=nosetests-{envname}.xml --xunit-testsuite-name={envname} @@ -52,4 +54,6 @@ CHERRYPY = 11: cherrypy11 12: cherrypy12 13: cherrypy13 - 14: cherrypy14 \ No newline at end of file + 14: cherrypy14 + 14: cherrypy15 + 14: cherrypy16 \ No newline at end of file -- GitLab