fix(jobs,database-jobs): grant authenticated EXECUTE on add_job#77
Merged
Merged
Conversation
Adds narrow GRANT pattern so that SECURITY INVOKER trigger functions can call app_jobs.add_job() without requiring the entire trigger body to be SECURITY DEFINER: - GRANT USAGE ON SCHEMA app_jobs TO authenticated - GRANT EXECUTE ON FUNCTION app_jobs.add_job(...) TO authenticated This allows job-enqueue triggers to respect RLS and role context for all operations except the actual job enqueue, which is already SECURITY DEFINER. Changes for both packages/jobs (7-param signature) and packages/database-jobs (10-param signature with entity_id, organization_id, entity_type). Also syncs sql/ output with current package.json versions via pgpm package. Refs: constructive-db#1496, constructive-planning#998
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upstream the GRANT pattern from constructive-db#1496 so that SECURITY INVOKER trigger functions can call
app_jobs.add_job()without requiring the entire trigger body to be SECURITY DEFINER.Two changes per package (
packages/jobsandpackages/database-jobs):schema.sqladdsGRANT USAGE ON SCHEMA app_jobs TO authenticatedGRANT EXECUTE ON FUNCTION app_jobs.add_job(...) TO authenticatedThis lets triggers stay INVOKER (respecting RLS for entity lookups, org resolution, future cloud function validation) while only
add_jobitself escalates (it's already SECURITY DEFINER).Also syncs
sql/output with currentpackage.jsonversions viapgpm package—pgpm-jobscontrol was stuck at 0.15.5 while package.json was 0.26.0.Refs: constructive-planning#998
Link to Devin session: https://app.devin.ai/sessions/2d4e3ceffc994b2486b4a9b010e14642
Requested by: @pyramation