SecurityMixin¶
Provides security functionality for the file manager. The SecurityMixin contains operations for freezing, unfreezing, and masking sensitive data.
Methods¶
freeze¶
Make the file read-only by preventing modifications.
Example:
unfreeze¶
Re-enable write operations on the file.
Example:
is_frozen¶
Check if the file is frozen (read-only).
Returns:
- bool: True if frozen, False otherwise
Example:
mask_sensitive¶
def mask_sensitive(
self,
keys_to_mask: Optional[List[str]] = None,
mask: str = "***"
) -> Dict[str, Any]
Create a masked version of the data with sensitive information hidden.
Parameters:
- keys_to_mask (Optional[List[str]]): List of keys to mask. If None, uses default sensitive keys
- mask (str): String to use for masking
Returns:
- Dict[str, Any]: Dictionary with sensitive data masked
Example:
# Mask with default sensitive keys
masked = fm.mask_sensitive()
# Mask with specific keys
masked = fm.mask_sensitive(["password", "secret"], "HIDDEN")
get_public_config¶
Get a public version of the configuration with sensitive data removed.
Parameters:
- sensitive_keys (Optional[List[str]]): List of keys to remove. If None, uses default sensitive keys
Returns:
- Dict[str, Any]: Dictionary with sensitive data removed
Example:
# Public config with default sensitive data removal
public = fm.get_public_config()
# Public config with specific keys
public = fm.get_public_config(["password", "secret"])
Default Sensitive Keys¶
The SecurityMixin automatically recognizes the following key patterns as sensitive: - password, passwd, pwd - secret, key, token, auth, credential - private, sensitive, confidential - api_key, access_token, refresh_token - session_id, cookie