mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 09:42:57 -07:00
Better apikey generation
This commit is contained in:
parent
6cae12d467
commit
7e7693f206
2 changed files with 6 additions and 5 deletions
|
@ -84,9 +84,6 @@ def delete_mobile_device(device_id=None):
|
||||||
def blacklist_logger():
|
def blacklist_logger():
|
||||||
devices = get_mobile_devices()
|
devices = get_mobile_devices()
|
||||||
|
|
||||||
blacklist = []
|
blacklist = [d['device_token'] for d in devices]
|
||||||
|
|
||||||
for d in devices:
|
|
||||||
blacklist.append(d['device_token'])
|
|
||||||
|
|
||||||
logger._BLACKLIST_WORDS.extend(blacklist)
|
logger._BLACKLIST_WORDS.extend(blacklist)
|
||||||
|
|
|
@ -19,6 +19,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
|
import uuid
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
from cherrypy.lib.static import serve_file, serve_download
|
from cherrypy.lib.static import serve_file, serve_download
|
||||||
|
@ -3489,7 +3490,10 @@ class WebInterface(object):
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
def generate_api_key(self, device=None, **kwargs):
|
def generate_api_key(self, device=None, **kwargs):
|
||||||
apikey = hashlib.sha224(str(random.getrandbits(256))).hexdigest()[0:32]
|
apikey = ''
|
||||||
|
while not apikey or apikey == plexpy.CONFIG.API_KEY or mobile_app.get_mobile_device_by_token(device_token=apikey):
|
||||||
|
apikey = uuid.uuid4().hex
|
||||||
|
|
||||||
logger.info(u"New API key generated.")
|
logger.info(u"New API key generated.")
|
||||||
logger._BLACKLIST_WORDS.append(apikey)
|
logger._BLACKLIST_WORDS.append(apikey)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue