mirror of https://github.com/jumpserver/jumpserver
				
				
				
			Merge branch 'v3' of github.com:jumpserver/jumpserver into v3
						commit
						c9b8c087c7
					
				| 
						 | 
				
			
			@ -64,7 +64,7 @@ class LoginAssetACL(BaseACL, OrgModelMixin):
 | 
			
		|||
            Q(assets__hostname_group__contains=asset.name) |
 | 
			
		||||
            Q(assets__hostname_group__contains='*')
 | 
			
		||||
        )
 | 
			
		||||
        ids = [q.id for q in queryset if contains_ip(asset.ip, q.assets.get('ip_group', []))]
 | 
			
		||||
        ids = [q.id for q in queryset if contains_ip(asset.address, q.assets.get('ip_group', []))]
 | 
			
		||||
        queryset = cls.objects.filter(id__in=ids)
 | 
			
		||||
        return queryset
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
from rest_framework.decorators import action
 | 
			
		||||
from rest_framework.response import Response
 | 
			
		||||
from rest_framework.generics import CreateAPIView
 | 
			
		||||
from rest_framework.generics import CreateAPIView, get_object_or_404
 | 
			
		||||
 | 
			
		||||
from orgs.mixins.api import OrgBulkModelViewSet
 | 
			
		||||
from rbac.permissions import RBACPermission
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ class AccountViewSet(OrgBulkModelViewSet):
 | 
			
		|||
    }
 | 
			
		||||
    rbac_perms = {
 | 
			
		||||
        'verify': 'assets.test_account',
 | 
			
		||||
        'partial_update': 'assets.change_assetaccountsecret',
 | 
			
		||||
        'partial_update': 'assets.change_accountsecret',
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @action(methods=['post'], detail=True, url_path='verify')
 | 
			
		||||
| 
						 | 
				
			
			@ -41,9 +41,10 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
 | 
			
		|||
    因为可能要导出所有账号,所以单独建立了一个 viewset
 | 
			
		||||
    """
 | 
			
		||||
    serializer_classes = {
 | 
			
		||||
        'default': serializers.AccountSecretSerializer
 | 
			
		||||
        'default': serializers.AccountSecretSerializer,
 | 
			
		||||
        'histories': serializers.AccountHistorySerializer,
 | 
			
		||||
    }
 | 
			
		||||
    http_method_names = ['get']
 | 
			
		||||
    http_method_names = ['get', 'options']
 | 
			
		||||
    # Todo: 记得打开
 | 
			
		||||
    # permission_classes = [RBACPermission, UserConfirmation.require(ConfirmType.MFA)]
 | 
			
		||||
    rbac_perms = {
 | 
			
		||||
| 
						 | 
				
			
			@ -52,12 +53,11 @@ class AccountSecretsViewSet(RecordViewLogMixin, AccountViewSet):
 | 
			
		|||
        'histories': ['assets.view_accountsecret'],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @action(methods=['get'], detail=True, url_path='histories', serializer_class=serializers.AccountHistorySerializer)
 | 
			
		||||
    @action(methods=['get'], detail=True, url_path='histories')
 | 
			
		||||
    def histories(self, request, *args, **kwargs):
 | 
			
		||||
        account = self.get_object()
 | 
			
		||||
        histories = account.history.all()
 | 
			
		||||
        serializer = serializers.AccountHistorySerializer(histories, many=True)
 | 
			
		||||
        return Response(serializer.data)
 | 
			
		||||
        account = get_object_or_404(self.get_queryset(), **kwargs)
 | 
			
		||||
        self.queryset = account.history.all()
 | 
			
		||||
        return super().list(request, *args, **kwargs)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AccountTaskCreateAPI(CreateAPIView):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,8 +39,11 @@ class GatherAccountsFilter:
 | 
			
		|||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def windows_filter(info):
 | 
			
		||||
        # TODO
 | 
			
		||||
        info = info[4:-2]
 | 
			
		||||
        result = {}
 | 
			
		||||
        for i in info:
 | 
			
		||||
            for username in i.split():
 | 
			
		||||
                result[username] = {}
 | 
			
		||||
        return result
 | 
			
		||||
 | 
			
		||||
    def run(self, method_id_meta_mapper, info):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,7 +142,7 @@ class IpInFilterBackend(filters.BaseFilterBackend):
 | 
			
		|||
        if not ips:
 | 
			
		||||
            return queryset
 | 
			
		||||
        ip_list = [i.strip() for i in ips.split(',')]
 | 
			
		||||
        queryset = queryset.filter(ip__in=ip_list)
 | 
			
		||||
        queryset = queryset.filter(address__in=ip_list)
 | 
			
		||||
        return queryset
 | 
			
		||||
 | 
			
		||||
    def get_schema_fields(self, view):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ class ConnectionTokenAssetSerializer(serializers.ModelSerializer):
 | 
			
		|||
    """ Asset """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Asset
 | 
			
		||||
        fields = ['id', 'name', 'ip', 'protocols', 'org_id']
 | 
			
		||||
        fields = ['id', 'name', 'address', 'protocols', 'org_id']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ConnectionTokenAccountSerializer(serializers.ModelSerializer):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ class CeleryTaskSerializer(serializers.ModelSerializer):
 | 
			
		|||
    class Meta:
 | 
			
		||||
        model = CeleryTask
 | 
			
		||||
        fields = [
 | 
			
		||||
            'id', 'name', 'meta', 'publish_count', 'state', 'success_count', 'last_published_time',
 | 
			
		||||
            'id', 'name', 'meta', 'state', 'last_published_time',
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue