backups: Require POST method for mount/unmount operations

Tests:

- Sending GET requests to the two views by opening theirs URLs in the browser
show a blank page. Actions are not performed.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2024-12-30 08:33:59 -05:00
1 parent a6b16920e2
commit d423b40239
1 file changed
+3
+3
View File
@@ -17,6 +17,7 @@ from django.urls import reverse, reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from django.views.decorators.http import require_POST
from django.views.generic import FormView, TemplateView, View
from plinth.errors import PlinthError
@@ -472,6 +473,7 @@ class RemoveRepositoryView(SuccessMessageMixin, TemplateView):
return redirect('backups:index')
@require_POST
def umount_repository(request, uuid):
"""View to unmount a remote SSH repository."""
repository = SshBorgRepository.load(uuid)
@@ -482,6 +484,7 @@ def umount_repository(request, uuid):
return redirect('backups:index')
@require_POST
def mount_repository(request, uuid):
"""View to mount a remote SSH repository."""
# Do not mount unverified ssh repositories. Prompt for verification.