1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 01:44:13 +00:00

Merge pull request #4936 from haiwen/webdav-secret

length of webdav secret should be less than 30
This commit is contained in:
Daniel Pan
2021-07-17 10:35:46 +08:00
committed by GitHub
2 changed files with 6 additions and 0 deletions

View File

@@ -7,6 +7,8 @@ from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from django.utils.translation import ugettext as _
from seahub.api2.authentication import TokenAuthentication
from seahub.api2.throttling import UserRateThrottle
from seahub.api2.utils import api_error
@@ -43,6 +45,9 @@ class WebdavSecretView(APIView):
username = request.user.username
secret = request.data.get("secret", None)
if len(secret) >= 30:
return api_error(status.HTTP_400_BAD_REQUEST,
_("Length of WebDav password should be less then 30."))
if secret:
encoded = aes.encode(secret)

View File

@@ -51,4 +51,5 @@ class AESPasswordHasher:
raise AESPasswordDecodeError
data = data.encode('utf-8')
data += b'='*4
return DecodeAES(self.cipher, data)