diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b6ad45482e2822ee44f6658e135813e8fdf3b69..f290642995f81724ecbb3aecffb85227dc69b008 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 b72b430e9d9b739bb0f5b0a8cd900523da490d12..acd1dd834c105ae0f6e2a8e3409cd2c7cb829244 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 0be00368aac22b518fa6d075c41177914a0fa036..9d2e2c41d59c1b370bb9884c870409fced7e43c8 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 552202fecd9cb22810082b0136e784f85fd6a3a9..e9a9d71726be5dc209597a972504ba251b929ad3 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