Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot] 2026-05-23 17:54:36 +00:00
parent b913f43dde
commit 70393534eb
4 changed files with 36 additions and 2 deletions

View file

@ -13,6 +13,7 @@
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.45.4";
import { corsHeaders } from "../_shared/cors.ts";
import { authorizeInternalRequest } from "../_shared/internal-auth.ts";
import { pullAgentCronjobsRuntimeState } from "../_shared/runtime-sync.ts";
const SUPABASE_URL = Deno.env.get("SUPABASE_URL")!;
@ -31,6 +32,13 @@ interface AgentRow {
Deno.serve(async (req) => {
if (req.method === "OPTIONS") return new Response(null, { headers: corsHeaders });
// Auth: aceita X-Internal-Secret (pg_cron) OU JWT de admin.
const auth = await authorizeInternalRequest(req, { allowOwner: false });
if (!auth.ok) {
console.warn(`keep-alive: auth rejected (${auth.reason})`);
return jsonResponse(401, { error: "unauthorized", reason: auth.reason });
}
const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, {
auth: { persistSession: false, autoRefreshToken: false },
});