关闭 网域网关 密码特殊字符校验

pull/6498/head
feng626 2021-07-19 11:10:09 +08:00 committed by 老广
parent 3f0a0b33b5
commit 981319e553
4 changed files with 6 additions and 8 deletions

View File

@ -10,7 +10,6 @@ from django.db import models
from django.db.models import TextChoices from django.db.models import TextChoices
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from common.utils.strings import no_special_chars
from orgs.mixins.models import OrgModelMixin from orgs.mixins.models import OrgModelMixin
from .base import BaseUser from .base import BaseUser
@ -64,8 +63,8 @@ class Gateway(BaseUser):
def test_connective(self, local_port=None): def test_connective(self, local_port=None):
if local_port is None: if local_port is None:
local_port = self.port local_port = self.port
if self.password and not no_special_chars(self.password): if not self.password:
return False, _("Password should not contains special characters") return False, _("Password cannot be empty")
client = paramiko.SSHClient() client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

View File

@ -4,7 +4,6 @@ from rest_framework import serializers
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from orgs.mixins.serializers import BulkOrgResourceModelSerializer from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from common.validators import NoSpecialChars
from ..models import Domain, Gateway from ..models import Domain, Gateway
from .base import AuthSerializerMixin from .base import AuthSerializerMixin
@ -58,7 +57,7 @@ class GatewaySerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
fields_fk = ['domain'] fields_fk = ['domain']
fields = fields_small + fields_fk fields = fields_small + fields_fk
extra_kwargs = { extra_kwargs = {
'password': {'write_only': True, 'validators': [NoSpecialChars()]}, 'password': {'write_only': True},
'private_key': {"write_only": True}, 'private_key': {"write_only": True},
'public_key': {"write_only": True}, 'public_key': {"write_only": True},
} }
@ -67,7 +66,7 @@ class GatewaySerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
class GatewayWithAuthSerializer(GatewaySerializer): class GatewayWithAuthSerializer(GatewaySerializer):
class Meta(GatewaySerializer.Meta): class Meta(GatewaySerializer.Meta):
extra_kwargs = { extra_kwargs = {
'password': {'write_only': False, 'validators': [NoSpecialChars()]}, 'password': {'write_only': False},
'private_key': {"write_only": False}, 'private_key': {"write_only": False},
'public_key': {"write_only": False}, 'public_key': {"write_only": False},
} }

Binary file not shown.

View File

@ -652,8 +652,8 @@ msgid "Gateway"
msgstr "网关" msgstr "网关"
#: assets/models/domain.py:68 #: assets/models/domain.py:68
msgid "Password should not contains special characters" msgid "Password cannot be empty"
msgstr "密码不能包含特殊字符" msgstr "密码不能为空"
#: assets/models/gathered_user.py:16 #: assets/models/gathered_user.py:16
msgid "Present" msgid "Present"