Re: Need help revoking access WHERE state = 'deleted'

Поиск
Список
Период
Сортировка
От Ben Morrow
Тема Re: Need help revoking access WHERE state = 'deleted'
Дата
Msg-id 20130228180201.GA10412@anubis.morrow.me.uk
обсуждение исходный текст
Ответ на Need help revoking access WHERE state = 'deleted'  (Mark Stosberg <mark@summersault.com>)
Ответы Re: Need help revoking access WHERE state = 'deleted'  (Mark Stosberg <mark@summersault.com>)
Re: Need help revoking access WHERE state = 'deleted'  (Wayne Cuddy <lists-pgsql@useunix.net>)
Список pgsql-sql
Quoth mark@summersault.com (Mark Stosberg):
> 
> We are working on a project to start storing some data as "soft deleted"
> (WHERE state = 'deleted') instead of hard-deleting it.
> 
> To make sure that we never accidentally expose the deleted rows through
> the application, I had the idea to use a view and permissions for this
> purpose.
> 
> I thought I could revoke SELECT access to the "entities" table, but then
> grant SELECT access to a view:
> 
>   CREATE VIEW entities_not_deleted AS SELECT * FROM entities WHERE state
> != 'deleted';
> 
> We could then find/replace in the code to replace references to the
> "entities" table with the "entities_not_deleted" table

(If you wanted to you could instead rename the table, and use rules on
the view to transform DELETE to UPDATE SET state = 'deleted' and copy
across INSERT and UPDATE...)

> However, this isn't working, I "permission denied" when trying to use
> the view. (as the same user that has had their SELECT access removed to
> the underlying table.)

Works for me. Have you made an explicit GRANT on the view? Make sure
you've read section 37.4 'Rules and Privileges' in the documentation,
since it explains the ways in which this sort of information hiding is
not ironclad.

Ben




В списке pgsql-sql по дате отправления:

Предыдущее
От: Mark Stosberg
Дата:
Сообщение: Need help revoking access WHERE state = 'deleted'
Следующее
От: Mark Stosberg
Дата:
Сообщение: Re: Need help revoking access WHERE state = 'deleted'