Add web-based Uptime Kuma login with TOTP support
All checks were successful
Build and Push Container / build (push) Successful in 34s

- Add login modal for username/password/TOTP authentication
- Persist token to file for session persistence
- Make UPTIME_KUMA_API_KEY optional (can login via web UI)
- Add /api/kuma/auth, /api/kuma/login, /api/kuma/logout endpoints
- Show login prompt when not authenticated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-01-05 03:32:22 +00:00
parent 98a6d41b6d
commit e05faaacbe
6 changed files with 316 additions and 9 deletions

View File

@@ -406,6 +406,52 @@ def create_suggested_monitors():
return jsonify({"created": created})
# Uptime Kuma authentication endpoints
@app.route("/api/kuma/auth", methods=["GET"])
def kuma_auth_status():
"""Check if authenticated to Uptime Kuma."""
try:
kuma = get_kuma_client()
authenticated = kuma.is_authenticated()
config = get_config()
return jsonify({
"authenticated": authenticated,
"url": config.uptime_kuma_url,
})
except Exception as e:
return jsonify({"authenticated": False, "error": str(e)})
@app.route("/api/kuma/login", methods=["POST"])
def kuma_login():
"""Login to Uptime Kuma with username/password/TOTP."""
data = request.json
username = data.get("username")
password = data.get("password")
totp = data.get("totp") # Optional
if not username or not password:
return jsonify({"error": "username and password are required"}), 400
try:
kuma = get_kuma_client()
result = kuma.login(username, password, totp)
return jsonify(result)
except Exception as e:
return jsonify({"error": str(e)}), 401
@app.route("/api/kuma/logout", methods=["POST"])
def kuma_logout():
"""Logout from Uptime Kuma."""
try:
kuma = get_kuma_client()
kuma.logout()
return jsonify({"status": "ok"})
except Exception as e:
return jsonify({"error": str(e)}), 500
# Test Uptime Kuma connection
@app.route("/api/kuma/test", methods=["GET"])
def test_kuma_connection():