feat: no auth by default

This commit is contained in:
arkohut 2024-11-14 14:47:35 +08:00
parent bdac92fb34
commit e889aa86de
3 changed files with 8 additions and 5 deletions

View File

@ -70,8 +70,8 @@ class Settings(BaseSettings):
# Embedding settings
embedding: EmbeddingSettings = EmbeddingSettings()
auth_username: str = "admin"
auth_password: SecretStr = SecretStr("changeme")
auth_username: str = ""
auth_password: SecretStr = SecretStr("")
default_plugins: List[str] = ["builtin_ocr"]

View File

@ -6,8 +6,10 @@ screenshots_dir: screenshots
server_host: 0.0.0.0
server_port: 8839
auth_username: admin
auth_password: changeme
# Enable authentication by uncommenting the following lines
# auth_username: admin
# auth_password: changeme
default_plugins:
- builtin_ocr
# - builtin_vlm

View File

@ -96,6 +96,7 @@ def is_auth_enabled():
def authenticate(credentials: HTTPBasicCredentials = Depends(security)):
if not is_auth_enabled():
logging.info("Authentication is disabled - no username/password configured")
return None
correct_username = compare_digest(credentials.username, settings.auth_username)
correct_password = compare_digest(
@ -117,7 +118,7 @@ def optional_auth(credentials: HTTPBasicCredentials = Depends(security)):
@app.get("/")
async def serve_spa():
async def serve_spa(username: str = Depends(optional_auth)):
return FileResponse(os.path.join(current_dir, "static/app.html"))