Skip to main content

Minimal utilities for managing SyftBox file permissions

Project description

syft-perm

Minimal utilities for managing SyftBox file permissions.

Overview

syft-perm provides simple, focused utilities for reading, setting, and removing file permissions in SyftBox environments. It handles the creation and management of syft.pub.yaml permission files.

Installation

pip install syft-perm

For SyftBox integration:

pip install syft-perm[syftbox]

Usage

Basic Permission Management

from syft_perm import set_file_permissions, get_file_permissions, remove_file_permissions

# Set permissions for a file
set_file_permissions(
    "path/to/file.txt",
    read_users=["alice@example.com", "bob@example.com"],
    write_users=["alice@example.com"]
)

# Get current permissions
permissions = get_file_permissions("path/to/file.txt")
print(permissions)  # {'read': ['alice@example.com', 'bob@example.com'], 'write': ['alice@example.com']}

# Remove permissions
remove_file_permissions("path/to/file.txt")

SyftBox URL Support

Works with both local paths and syft:// URLs:

# Local path
set_file_permissions("/local/path/file.txt", read_users=["public"])

# SyftBox URL (requires syft-core)
set_file_permissions("syft://alice@example.com/public/data.csv", read_users=["bob@example.com"])

Public Access

Use "public" or "*" for public access:

set_file_permissions(
    "public_file.txt",
    read_users=["public"],  # Anyone can read
    write_users=["alice@example.com"]  # Only alice can write
)

API Reference

set_file_permissions(file_path_or_syfturl, read_users, write_users=None, admin_users=None)

Set permissions for a file by updating the corresponding syft.pub.yaml file.

Parameters:

  • file_path_or_syfturl: Local file path or syft:// URL
  • read_users: List of users who can read the file
  • write_users: List of users who can write the file (optional)
  • admin_users: List of users who have admin access (optional, defaults to write_users)

get_file_permissions(file_path_or_syfturl)

Read current permissions for a file from syft.pub.yaml.

Returns: Dictionary with access permissions, or None if not found.

remove_file_permissions(file_path_or_syfturl)

Remove permissions for a file from syft.pub.yaml.

Requirements

  • Python 3.8+
  • PyYAML 6.0+
  • syft-core (optional, for syft:// URL support)

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syft_perm-0.2.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syft_perm-0.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file syft_perm-0.2.0.tar.gz.

File metadata

  • Download URL: syft_perm-0.2.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for syft_perm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 276f95d43d71c04694b6b7d3efd26177bd3451a26b13adf635f2d60f9b007fac
MD5 27be18d728e28dab6c5f9528e0923aaa
BLAKE2b-256 2c647207ba089a3fa03efa3f05282aa05bd74f39d503d900c5aeb71b1c12d79c

See more details on using hashes here.

File details

Details for the file syft_perm-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: syft_perm-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for syft_perm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c45d8fc0b7d9edf39c5f3737f7970601a9217f28a46519db206bceab58783d6d
MD5 1675b2703a91808bac323e4c40bde9c8
BLAKE2b-256 8a2b9b7bdfe88a30af10cdab15b0d992a21ed3ea560b93fdf2cda8240a00b654

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page