Option to disable new site adding in multiuser mode

This commit is contained in:
shortcutme 2017-02-11 18:22:24 +01:00
parent 0106a193e5
commit 27d31b3a1e
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -29,6 +29,15 @@ class UiRequestPlugin(object):
if not user: # No user found by cookie
user = self.user_manager.create()
user_created = True
else:
user = None
# Disable new site creation if --multiuser_no_new_sites enabled
if config.multiuser_no_new_sites:
path_parts = self.parsePath(path)
if not self.server.site_manager.get(match.group("address")) and (not user or user.master_address not in local_master_addresses):
self.sendHeader(404)
return self.formatError("Not Found", "Adding new sites disabled on this proxy", details=False)
if user_created:
if not extra_headers:
@ -194,5 +203,6 @@ class ConfigPlugin(object):
def createArguments(self):
group = self.parser.add_argument_group("Multiuser plugin")
group.add_argument('--multiuser_local', help="Enable unsafe Ui functions and write users to disk", action='store_true')
group.add_argument('--multiuser_no_new_sites', help="Denies adding new sites by normal users", action='store_true')
return super(ConfigPlugin, self).createArguments()