1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00

feat(security): implement P0 critical security fixes for API, console, and access control

- Computes API: mark password as write_only in ComputeSerializer, restrict ComputeViewSet and architectures to IsAdminUser.
- Instances API: enforce user ownership tenant isolation in InstanceViewSet.list, restrict MigrateViewSet and CreateInstanceViewSet to IsAdminUser, require IsAdminUser for mutating FlavorViewSet.
- Storage, Network, and Interface APIs: restrict StorageViewSet, VolumeViewSet, NetworkViewSet, InterfaceViewSet to IsAdminUser.
- AppSettings & NWFilters: protect appsettings and nwfilter views with @superuser_only (403 Forbidden for non-superusers).
- noVNC Console: sign tokens with TimestampSigner (salt='console.novnc', max_age=600), verify signature and user authorization in novncd with backward-compatible fallback for debug/test mode.
- Accounts: avoid hardcoded default admin password; generate cryptographically secure random password unless ADMIN_PASSWORD is set (preserve 'admin' in test runner).
- gstfsd daemon: bind to 127.0.0.1 by default instead of 0.0.0.0.
- Tests: added comprehensive test coverage for API security, token expiration/rejection, and view permissions (132 tests passing).
This commit is contained in:
catborise 2026-09-27 10:50:09 +03:00
parent 1c561de4d2
commit 1227674d8f
17 changed files with 385 additions and 53 deletions

View file

@ -4,8 +4,13 @@ from vrtManager.connection import CONN_SOCKET, CONN_SSH, CONN_TCP, CONN_TLS
class ComputeSerializer(serializers.ModelSerializer):
# Use <input type="password"> for the input.
password = serializers.CharField(style={"input_type": "password"})
password = serializers.CharField(
style={"input_type": "password"},
write_only=True,
required=False,
allow_blank=True,
allow_null=True,
)
# Use a radio input instead of a select input.
conn_types = (
(CONN_SSH, "SSH"),

View file

@ -13,10 +13,12 @@ class ComputeViewSet(viewsets.ModelViewSet):
queryset = Compute.objects.all().order_by("name")
serializer_class = ComputeSerializer
permission_classes = [permissions.IsAuthenticated]
permission_classes = [permissions.IsAdminUser]
class ComputeArchitecturesView(viewsets.ViewSet):
permission_classes = [permissions.IsAdminUser]
def list(self, request, compute_pk=None):
"""
Return a list of supported host architectures.
@ -42,6 +44,8 @@ class ComputeArchitecturesView(viewsets.ViewSet):
class ComputeMachinesView(viewsets.ViewSet):
permission_classes = [permissions.IsAdminUser]
def list(self, request, compute_pk=None, archs_pk=None):
"""
Return a list of supported host architectures.