11
Right to re-grant
Granting privileges with the right to re-grant
alice=> GRANT privileges ON object TO bob WITH GRANT OPTION;
Revoking privileges
alice=> REVOKE privileges ON object FROM bob CASCADE;
Revoking the right to re-grant
alice=> REVOKE GRANT OPTION FOR
privileges ON object FROM bob CASCADE;
bob
charlie
alice
privileges
dave
p
r
i
v
i
l
e
g
e
s
p
r
i
v
i
l
e
g
e
s
required
if the privilege
was granted
to other roles
When granting certain privileges to a role, you can allow the role to grant (or
revoke) these privileges to other roles down the line. This is done with the
GRANT ... WITH GRANT OPTION command (a similar construction WITH
ADMIN OPTION for attributes was discussed in the topic “Roles” before).
If a role uses this right to re-grant, a hierarchy of roles is formed.
Privileges are revoked with the REVOKE command. A role can revoke only
those privileges that it has granted to others itself. In the example shown on
the slide, alice cannot revoke the privilege directly from charlie or
dave.
However, if the privilege is revoked from bob, it will be automatically
revoked from all the roles down the line in the hierarchy. This requires the
CASCADE keyword (if the hierarchy is not empty, then attempting to revoke
without the CASCADE keyword will return an error).
The right to re-grant can be revoked without revoking the privilege itself.
This is done with the REVOKE GRANT OPTION FOR command. The
CASCADE keyword works here similarly to when revoking a privilege.