diff --git a/config b/config index bd35574..0925a54 100644 --- a/config +++ b/config @@ -66,8 +66,8 @@ [auth] # Authentication method -# Value: None | htpasswd | remote_user | http_x_remote_user -#type = None +# Value: none | htpasswd | remote_user | http_x_remote_user +#type = none # Htpasswd filename #htpasswd_filename = /etc/radicale/users @@ -85,7 +85,7 @@ [rights] # Rights backend -# Value: None | authenticated | owner_only | owner_write | from_file +# Value: none | authenticated | owner_only | owner_write | from_file #type = owner_only # File for rights management from_file diff --git a/radicale/__init__.py b/radicale/__init__.py index 5aac750..4fff67e 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -334,8 +334,8 @@ class Application: status, client.responses.get(status, "Unknown")) self.logger.info( "%s answer status for %r%s in %.3f seconds: %s", - environ["REQUEST_METHOD"], environ["PATH_INFO"], depthinfo, - (time_end - time_begin).total_seconds(), status) + environ["REQUEST_METHOD"], environ.get("PATH_INFO", ""), + depthinfo, (time_end - time_begin).total_seconds(), status) # Return response content return status, list(headers.items()), [answer] if answer else [] @@ -372,15 +372,15 @@ class Application: environ.get("SCRIPT_NAME", "")).rstrip("/") self.logger.debug("Sanitized script name: %r", environ["SCRIPT_NAME"]) base_prefix = environ["SCRIPT_NAME"] + environ["PATH_INFO"] = environ.get("PATH_INFO", "") # Sanitize request URI (a WSGI server indicates with an empty path, # that the URL targets the application root without a trailing slash) if environ["PATH_INFO"]: environ["PATH_INFO"] = storage.sanitize_path(environ["PATH_INFO"]) self.logger.debug("Sanitized path: %r", environ["PATH_INFO"]) + # SCRIPT_NAME is already removed from PATH_INFO, according to the + # WSGI specification. path = environ["PATH_INFO"] - if base_prefix and path.startswith(base_prefix): - path = path[len(base_prefix):] - self.logger.debug("Stripped script name from path: %s", path) # Get function corresponding to method function = getattr(self, "do_%s" % environ["REQUEST_METHOD"].upper()) diff --git a/radicale/auth.py b/radicale/auth.py index 63f0f37..20c1399 100644 --- a/radicale/auth.py +++ b/radicale/auth.py @@ -64,7 +64,7 @@ from importlib import import_module def load(configuration, logger): """Load the authentication manager chosen in configuration.""" auth_type = configuration.get("auth", "type") - if auth_type == "None": + if auth_type in ("None", "none"): # DEPRECATED: use "none" class_ = NoneAuth elif auth_type == "remote_user": class_ = RemoteUserAuth diff --git a/radicale/rights.py b/radicale/rights.py index d4c0f6a..ed8745b 100644 --- a/radicale/rights.py +++ b/radicale/rights.py @@ -48,9 +48,9 @@ from . import storage def load(configuration, logger): """Load the rights manager chosen in configuration.""" rights_type = configuration.get("rights", "type") - if configuration.get("auth", "type") == "None": + if configuration.get("auth", "type") in ("None", "none"): # DEPRECATED rights_type = "None" - if rights_type == "None": + if rights_type in ("None", "none"): # DEPRECATED: use "none" rights_class = NoneRights elif rights_type == "authenticated": rights_class = AuthenticatedRights diff --git a/radicale/tests/test_auth.py b/radicale/tests/test_auth.py index 3ac3f08..dc0fadd 100644 --- a/radicale/tests/test_auth.py +++ b/radicale/tests/test_auth.py @@ -21,7 +21,6 @@ Radicale tests with simple requests and authentication. """ import base64 -import logging import os import shutil import tempfile @@ -40,7 +39,6 @@ class TestBaseAuthRequests(BaseTest): """ def setup(self): self.configuration = config.load() - self.logger = logging.getLogger("radicale_test") self.colpath = tempfile.mkdtemp() self.configuration.set("storage", "filesystem_folder", self.colpath) # Disable syncing to disk for better performance @@ -63,14 +61,14 @@ class TestBaseAuthRequests(BaseTest): self.configuration.set("auth", "htpasswd_encryption", htpasswd_encryption) self.application = Application(self.configuration, self.logger) - for user, password, expeced_status in ( + for user, password, expected_status in ( ("tmp", "bepo", 207), ("tmp", "tmp", 401), ("tmp", "", 401), ("unk", "unk", 401), ("unk", "", 401), ("", "", 401)): status, headers, answer = self.request( "PROPFIND", "/", HTTP_AUTHORIZATION="Basic %s" % base64.b64encode( ("%s:%s" % (user, password)).encode()).decode()) - assert status == expeced_status + assert status == expected_status def test_htpasswd_plain(self): self._test_htpasswd("plain", "tmp:bepo") @@ -142,6 +140,6 @@ class TestBaseAuthRequests(BaseTest): self.configuration.set("auth", "type", "tests.custom.auth") self.application = Application(self.configuration, self.logger) status, headers, answer = self.request( - "GET", "/", HTTP_AUTHORIZATION="dG1wOmJlcG8=") - assert status == 200 - assert "Radicale works!" in answer + "PROPFIND", "/tmp", HTTP_AUTHORIZATION="Basic %s" % + base64.b64encode(("tmp:").encode()).decode()) + assert status == 207 diff --git a/radicale/tests/test_rights.py b/radicale/tests/test_rights.py index f332f5b..4e80c26 100644 --- a/radicale/tests/test_rights.py +++ b/radicale/tests/test_rights.py @@ -102,16 +102,16 @@ class TestBaseAuthRequests(BaseTest): self._test_rights("authenticated", "tmp", "/other", "w", 207) def test_none(self): - self._test_rights("None", "", "/", "r", 207) - self._test_rights("None", "", "/", "w", 207) - self._test_rights("None", "", "/tmp", "r", 207) - self._test_rights("None", "", "/tmp", "w", 207) - self._test_rights("None", "tmp", "/", "r", 207) - self._test_rights("None", "tmp", "/", "w", 207) - self._test_rights("None", "tmp", "/tmp", "r", 207) - self._test_rights("None", "tmp", "/tmp", "w", 207) - self._test_rights("None", "tmp", "/other", "r", 207) - self._test_rights("None", "tmp", "/other", "w", 207) + self._test_rights("none", "", "/", "r", 207) + self._test_rights("none", "", "/", "w", 207) + self._test_rights("none", "", "/tmp", "r", 207) + self._test_rights("none", "", "/tmp", "w", 207) + self._test_rights("none", "tmp", "/", "r", 207) + self._test_rights("none", "tmp", "/", "w", 207) + self._test_rights("none", "tmp", "/tmp", "r", 207) + self._test_rights("none", "tmp", "/tmp", "w", 207) + self._test_rights("none", "tmp", "/other", "r", 207) + self._test_rights("none", "tmp", "/other", "w", 207) def test_from_file(self): rights_file_path = os.path.join(self.colpath, "rights")