mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 02:48:51 +00:00
Merge pull request #4936 from haiwen/webdav-secret
length of webdav secret should be less than 30
This commit is contained in:
@@ -7,6 +7,8 @@ from rest_framework.permissions import IsAuthenticated
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from seahub.api2.authentication import TokenAuthentication
|
from seahub.api2.authentication import TokenAuthentication
|
||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error
|
||||||
@@ -43,6 +45,9 @@ class WebdavSecretView(APIView):
|
|||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
secret = request.data.get("secret", None)
|
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:
|
if secret:
|
||||||
encoded = aes.encode(secret)
|
encoded = aes.encode(secret)
|
||||||
|
@@ -51,4 +51,5 @@ class AESPasswordHasher:
|
|||||||
raise AESPasswordDecodeError
|
raise AESPasswordDecodeError
|
||||||
data = data.encode('utf-8')
|
data = data.encode('utf-8')
|
||||||
|
|
||||||
|
data += b'='*4
|
||||||
return DecodeAES(self.cipher, data)
|
return DecodeAES(self.cipher, data)
|
||||||
|
Reference in New Issue
Block a user