Commit 48d00fcc authored by Patrik Dufresne's avatar Patrik Dufresne

Add support for cherrypy 16

parent 552a9dc2
Pipeline #263 passed with stages
in 57 minutes and 7 seconds
......@@ -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
......
......@@ -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.
......
......@@ -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")
......
......@@ -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
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