Skip to main content

authorize_related_to

Function authorize_related_to 

Source
pub async fn authorize_related_to<F, Fut>(
    owning_class: &str,
    relation_key: &str,
    owning_protected_fields: &[String],
    detail: ErrorDetail,
    can_read_owning: F,
) -> Result<bool, ParseError>
where F: FnOnce() -> Fut, Fut: Future<Output = Result<bool, ParseError>>,
Expand description

authorizeRelatedToQuery (DatabaseController.js:1260-1308), run before the join table is read.

Two checks, and neither is redundant. The relation key must not be a protected field on the owning class, because the downstream protected-field filter only ever applies to the class being queried. And the caller must be able to read the owning object, because none of the owning class’s CLP or ACL is otherwise consulted.

can_read_owning performs the second check as a full read with the caller’s own auth. It is a parameter rather than a call into the pipeline so that the recursion stays at the one place that owns it.