mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-03 10:36:45 +09:00
Require valid access-token sessions, scope application and server rooms, and enforce run visibility consistently across sockets and polling. Add positive-delivery and cross-user isolation regressions.
25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
"""Run envelope REST twin (plan 77 E1).
|
|
|
|
The polling counterpart of the `run_log` / `run_status` socket events: any
|
|
run kind's persisted lines, resumable via ?after_id, so a client that missed
|
|
socket frames (or has sockets disabled) can always catch up. The deploy kind
|
|
keeps its richer legacy endpoint (/api/v1/deployment-jobs/<id>/logs) — this
|
|
one serves every kind stored in run_log_entries.
|
|
"""
|
|
from flask import Blueprint, jsonify, request
|
|
|
|
from app.middleware.rbac import auth_required, get_current_user
|
|
from app.services.run_access import can_read_run
|
|
from app.services.run_log_service import list_run_logs
|
|
|
|
runs_bp = Blueprint('runs', __name__)
|
|
|
|
|
|
@runs_bp.route('/<run_kind>/<run_id>/logs', methods=['GET'])
|
|
@auth_required()
|
|
def get_run_logs(run_kind, run_id):
|
|
if not can_read_run(get_current_user(), run_kind, run_id):
|
|
return jsonify({'error': 'Run not found or access denied'}), 403
|
|
after_id = request.args.get('after_id', type=int)
|
|
return jsonify({'logs': list_run_logs(run_kind, run_id, after_id=after_id)}), 200
|