Add site-wide login gate protecting the whole app

Chat/memory/logs/models APIs were reachable without any auth even
though the app is deployed publicly behind Caddy HTTPS; only the
settings screen had a password. Add an optional SITE_PASSWORD-backed
session cookie gate in front of everything (settings included, on
top of its existing SETTINGS_PASSWORD), with a matching login screen
on the frontend. Stays fully backward compatible: with SITE_PASSWORD
unset the app behaves exactly as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 23:04:01 +09:00
co-authored by Claude Sonnet 5
parent 002282a8b7
commit 1ad8b130c7
12 changed files with 319 additions and 38 deletions
+11
View File
@@ -21,6 +21,17 @@ DEBUG=false
# HTTPS化していない環境ではBasic認証の資格情報が平文で流れるため、公開環境ではHTTPS化とセットで使うこと。
SETTINGS_PASSWORD=
# サイト全体(チャット含む全機能)を保護する簡易パスワード。SETTINGS_PASSWORDとは別物。
# 未設定だとこれまで通りサイト全体が無認証で使える。外部公開する場合は必ず設定すること。
SITE_PASSWORD=
# セッションCookieの署名鍵。未設定でも動くが、その場合バックエンド再起動のたびに全員ログインし直しになる。
# 公開環境では `openssl rand -hex 32` などで生成した値を設定しておくこと。
SESSION_SECRET_KEY=
# ローカルのhttp開発環境(HTTPS化していない)でログインが効かない場合のみ false にする。公開環境では変更しないこと。
SESSION_COOKIE_SECURE=true
# ログインセッションの有効日数
SESSION_MAX_AGE_DAYS=30
# Tavily Web検索(未設定だとweb_searchツールは何も検索せず空振りする)
TAVILY_API_KEY=
# 蓄積知識をシステムプロンプトに注入する際の最大件数