The main driver of RLS resolution for subscription queries. Mainly a wrapper around [resolve_views_for_expr].
(
tx: &impl SchemaView,
expr: ProjectName,
auth: &AuthCtx,
has_param: &mut bool,
)
| 13 | /// The main driver of RLS resolution for subscription queries. |
| 14 | /// Mainly a wrapper around [resolve_views_for_expr]. |
| 15 | pub fn resolve_views_for_sub( |
| 16 | tx: &impl SchemaView, |
| 17 | expr: ProjectName, |
| 18 | auth: &AuthCtx, |
| 19 | has_param: &mut bool, |
| 20 | ) -> anyhow::Result<Vec<ProjectName>> { |
| 21 | // RLS does not apply to the database owner |
| 22 | if auth.bypass_rls() { |
| 23 | return Ok(vec![expr]); |
| 24 | } |
| 25 | |
| 26 | let Some(return_name) = expr.return_name().cloned() else { |
| 27 | anyhow::bail!("Could not determine return type during RLS resolution") |
| 28 | }; |
| 29 | |
| 30 | // Unwrap the underlying `RelExpr` |
| 31 | let expr = match expr { |
| 32 | ProjectName::None(expr) | ProjectName::Some(expr, _) => expr, |
| 33 | }; |
| 34 | |
| 35 | resolve_views_for_expr( |
| 36 | tx, |
| 37 | expr, |
| 38 | // Do not ignore the return table when checking for RLS rules |
| 39 | None, |
| 40 | // Resolve list is empty as we are not yet resolving any RLS rules |
| 41 | Rc::new(ResolveList::None), |
| 42 | has_param, |
| 43 | &mut 0, |
| 44 | auth, |
| 45 | ) |
| 46 | .map(|fragments| { |
| 47 | fragments |
| 48 | .into_iter() |
| 49 | // The expanded fragments could be join trees, |
| 50 | // so wrap each of them in an outer project. |
| 51 | .map(|expr| ProjectName::Some(expr, return_name.clone())) |
| 52 | .collect() |
| 53 | }) |
| 54 | } |
| 55 | |
| 56 | /// The main driver of RLS resolution for sql queries. |
| 57 | /// Mainly a wrapper around [resolve_views_for_expr]. |
no test coverage detected
searching dependent graphs…