handle when auth token is not enabled

This commit is contained in:
Cyberes 2023-09-24 15:57:39 -06:00
parent 8d6b2ce49c
commit 84ea2f8891
2 changed files with 4 additions and 3 deletions

View File

@ -7,6 +7,10 @@ from llm_server import opts
def check_auth(token): def check_auth(token):
if not opts.admin_token:
# The admin token is not set/enabled.
# Default: deny all.
return False
password = None password = None
if token.startswith('Basic '): if token.startswith('Basic '):
try: try:
@ -17,7 +21,6 @@ def check_auth(token):
password = token.split('Bearer ', maxsplit=1) password = token.split('Bearer ', maxsplit=1)
del password[0] del password[0]
password = ''.join(password) password = ''.join(password)
print(password, token)
return password == opts.admin_token return password == opts.admin_token

View File

@ -9,7 +9,6 @@ redis~=5.0.0
gevent gevent
async-timeout async-timeout
flask-sock flask-sock
auto_gptq
uvicorn~=0.23.2 uvicorn~=0.23.2
fastapi~=0.103.1 fastapi~=0.103.1
torch~=2.0.1 torch~=2.0.1
@ -17,6 +16,5 @@ urllib3~=2.0.4
PyMySQL~=1.1.0 PyMySQL~=1.1.0
DBUtils~=3.0.3 DBUtils~=3.0.3
simplejson~=3.19.1 simplejson~=3.19.1
setuptools~=65.5.1
websockets~=11.0.3 websockets~=11.0.3
basicauth~=1.0.0 basicauth~=1.0.0