rustfs-policy

Crates.iorustfs-policy
lib.rsrustfs-policy
version0.0.3
created_at2025-07-05 00:13:29.449946+00
updated_at2025-07-05 00:13:29.449946+00
descriptionPolicy management for RustFS, providing a framework for defining and enforcing policies across the system.
homepagehttps://rustfs.com
repositoryhttps://github.com/rustfs/rustfs
max_upload_size
id1738651
size278,608
houseme (houseme)

documentation

https://docs.rs/rustfs-policy/latest/rustfs_policy/

README

RustFS

RustFS Policy Engine

Advanced policy-based access control engine for RustFS distributed object storage

CI πŸ“– Documentation Β· πŸ› Bug Reports Β· πŸ’¬ Discussions


πŸ“– Overview

RustFS Policy Engine is a sophisticated access control system for the RustFS distributed object storage platform. It provides fine-grained, attribute-based access control (ABAC) with support for complex policy expressions, dynamic evaluation, and AWS IAM-compatible policy syntax.

Note: This is a core submodule of RustFS that provides essential access control and authorization capabilities for the distributed object storage system. For the complete RustFS experience, please visit the main RustFS repository.

✨ Features

πŸ” Access Control

  • AWS IAM Compatible: Full support for AWS IAM policy syntax
  • Fine-Grained Permissions: Resource-level and action-level access control
  • Dynamic Policy Evaluation: Real-time policy evaluation with context
  • Conditional Access: Support for complex conditional expressions

πŸ“œ Policy Management

  • Policy Documents: Structured policy definition and management
  • Policy Versioning: Version control for policy documents
  • Policy Validation: Syntax and semantic validation
  • Policy Templates: Pre-built policy templates for common use cases

🎯 Advanced Features

  • Attribute-Based Access Control (ABAC): Context-aware access decisions
  • Function-Based Conditions: Rich set of condition functions
  • Principal-Based Policies: User, group, and service account policies
  • Resource-Based Policies: Bucket and object-level policies

πŸ› οΈ Integration Features

  • ARN Support: AWS-style Amazon Resource Names
  • Multi-Tenant Support: Isolated policy evaluation per tenant
  • Real-Time Evaluation: High-performance policy evaluation engine
  • Audit Trail: Comprehensive policy evaluation logging

πŸ—οΈ Architecture

Policy Engine Architecture

Policy Engine Architecture:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Policy API Layer                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Policy Parser   β”‚   Policy Validator   β”‚   Policy Store   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              Policy Evaluation Engine                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Condition Functions  β”‚  Principal Resolver  β”‚  Resource Mgr β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              Authentication Integration                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Policy Decision Flow

Policy Decision Flow:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Request   │───▢│   Policy    │───▢│   Decision  β”‚
β”‚  (Subject,  β”‚    β”‚  Evaluation β”‚    β”‚  (Allow/    β”‚
β”‚   Action,   β”‚    β”‚   Engine    β”‚    β”‚   Deny/     β”‚
β”‚  Resource)  β”‚    β”‚             β”‚    β”‚  Not Found) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚                   β”‚
       β–Ό                   β–Ό                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Context    β”‚    β”‚  Condition  β”‚    β”‚   Audit     β”‚
β”‚ Information β”‚    β”‚ Functions   β”‚    β”‚    Log      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Installation

Add this to your Cargo.toml:

[dependencies]
rustfs-policy = "0.0.3"

πŸ”§ Usage

πŸš€ Performance Optimization

Caching Strategy

  • Policy Document Cache: Cache parsed policy documents
  • Evaluation Result Cache: Cache evaluation results for identical requests
  • Condition Cache: Cache condition function results
  • Principal Cache: Cache principal resolution results

Best Practices

  1. Minimize Policy Size: Keep policies as small as possible
  2. Use Specific Actions: Avoid overly broad action patterns
  3. Optimize Conditions: Use efficient condition functions
  4. Cache Frequently Used Policies: Enable policy caching for better performance

🀝 Integration with RustFS

The Policy Engine integrates seamlessly with other RustFS components:

  • IAM Module: Provides policy storage and user/group management
  • ECStore: Implements resource-based access control
  • API Server: Enforces policies on S3 API operations
  • Audit System: Logs policy evaluation decisions
  • Admin Interface: Manages policy documents and templates

πŸ“‹ Requirements

  • Rust: 1.70.0 or later
  • Platforms: Linux, macOS, Windows
  • Memory: Minimum 1GB RAM for policy caching
  • Storage: Compatible with RustFS storage backend

πŸ› Troubleshooting

Common Issues

  1. Policy Parse Errors:

    • Check JSON syntax validity
    • Verify action and resource ARN formats
    • Validate condition function syntax
  2. Policy Evaluation Failures:

    • Check principal resolution
    • Verify resource ARN matching
    • Debug condition function evaluation
  3. Performance Issues:

    • Monitor policy cache hit rates
    • Check policy document sizes
    • Optimize condition functions

Debug Commands

# Validate policy syntax
rustfs-cli policy validate --file policy.json

# Test policy evaluation
rustfs-cli policy test --policy policy.json --user john --action s3:GetObject --resource arn:aws:s3:::bucket/key

# Show policy evaluation trace
rustfs-cli policy trace --policy policy.json --user john --action s3:GetObject --resource arn:aws:s3:::bucket/key

🌍 Related Projects

This module is part of the RustFS ecosystem:

πŸ“š Documentation

For comprehensive documentation, visit:

πŸ”— Links

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Policy engine architecture and design patterns
  • Policy language syntax and semantics
  • Condition function implementation
  • Performance optimization techniques
  • Security considerations for access control

Development Setup

# Clone the repository
git clone https://github.com/rustfs/rustfs.git
cd rustfs

# Navigate to Policy module
cd crates/policy

# Install dependencies
cargo build

# Run tests
cargo test

# Run policy validation tests
cargo test policy_validation

# Format code
cargo fmt

# Run linter
cargo clippy

πŸ’¬ Getting Help

πŸ“ž Contact

πŸ‘₯ Contributors

This module is maintained by the RustFS security team and community contributors. Special thanks to all who have contributed to making RustFS access control robust and flexible.

πŸ“„ License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Copyright 2024 RustFS Team

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

RustFS is a trademark of RustFS, Inc.
All other trademarks are the property of their respective owners.

Made with πŸ›‘οΈ by the RustFS Security Team

Commit count: 0

cargo fmt