diff --git a/data/model/user.py b/data/model/user.py index e779ce859..acd22020f 100644 --- a/data/model/user.py +++ b/data/model/user.py @@ -324,6 +324,10 @@ def update_enabled(user, set_enabled): def create_robot(robot_shortname, parent, description="", unstructured_metadata=None, token=None): (username_valid, username_issue) = validate_username(robot_shortname) + if config.app_config.get("ROBOTS_DISALLOW", False): + msg = "Robot accounts have beeen disabled. Please contact your administrator." + raise InvalidRobotException(msg) + if not username_valid: raise InvalidRobotException( "The name for the robot '%s' is invalid: %s" % (robot_shortname, username_issue) @@ -435,6 +439,9 @@ def get_matching_robots(name_prefix, username, limit=10): def verify_robot(robot_username, password): + if config.app_config.get("ROBOTS_DISALLOW", False): + msg = "Robot accounts have been disabled. Please contact your administrator." + raise InvalidRobotException(msg) try: password.encode("ascii") except UnicodeEncodeError: diff --git a/util/config/schema.py b/util/config/schema.py index a82cf851e..7b9aece86 100644 --- a/util/config/schema.py +++ b/util/config/schema.py @@ -1394,5 +1394,10 @@ CONFIG_SCHEMA = { "description": "Enable customizing of terms of service for on-prem installations", "x-example": "https://quay.io/tos", }, + "ROBOTS_DISALLOW": { + "type": "boolean", + "description": "If robot accounts are prevented from any interaction as well as from being created. Defaults to False", + "x-example": False, + }, }, }