Fix get_apikey API command with a hashed password

This commit is contained in:
JonnyWong16 2020-08-08 21:19:39 -07:00
parent ba9acd6e23
commit b4ba88b3e5
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -20,6 +20,8 @@ from __future__ import unicode_literals
from future.builtins import str
from future.builtins import object
from hashing_passwords import check_hash
import hashlib
import inspect
import json
@ -609,9 +611,17 @@ General optional parameters:
```
"""
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 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:
data = plexpy.CONFIG.API_KEY
else: