Skip to content

digital-identity-platform-docs


digital-identity-platform-docs / supabase/functions/enforce-plan-compliance

supabase/functions/enforce-plan-compliance

Fileoverview

Plan Compliance Safety Job

A scheduled job that iterates all active container subscriptions and enforces plan entitlements as a safety net for missed webhook events.

Cloudflare Architecture Context

AttributeValue
Classification🔵 BACKEND-ONLY (Cron)
PositionAfter Cloudflare (works with billing data)
Receives Public TrafficNo (pg_cron or manual trigger)
Latency SensitiveNo
Safe to RetryYes (idempotent entitlement checks)
Failure BehaviorLogs errors per container, continues

Endpoint

POST /functions/v1/enforce-plan-compliance

Authentication

Protected by x-cron-secret header (not JWT).

Behavior

  • Fetches all containers with active subscriptions
  • Calls rpc_enforce_plan_entitlements() for each container
  • Reports summary of any corrections made

Schedule

Intended to run daily via external cron or Supabase scheduled functions.

Environment Variables

  • CRON_SECRET: Secret to authenticate cron calls
  • SUPABASE_URL: Supabase project URL
  • SUPABASE_SERVICE_ROLE_KEY: Service role key for admin operations

Released under proprietary license.