Class: Parse::Constraint::NotReadableByConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::NotReadableByConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Note:
"Not readable by X" excludes rows readable by X directly, via
any role X inherits, AND publicly — so a User value expands its
roles and the public "*" is always added to the exclusion set.
Note:
This constraint uses aggregation pipeline because Parse Server restricts direct queries on the internal _rperm field.
ACL NOT Readable By Constraint Query objects that are NOT readable by the specified users/roles. Useful for finding objects hidden from specific users.
Instance Method Summary collapse
Instance Method Details
#build ⇒ Object
3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 |
# File 'lib/parse/query/constraints.rb', line 3288 def build keys = ACLPermissions.collect_for_negation(@value) return { "__aggregation_pipeline" => [] } if keys.empty? # Find objects whose _rperm EXISTS and does NOT contain any of the # keys. The `$exists: true` guard is essential: Parse Server treats a # missing `_rperm` as publicly readable, and MongoDB's `$nin` matches # documents where the field is absent. Without the guard, # `not_readable_by("*")` (i.e. #not_publicly_readable) would MATCH the # public-by-absence rows it is meant to exclude — inverting the result # and giving a security audit a false sense of safety. pipeline = [ { "$match" => { "_rperm" => { "$exists" => true, "$nin" => keys }, }, }, ] { "__aggregation_pipeline" => pipeline } end |