Permission Denied for Schema 'cron' When Updating End Time via FrontEnd. #27917
-
Hello Supabase Community, I'm currently working on a project where I need to schedule and execute cron jobs in Supabase. My setup includes triggers and cron jobs that should automatically run certain functions when the end_time column in my tender table is updated using pg_cron. Everything works perfectly when I update the database directly via Supabase UI(For both role anon and postgres) , but I encounter a "permission denied for schema 'cron'" error when attempting to update the end_time from the flutter application (connected using anon key) loggen in as a authenticated user. I have granted all the permission to anon, which runs successfully: -- Grant usage on cron schema
GRANT USAGE ON SCHEMA cron TO anon;
-- Grant all privileges on tables in cron schema
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA cron TO anon;
-- Grant all privileges on functions in cron schema
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA cron TO anon;
-- Grant execute on specific cron.schedule functions based on identified signatures
GRANT EXECUTE ON FUNCTION cron.schedule(text, text) TO anon;
GRANT EXECUTE ON FUNCTION cron.schedule(text, text, text) TO anon;
GRANT EXECUTE ON FUNCTION cron.schedule_in_database(text, text, text, text, text, boolean) TO anon; I verified the permissions and returned true: -- Check if anon has USAGE on cron schema
SELECT has_schema_privilege('anon', 'cron', 'USAGE');
-- Check if anon has ALL PRIVILEGES on tables in cron schema
SELECT has_table_privilege('anon', 'cron.job', 'SELECT, INSERT, UPDATE, DELETE');
-- Check if anon has EXECUTE on specific cron.schedule functions
SELECT has_function_privilege('anon', 'cron.schedule(text, text)', 'EXECUTE');
SELECT has_function_privilege('anon', 'cron.schedule(text, text, text)', 'EXECUTE');
SELECT has_function_privilege('anon', 'cron.schedule_in_database(text, text, text, text, text, boolean)', 'EXECUTE'); I have disable RLS for the tender table too, to check if i need to apply some policies. But still getting the same problem. Is there any configuration or additional step am i missing?. any suggestions or a assistance is appreciated. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sorry, I have figured it out. Grant permission to anon not requires because, the user i logged belongs to authenticated. After granting permission to authenticated instead of anon, solved the issue. |
Beta Was this translation helpful? Give feedback.
-
For anyone running into this - h/t @GaryAustin1 |
Beta Was this translation helpful? Give feedback.
Sorry, I have figured it out. Grant permission to anon not requires because, the user i logged belongs to authenticated. After granting permission to authenticated instead of anon, solved the issue.