Auth: Add option to disable authentication

This creates a massive security hole, but it's gated behind a flag
for users who only use localhost.

A warning will pop up when users disable authentication.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-12-21 23:40:16 -05:00
parent 99a798e117
commit 8fa764bfbe
3 changed files with 32 additions and 5 deletions

View file

@ -380,9 +380,6 @@ async def generate_chat_completion(request: Request, data: ChatCompletionRequest
return response
if __name__ == "__main__":
# Initialize auth keys
load_auth_keys()
# Load from YAML config. Possibly add a config -> kwargs conversion function
try:
with open('config.yml', 'r', encoding = "utf8") as config_file:
@ -395,6 +392,11 @@ if __name__ == "__main__":
)
config = {}
network_config = unwrap(config.get("network"), {})
# Initialize auth keys
load_auth_keys(unwrap(network_config.get("disable_auth"), False))
# Override the generation log options if given
log_config = unwrap(config.get("logging"), {})
if log_config:
@ -426,7 +428,6 @@ if __name__ == "__main__":
lora_dir = pathlib.Path(unwrap(lora_config.get("lora_dir"), "loras"))
model_container.load_loras(lora_dir.resolve(), **lora_config)
network_config = unwrap(config.get("network"), {})
uvicorn.run(
app,
host=network_config.get("host", "127.0.0.1"),