Skip to content

Commit

Permalink
Add restore_only permission
Browse files Browse the repository at this point in the history
  • Loading branch information
deajan committed Jan 30, 2025
1 parent 7f798b0 commit 825269e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Please check https://github.com/netinvent/npbackup/releases
- Repository permissions allowing to limit clients
- Backup only permission
- Backup, list and restore permissions
- Restore only permissions
- Full permissions including destructive operations
- Encrypted data viewing requires additional password
- AES-256 keys can't be guessed in executables thanks to Nuitka Commercial compiler
Expand Down Expand Up @@ -245,6 +246,7 @@ In that case, you can set permissions via the GUI or directly in the configurati
Permissions are:
- full: Set by default, allows all including destructive operations
- restore: Allows everything backup does plus restore, check and dump operations
- restore_noly: Allows only restoring backups, but not creating ones
- backup: Allows, backup, snapshot/object listing operations and repo unlocking

## Logs
Expand Down
13 changes: 7 additions & 6 deletions npbackup/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ def has_permission(fn: Callable):
Possible permissions are:
- backup: Init, Backup, list backups and unlock
- restore: Init, Backup, restore, recover and list snapshots
- restore_only: Restore only
- full: Full permissions
Only one permission can be set per repo
Expand All @@ -531,13 +532,13 @@ def wrapper(self, *args, **kwargs):
required_permissions = {
"init": ["backup", "restore", "full"],
"backup": ["backup", "restore", "full"],
"has_recent_snapshot": ["backup", "restore", "full"],
"snapshots": ["backup", "restore", "full"],
"has_recent_snapshot": ["backup", "restore", "restore_only", "full"],
"snapshots": ["backup", "restore", "restore_only", "full"],
"stats": ["backup", "restore", "full"],
"ls": ["backup", "restore", "full"],
"find": ["backup", "restore", "full"],
"restore": ["restore", "full"],
"dump": ["restore", "full"],
"ls": ["backup", "restore", "restore_only", "full"],
"find": ["backup", "restore", "restore_only", "full"],
"restore": ["restore", "restore_only", "full"],
"dump": ["restore", "retore_only", "full"],
"check": ["restore", "full"],
"recover": ["restore", "full"],
"list": ["full"],
Expand Down
2 changes: 1 addition & 1 deletion npbackup/gui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def viewer_create_repo(viewer_repo_uri: str, viewer_repo_password: str) -> dict:
# Let's set default backup age to 24h
repo_config.s("repo_opts.minimum_backup_age", 1440)
# NPF-SEC-00005 Add restore permission
repo_config.s("permissions", "restore")
repo_config.s("permissions", "restore_only")

return repo_config

Expand Down
1 change: 1 addition & 0 deletions npbackup/gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def config_gui(full_config: dict, config_file: str):
"permissions": {
"backup": _t("config_gui.backup_perms"),
"restore": _t("config_gui.restore_perms"),
"restore_only": _t("config_gui.restore_only_perms"),
"full": _t("config_gui.full_perms"),
},
}
Expand Down
1 change: 1 addition & 0 deletions npbackup/translations/config_gui.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ en:
permissions: Permissions
backup_perms: Backup only
restore_perms: Backup, verify, recover and restore
restore_only_perms: Restore only
full_perms: Full permissions
setting_permissions_requires_manager_password: Setting permissions requires manager password
manager_password_too_simple: Manager password needs at least 8 uppercase, lowercase and digits characters
Expand Down
1 change: 1 addition & 0 deletions npbackup/translations/config_gui.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ fr:
permissions: Permissions
backup_perms: Sauvegardes uniquement
restore_perms: Sauvegarde, vérification, récupération et restauration
restore_only_perms: Restauration uniquement
full_perms: Accès total
setting_permissions_requires_manager_password: Un mot de passe gestionnaire est requis pour définir des permissions
manager_password_too_simple: Le mot de passe gestionnaire nécessite au moins 8 caractères majuscules, minuscules et chiffres
Expand Down

0 comments on commit 825269e

Please sign in to comment.