Fix get_apikey API command with a hashed password
This commit is contained in:
@@ -20,6 +20,8 @@ from __future__ import unicode_literals
|
|||||||
from future.builtins import str
|
from future.builtins import str
|
||||||
from future.builtins import object
|
from future.builtins import object
|
||||||
|
|
||||||
|
from hashing_passwords import check_hash
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
@@ -609,9 +611,17 @@ General optional parameters:
|
|||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
data = None
|
data = None
|
||||||
apikey = hashlib.sha224(str(random.getrandbits(256))).hexdigest()[0:32]
|
apikey = hashlib.sha224(str(random.getrandbits(256)).encode('utf-8')).hexdigest()[0:32]
|
||||||
if plexpy.CONFIG.HTTP_USERNAME and plexpy.CONFIG.HTTP_PASSWORD:
|
if plexpy.CONFIG.HTTP_USERNAME and plexpy.CONFIG.HTTP_PASSWORD:
|
||||||
if username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
|
authenticated = False
|
||||||
|
if plexpy.CONFIG.HTTP_HASHED_PASSWORD and \
|
||||||
|
username == plexpy.CONFIG.HTTP_USERNAME and check_hash(password, plexpy.CONFIG.HTTP_PASSWORD):
|
||||||
|
authenticated = True
|
||||||
|
elif not plexpy.CONFIG.HTTP_HASHED_PASSWORD and \
|
||||||
|
username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
|
||||||
|
authenticated = True
|
||||||
|
|
||||||
|
if authenticated:
|
||||||
if plexpy.CONFIG.API_KEY:
|
if plexpy.CONFIG.API_KEY:
|
||||||
data = plexpy.CONFIG.API_KEY
|
data = plexpy.CONFIG.API_KEY
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user