Properly encode before md5. fix #580
This commit is contained in:
@@ -53,7 +53,7 @@ class Core(Plugin):
|
||||
|
||||
|
||||
def md5Password(self, value):
|
||||
return md5(value) if value else ''
|
||||
return md5(value.encode(Env.get('encoding'))) if value else ''
|
||||
|
||||
def checkApikey(self, value):
|
||||
return value if value and len(value) > 3 else uuid4().hex
|
||||
|
||||
@@ -17,8 +17,9 @@ def requires_auth(f):
|
||||
@wraps(f)
|
||||
def decorated(*args, **kwargs):
|
||||
auth = getattr(request, 'authorization')
|
||||
if Env.setting('username') and Env.setting('password') and (not auth or not check_auth(auth.username, md5(auth.password))):
|
||||
return authenticate()
|
||||
if Env.setting('username') and Env.setting('password'):
|
||||
if (not auth or not check_auth(auth.username.decode('latin1'), md5(auth.password.decode('latin1').encode(Env.get('encoding'))))):
|
||||
return authenticate()
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.helpers.variable import natcmp
|
||||
from flask.globals import current_app
|
||||
from flask.helpers import json, make_response
|
||||
from libs.werkzeug.urls import url_decode
|
||||
from urllib import unquote
|
||||
from werkzeug.urls import url_decode
|
||||
import flask
|
||||
import re
|
||||
|
||||
@@ -57,7 +57,7 @@ def dictToList(params):
|
||||
|
||||
def getParam(attr, default = None):
|
||||
try:
|
||||
return toUnicode(unquote(getattr(flask.request, 'args').get(attr, default)))
|
||||
return getParams().get(attr, default)
|
||||
except:
|
||||
return default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user