[Update] 修改public key 校验

This commit is contained in:
ibuler
2019-11-11 12:43:00 +08:00
parent 0b211d33b2
commit aeff0ab5f3
4 changed files with 60 additions and 11 deletions

View File

@@ -120,6 +120,23 @@ class AuthMixin:
return s
return False
@staticmethod
def get_public_key_body(key):
for i in key.split():
if len(i) > 256:
return i
return key
def check_public_key(self, key):
if not self.public_key:
return False
key = self.get_public_key_body(key)
key_saved = self.get_public_key_body(self.public_key)
if key == key_saved:
return True
else:
return False
class RoleMixin:
ROLE_ADMIN = 'Admin'