From 7dbc953b3b5a1200076e8115228e667874e8321b Mon Sep 17 00:00:00 2001 From: Yuguang Wang Date: Wed, 11 Oct 2023 11:27:41 +0800 Subject: [PATCH] hub: fail open in case an invalid acl permission is specified --- kobo/hub/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kobo/hub/__init__.py b/kobo/hub/__init__.py index d35ebf44..5a982c8a 100644 --- a/kobo/hub/__init__.py +++ b/kobo/hub/__init__.py @@ -30,6 +30,16 @@ raise ImproperlyConfigured("Invalid permissions on '%s'." % dir_path) +if hasattr(settings, "USERS_ACL_PERMISSION"): + acl_permission = getattr(settings, "USERS_ACL_PERMISSION") + valid_options = ["", "authenticated", "staff"] + if acl_permission not in valid_options: + raise ImproperlyConfigured( + f"Invalid USERS_ACL_PERMISSION in settings: '{acl_permission}', must be one of " + f"'authenticated', 'staff' or ''(empty string)" + ) + + if getattr(settings, "MIDDLEWARE", None) is not None: # Settings defines Django>=1.10 style middleware, check that middleware_var = "MIDDLEWARE"