sync
This commit is contained in:
parent
841765df05
commit
82d1b6a652
|
@ -52,8 +52,8 @@ def main():
|
||||||
servers = get_config(args.config)
|
servers = get_config(args.config)
|
||||||
authorized_users = get_authorized_users(args.users_list)
|
authorized_users = get_authorized_users(args.users_list)
|
||||||
deactivate_security = args.deactivate_security
|
deactivate_security = args.deactivate_security
|
||||||
print("Ollama Proxy server")
|
ASCIIColors.red("Ollama Proxy server")
|
||||||
print("Author: ParisNeo")
|
ASCIIColors.red("Author: ParisNeo")
|
||||||
|
|
||||||
class RequestHandler(BaseHTTPRequestHandler):
|
class RequestHandler(BaseHTTPRequestHandler):
|
||||||
def add_access_log_entry(self, event, user, ip_address, access, server, nb_queued_requests_on_server, error=""):
|
def add_access_log_entry(self, event, user, ip_address, access, server, nb_queued_requests_on_server, error=""):
|
||||||
|
@ -91,8 +91,8 @@ def main():
|
||||||
auth_header = self.headers.get('Authorization')
|
auth_header = self.headers.get('Authorization')
|
||||||
if not auth_header or not auth_header.startswith('Bearer '):
|
if not auth_header or not auth_header.startswith('Bearer '):
|
||||||
return False
|
return False
|
||||||
token = auth_header.split(' ')[1]
|
token = auth_header.split(' ')[1]
|
||||||
user, key = token.split(':')
|
user, key = token.split(':')
|
||||||
|
|
||||||
# Check if the user and key are in the list of authorized users
|
# Check if the user and key are in the list of authorized users
|
||||||
if authorized_users.get(user) == key:
|
if authorized_users.get(user) == key:
|
||||||
|
@ -103,6 +103,7 @@ def main():
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def proxy(self):
|
def proxy(self):
|
||||||
if not deactivate_security and not self._validate_user_and_key():
|
if not deactivate_security and not self._validate_user_and_key():
|
||||||
ASCIIColors.red(f'User is not authorized')
|
ASCIIColors.red(f'User is not authorized')
|
||||||
|
|
Loading…
Reference in New Issue