diff --git a/plugins/host_agent/routes.py b/plugins/host_agent/routes.py index f74b7f8..f5c2221 100644 --- a/plugins/host_agent/routes.py +++ b/plugins/host_agent/routes.py @@ -9,7 +9,7 @@ from pathlib import Path import secrets from quart import Blueprint, current_app, jsonify, request, Response, render_template, redirect, url_for, session -from steward.auth.middleware import require_role +from steward.auth.middleware import public_route, require_role from steward.models.users import UserRole from sqlalchemy import select, func, or_, and_ from datetime import timedelta @@ -166,6 +166,7 @@ def _error(status: int, code: str, detail: str | None = None) -> tuple[Any, int] @host_agent_bp.post("/ingest") +@public_route("the agent authenticates with its bearer token") async def ingest(): auth = request.headers.get("Authorization", "") if not auth.startswith("Bearer "): @@ -313,6 +314,7 @@ def _agent_version() -> str: @host_agent_bp.get("/install.sh") +@public_route("fetched by curl on the host being enrolled; carries an enrolment token") async def install_script(): token = request.args.get("token", "") if not token: @@ -344,6 +346,7 @@ async def install_script(): @host_agent_bp.get("/agent.py") +@public_route("fetched by the installer and by agent self-update; holds no secrets") async def agent_source(): try: body = AGENT_SOURCE_PATH.read_text(encoding="utf-8") @@ -470,6 +473,7 @@ async def _fleet_rows(session) -> list[dict]: @host_agent_bp.get("/widget") +@require_role(UserRole.viewer) async def widget_table(): """Fleet-glance dashboard widget: one row per monitored host, latest metrics.""" async with current_app.db_sessionmaker() as session: @@ -478,6 +482,7 @@ async def widget_table(): @host_agent_bp.get("/widget/history") +@require_role(UserRole.viewer) async def widget_history(): host_id = request.args.get("host_id", "") try: diff --git a/plugins/host_agent/templates/widget_history.html b/plugins/host_agent/templates/widget_history.html index 1c13783..01e7c5b 100644 --- a/plugins/host_agent/templates/widget_history.html +++ b/plugins/host_agent/templates/widget_history.html @@ -22,7 +22,7 @@ {% endif %} {% for opt in [1, 6, 24] %} - @@ -36,11 +36,15 @@