Skip to content

mi3guyc/pim-perms-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

PIM-Perms Backend

Backend monorepo containing 15 crates for the PIM-Perms permission system.

What's in This Repository

This repository contains the complete backend implementation:

  • Foundation (3 crates): pim-perms-models, pim-perms-crypto, pim-perms-database
  • Services (2 crates): pim-perms-cache, pim-perms-audit
  • Auth Providers (5 crates): pim-perms-providers, pim-perms-providers-local, pim-perms-providers-ldap, pim-perms-providers-oauth, pim-perms-providers-saml
  • Core Engine (5 crates): pim-perms-inheritance, pim-perms-time-windows, pim-perms-workflow, pim-perms-rbac, pim-perms-core
  • API (2 crates): pim-perms-middleware, pim-perms-api

Quick Start

Prerequisites

  • Rust 1.70+
  • PostgreSQL 14+ or SQLite 3.35+
  • Redis (optional, for distributed caching)

Build

# Clone and enter directory
cd pim-perms-backend

# Build all crates
cargo build --all

# Run tests
cargo test --all

# Run with auto-fix
cargo clippy --all --fix
cargo fmt --all

Structure

pim-perms-backend/
├── Cargo.toml           # Workspace configuration
├── crates/              # All 15 crates
│   ├── pim-perms-models/
│   ├── pim-perms-crypto/
│   └── ...
├── tests/               # Integration tests
├── test-utils/          # Shared test utilities
└── docs/                # This repo's documentation

Documentation

Central Documentation: pim-perms-docs

Backend-Specific:

Full Architecture:

Testing

This repository uses comprehensive testing at multiple levels:

  • Unit Tests: Each crate has tests in crates/*/tests/
  • Integration Tests: Cross-crate tests in tests/
  • Coverage Target: 80%+ for all crates
  • Linting: Clippy with -D warnings (fail on any warnings)
# Run all tests
cargo test --all

# Check coverage
cargo tarpaulin --all

# Lint
cargo clippy --all -- -D warnings

# Auto-fix linting issues
./scripts/lint-fix.sh

CI/CD

GitHub Actions automatically:

  • ✅ Runs tests on every PR
  • ✅ Checks code formatting
  • ✅ Runs clippy with strict settings
  • ✅ Measures code coverage
  • ✅ Auto-fixes formatting and some clippy warnings (commits back to PR)

Development Workflow

Branch Strategy

Use feature branches for concurrent development:

# Example: Implementing models crate
git checkout -b feature/models
# Work on crates/pim-perms-models/
git add crates/pim-perms-models/
git commit -m "feat(models): implement User and Group types"
git push origin feature/models

Multiple developers can work on different crates simultaneously with zero merge conflicts since each crate is in its own directory.

Pre-commit Hooks

Install pre-commit hooks to catch issues early:

# Install pre-commit (if not already installed)
pip install pre-commit

# Install hooks
pre-commit install

This will automatically run cargo fmt and cargo clippy before each commit.

Implementation Order

Follow this order for implementing crates:

  1. Week 1: Foundation

    • pim-perms-modelspim-perms-cryptopim-perms-database
  2. Week 2: Services (can parallelize)

    • pim-perms-cache + pim-perms-audit
  3. Week 3-4: Auth Providers (can parallelize)

    • pim-perms-providers → then all 4 provider implementations
  4. Week 5-6: Core Engine

    • pim-perms-inheritance, pim-perms-time-windows, pim-perms-workflowpim-perms-rbacpim-perms-core
  5. Week 7: API

    • pim-perms-middlewarepim-perms-api

Dependencies

External crates depend on published versions from crates.io or git:

# In downstream repos
[dependencies]
pim-perms-models = { git = "https://github.com/analog-pim/pim-perms-backend", package = "pim-perms-models" }

For local development, use path dependencies:

# .cargo/config.toml in other repos
[patch."https://github.com/analog-pim/pim-perms-backend"]
pim-perms-models = { path = "../pim-perms-backend/crates/pim-perms-models" }

Contributing

  1. Create a feature branch
  2. Implement your changes
  3. Write tests (maintain 80%+ coverage)
  4. Run cargo fmt and cargo clippy --fix
  5. Push and create PR
  6. CI will auto-fix minor issues and push back to your branch
  7. Address any remaining review comments
  8. Merge when approved and CI passes

Contact

See main PIM-Perms Documentation for project overview and contact information.

About

Backend monorepo for PIM-Perms permission system (15 Rust crates)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors