Overview
RuleSet and Rule classes define permission policies for directories in a datasite. Each directory can have a syft.pub.yaml file containing a ruleset that specifies which users can access files within that directory and its subdirectories.
RuleSet
A collection of permission rules for a specific directory.Fields
List of permission rules. Rules are automatically sorted by specificity when added to a service, with more specific patterns checked first.
If
True, prevents the permission tree from traversing to parent directories when looking for rules. This enforces stricter isolation for subdirectories.The directory path this ruleset applies to (relative to the datasite root). This field is excluded from serialization and is set automatically when loading from the filesystem.
Methods
load
Loads a ruleset from a YAML file.Path to the
syft.pub.yaml file to load.The loaded ruleset with
path set to the file’s parent directory.Example
save
Saves the ruleset to a YAML file.Target file path. If
None, saves to {ruleset.path}/syft.pub.yaml.Example
Example
Rule
Defines a single permission rule with a pattern and access control list.Fields
A glob pattern that matches file paths. Supports wildcards and user templates:
*- Matches files in the current directory only**- Matches all files recursively*.csv- Matches CSV files in the current directory**/*.csv- Matches CSV files anywherereports/**- Matches everything under the reports directory{{.UserEmail}}/**- Matches user-specific directories (template)
{{.UserEmail}} template is replaced with the requesting user’s email during evaluation.Access control list specifying which users have which permissions for files matching this pattern.
Pattern Specificity
When multiple rules match a path, they are evaluated in order of specificity (most specific first):- User templates:
{{.UserEmail}}/** - Exact paths:
reports/q1.csv - Directory wildcards:
reports/** - Extension wildcards:
*.csv - Recursive extension:
**/*.csv - Catch-all:
**
ACLService.
Validation
Rules are validated when created. The following templates are not supported and will raise aValueError:
{{.UserHash}}{{.Year}}{{.Month}}{{.Date}}
Examples
Basic Rule
User Template Rule
Hierarchical Rules
PERMISSION_FILE_NAME
Constant defining the standard filename for permission files.Usage
Every directory that needs custom permissions should contain a file namedsyft.pub.yaml. When ACLService.load_permissions_from_filesystem() is called, it recursively searches for all files with this name.
Example Directory Structure
Permission File Protection
Accessing asyft.pub.yaml file itself always requires ADMIN access, even if a rule grants lower-level permissions to the directory. This prevents unauthorized users from reading the permission configuration.
Complete Example
YAML Configuration
Python Usage
See Also
- ACLService - Manage and enforce permissions
- Access - Configure access control lists
- AccessLevel - Understand access levels