Allow specifying allowed actions when no password is sent

This commit is contained in:
Kovid Goyal 2022-08-15 21:05:53 +05:30
parent 65fc61a507
commit 1619687d1d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 1 deletions

View File

@ -2705,6 +2705,11 @@ To get a list of available actions, run::
kitty @ -h kitty @ -h
A set of actions to be allowed when no password is sent can be specified by using an empty
password, for example::
remote_control_password "" *-colors
Finally, the path to a python module can be specified that provides a function :code:`is_cmd_allowed` Finally, the path to a python module can be specified that provides a function :code:`is_cmd_allowed`
that is used to check every remote control command. See :ref:`rc_custom_auth` for details. For example:: that is used to check every remote control command. See :ref:`rc_custom_auth` for details. For example::

View File

@ -137,7 +137,11 @@ user_password_allowed: Dict[str, bool] = {}
def is_cmd_allowed(pcmd: Dict[str, Any], window: Optional['Window'], from_socket: bool, extra_data: Dict[str, Any]) -> Optional[bool]: def is_cmd_allowed(pcmd: Dict[str, Any], window: Optional['Window'], from_socket: bool, extra_data: Dict[str, Any]) -> Optional[bool]:
pw = pcmd.get('password', '') pw = pcmd.get('password', '')
if not pw: if not pw:
auth_items = get_options().remote_control_password.get('')
if auth_items is None:
return False return False
pa = password_authorizer(auth_items)
return pa.is_cmd_allowed(pcmd, window, from_socket, extra_data)
q = user_password_allowed.get(pw) q = user_password_allowed.get(pw)
if q is not None: if q is not None:
return q return q