Common checks that need to be performed before we can start checking a role's privileges.
(
catalog: &impl SessionCatalog,
session_meta: &dyn SessionMetadata,
)
| 39 | |
| 40 | /// Common checks that need to be performed before we can start checking a role's privileges. |
| 41 | fn rbac_check_preamble( |
| 42 | catalog: &impl SessionCatalog, |
| 43 | session_meta: &dyn SessionMetadata, |
| 44 | ) -> Result<(), UnauthorizedError> { |
| 45 | // PostgreSQL allows users that have their role dropped to perform some actions, |
| 46 | // such as `SET ROLE` and certain `SELECT` queries. We haven't implemented |
| 47 | // `SET ROLE` and feel it's safer to force to user to re-authenticate if their |
| 48 | // role is dropped. |
| 49 | if catalog |
| 50 | .try_get_role(&session_meta.role_metadata().current_role) |
| 51 | .is_none() |
| 52 | { |
| 53 | return Err(UnauthorizedError::ConcurrentRoleDrop( |
| 54 | session_meta.role_metadata().current_role.clone(), |
| 55 | )); |
| 56 | }; |
| 57 | if catalog |
| 58 | .try_get_role(&session_meta.role_metadata().session_role) |
| 59 | .is_none() |
| 60 | { |
| 61 | return Err(UnauthorizedError::ConcurrentRoleDrop( |
| 62 | session_meta.role_metadata().session_role.clone(), |
| 63 | )); |
| 64 | }; |
| 65 | if catalog |
| 66 | .try_get_role(&session_meta.role_metadata().authenticated_role) |
| 67 | .is_none() |
| 68 | { |
| 69 | return Err(UnauthorizedError::ConcurrentRoleDrop( |
| 70 | session_meta.role_metadata().authenticated_role.clone(), |
| 71 | )); |
| 72 | }; |
| 73 | |
| 74 | Ok(()) |
| 75 | } |
| 76 | |
| 77 | /// Filters `RbacRequirements` based on the session role metadata and RBAC related feature flags. |
| 78 | fn filter_requirements( |
no test coverage detected