Skip to content

Commit

Permalink
Fixed AutoRefresh crashing when database triggers are set up from the…
Browse files Browse the repository at this point in the history
… ihp_authenticated role

The ihp_authenticated role typically doesn't have permissions to set up triggers. This caused the first AutoRefresh call to a table to fail if row level security policies have been used and IHP tried to call the database from the ihp_authenticated role.
  • Loading branch information
mpscholten committed Dec 29, 2021
1 parent 09725bc commit d03da4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion IHP/AutoRefresh.hs
Expand Up @@ -162,7 +162,11 @@ registerNotificationTrigger touchedTablesVar autoRefreshServer = do
pgListener <- get #pgListener <$> readIORef autoRefreshServer
subscriptions <- subscriptionRequired |> mapM (\table -> do
let createTriggerSql = notificationTrigger table
sqlExec createTriggerSql ()

-- We need to add the trigger from the main IHP database role other we will get this error:
-- ERROR: permission denied for schema public
withRowLevelSecurityDisabled do
sqlExec createTriggerSql ()

pgListener |> PGListener.subscribe (channelName table) \notification -> do
sessions <- (get #sessions) <$> readIORef autoRefreshServer
Expand Down

0 comments on commit d03da4f

Please sign in to comment.