mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
users: Mark secret strings in privileged actions
Tests: - Run affected privileged actions through UI and notice that secret strings are not logged (except deleting the last admin user). Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
382b931cd4
commit
f22d1b31db
@ -10,7 +10,7 @@ import subprocess
|
|||||||
import augeas
|
import augeas
|
||||||
|
|
||||||
from plinth import action_utils, utils
|
from plinth import action_utils, utils
|
||||||
from plinth.actions import privileged
|
from plinth.actions import privileged, secret_str
|
||||||
|
|
||||||
INPUT_LINES = None
|
INPUT_LINES = None
|
||||||
ACCESS_CONF = '/etc/security/access.conf'
|
ACCESS_CONF = '/etc/security/access.conf'
|
||||||
@ -219,8 +219,9 @@ def _disconnect_samba_user(username):
|
|||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def create_user(username: str, password: str, auth_user: str | None = None,
|
def create_user(username: str, password: secret_str,
|
||||||
auth_password: str | None = None):
|
auth_user: str | None = None,
|
||||||
|
auth_password: secret_str | None = None):
|
||||||
"""Create an LDAP user, set password and flush cache."""
|
"""Create an LDAP user, set password and flush cache."""
|
||||||
_validate_user(auth_user, auth_password)
|
_validate_user(auth_user, auth_password)
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ def create_user(username: str, password: str, auth_user: str | None = None,
|
|||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def remove_user(username: str, password: str | None = None):
|
def remove_user(username: str, password: secret_str | None = None):
|
||||||
"""Remove an LDAP user."""
|
"""Remove an LDAP user."""
|
||||||
groups = _get_user_groups(username)
|
groups = _get_user_groups(username)
|
||||||
|
|
||||||
@ -287,8 +288,8 @@ def _set_samba_user(username, password):
|
|||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def set_user_password(username: str, password: str, auth_user: str,
|
def set_user_password(username: str, password: secret_str, auth_user: str,
|
||||||
auth_password: str):
|
auth_password: secret_str):
|
||||||
"""Set a user's password."""
|
"""Set a user's password."""
|
||||||
must_be_admin = username != auth_user
|
must_be_admin = username != auth_user
|
||||||
_validate_user(auth_user, auth_password, must_be_admin=must_be_admin)
|
_validate_user(auth_user, auth_password, must_be_admin=must_be_admin)
|
||||||
@ -424,7 +425,7 @@ def _add_user_to_group(username, groupname):
|
|||||||
@privileged
|
@privileged
|
||||||
def add_user_to_group(username: str, groupname: str,
|
def add_user_to_group(username: str, groupname: str,
|
||||||
auth_user: str | None = None,
|
auth_user: str | None = None,
|
||||||
auth_password: str | None = None):
|
auth_password: secret_str | None = None):
|
||||||
"""Add an LDAP user to an LDAP group."""
|
"""Add an LDAP user to an LDAP group."""
|
||||||
if groupname == 'admin':
|
if groupname == 'admin':
|
||||||
_validate_user(auth_user, auth_password)
|
_validate_user(auth_user, auth_password)
|
||||||
@ -440,7 +441,7 @@ def _remove_user_from_group(username, groupname):
|
|||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def remove_user_from_group(username: str, groupname: str, auth_user: str,
|
def remove_user_from_group(username: str, groupname: str, auth_user: str,
|
||||||
auth_password: str):
|
auth_password: secret_str):
|
||||||
"""Remove an LDAP user from an LDAP group."""
|
"""Remove an LDAP user from an LDAP group."""
|
||||||
if groupname == 'admin':
|
if groupname == 'admin':
|
||||||
_validate_user(auth_user, auth_password)
|
_validate_user(auth_user, auth_password)
|
||||||
@ -459,7 +460,7 @@ def get_group_users(group_name: str) -> list[str]:
|
|||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
def set_user_status(username: str, status: str, auth_user: str,
|
def set_user_status(username: str, status: str, auth_user: str,
|
||||||
auth_password: str):
|
auth_password: secret_str):
|
||||||
"""Set the status of the user."""
|
"""Set the status of the user."""
|
||||||
if status not in ('active', 'inactive'):
|
if status not in ('active', 'inactive'):
|
||||||
raise ValueError('Invalid status')
|
raise ValueError('Invalid status')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user