From 9be13cf08f269dd80aae5b4233ac995cb4d1a07c Mon Sep 17 00:00:00 2001 From: yumaojun03 <719118794@qq.com> Date: Wed, 20 Apr 2016 14:31:52 +0800 Subject: [PATCH] =?UTF-8?q?fix=20(jperm):=20=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=B7=BB=E5=8A=A0=E5=92=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20role=E6=97=B6=20=E5=AF=86=E7=A0=81=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84bug=20(#202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修改password字段的长度,对称加密过后的字符串会变长,所有设置得比较大(512) 2. 修改后端检查密码长度,并触发异常。 --- jperm/models.py | 2 +- jperm/views.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jperm/models.py b/jperm/models.py index 0ba12354a..a3451c447 100644 --- a/jperm/models.py +++ b/jperm/models.py @@ -26,7 +26,7 @@ class PermSudo(models.Model): class PermRole(models.Model): name = models.CharField(max_length=100, unique=True) comment = models.CharField(max_length=100, null=True, blank=True, default='') - password = models.CharField(max_length=128) + password = models.CharField(max_length=512) key_path = models.CharField(max_length=100) date_added = models.DateTimeField(auto_now=True) sudo = models.ManyToManyField(PermSudo, related_name='perm_role') diff --git a/jperm/views.py b/jperm/views.py index 7ff572bcf..6e7036098 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -290,6 +290,8 @@ def perm_role_add(request): if name == "root": raise ServerError(u'禁止使用root用户作为系统用户,这样非常危险!') default = get_object(Setting, name='default') + if len(password) > 64: + raise ServerError(u'密码长度不能超过64位!') if password: encrypt_pass = CRYPTOR.encrypt(password) @@ -446,6 +448,8 @@ def perm_role_edit(request): role_sudo_names = request.POST.getlist("sudo_name") role_sudos = [PermSudo.objects.get(id=sudo_id) for sudo_id in role_sudo_names] key_content = request.POST.get("role_key", "") + if len(role_password) > 64: + raise ServerError(u'密码长度不能超过64位!') try: if not role: