diff --git a/.DS_Store b/.DS_Store index db33070..8bfd930 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index d443429..67b7a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Generated files -pg_morbac.sql -pg_morbac--*.sql +pgmorbac.sql +pgmorbac--*.sql # Test database dumps *.dump diff --git a/CHANGELOG.md b/CHANGELOG.md index cb1ff8a..caaec7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,4 +41,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Complete documentation - Build and installation automation (Makefile, install.sh) -[1.0.0]: https://github.com/yourusername/pg_morbac/releases/tag/v1.0.0 +[1.0.0]: https://github.com/yourusername/pgmorbac/releases/tag/v1.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53a0030..a961ee9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to pg_morbac +# Contributing to pgmorbac -Thank you for your interest in contributing to pg_morbac! +Thank you for your interest in contributing to pgmorbac! ## How to Contribute @@ -62,8 +62,8 @@ brew install postgresql # macOS # or use your package manager # Clone your fork -git clone https://github.com/your-username/pg_morbac.git -cd pg_morbac +git clone https://github.com/your-username/pgmorbac.git +cd pgmorbac # Install the extension make install diff --git a/LICENSE b/LICENSE index 969d57c..7b3487a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 pg_morbac contributors +Copyright (c) 2026 pgmorbac contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 7ddbdb5..539158b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -# Makefile for pg_morbac PostgreSQL Extension +# Makefile for pgmorbac PostgreSQL Extension # Multi-OrBAC: Organization-Based Access Control -PROJECT_FILENAME = pg_morbac +PROJECT_FILENAME = pgmorbac # Read version from control file using centralized script PROJECT_VERSION = $(shell ./tools/get_version.sh $(PROJECT_FILENAME).control) @@ -97,7 +97,7 @@ docker-check: docker-install # Show help .PHONY: help help: - @echo "pg_morbac Makefile - Build and manage the PostgreSQL extension" + @echo "pgmorbac Makefile - Build and manage the PostgreSQL extension" @echo "" @echo "Makefile targets:" @echo " make build - Build $(OUTPUT_DEV_FILENAME) from src/" diff --git a/README.md b/README.md index ba16db8..9092636 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pg_morbac +# pgmorbac **Multi-Organization Based Access Control for PostgreSQL** @@ -33,15 +33,15 @@ A PostgreSQL extension implementing the Multi-OrBAC access control model - enabl ```bash # Clone repository -git clone https://github.com/yourusername/pg_morbac.git -cd pg_morbac +git clone https://github.com/yourusername/pgmorbac.git +cd pgmorbac # Build and install extension make build # Build versioned file from src/ sudo make install # Install to PostgreSQL # Enable in your database -psql -d mydb -c "CREATE EXTENSION pg_morbac;" +psql -d mydb -c "CREATE EXTENSION pgmorbac;" ``` ### Alternative: Using install script @@ -58,14 +58,14 @@ sudo ./tools/install.sh ```bash # Build versioned file from source -make build # Concatenates src/ files into pg_morbac--1.0.0.sql +make build # Concatenates src/ files into pgmorbac--1.0.0.sql # Copy files to PostgreSQL extension directory -sudo cp pg_morbac.control $(pg_config --sharedir)/extension/ -sudo cp pg_morbac--1.0.0.sql $(pg_config --sharedir)/extension/ +sudo cp pgmorbac.control $(pg_config --sharedir)/extension/ +sudo cp pgmorbac--1.0.0.sql $(pg_config --sharedir)/extension/ # Enable in PostgreSQL -psql -d mydb -c "CREATE EXTENSION pg_morbac;" +psql -d mydb -c "CREATE EXTENSION pgmorbac;" ``` ## Quick Start @@ -169,13 +169,13 @@ LIMIT 10; # Development workflow # 1. Edit source files in src/ directory # 2. Build and test -make build # Build versioned pg_morbac--X.Y.Z.sql from src/ +make build # Build versioned pgmorbac--X.Y.Z.sql from src/ make test # Build and run test suite # Manual testing make build createdb morbac_test -psql -d morbac_test -f pg_morbac.sql +psql -d morbac_test -f pgmorbac.sql # ... test manually ... dropdb morbac_test ``` @@ -216,8 +216,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. ```bash -git clone https://github.com/yourusername/pg_morbac.git -cd pg_morbac +git clone https://github.com/yourusername/pgmorbac.git +cd pgmorbac # Edit source files in src/ vim src/authorization.sql @@ -226,9 +226,9 @@ vim src/authorization.sql make test # Run test suite # When ready to release -# 1. Update version in pg_morbac.control +# 1. Update version in pgmorbac.control # 2. Build versioned file -make build # Creates pg_morbac--X.Y.Z.sql +make build # Creates pgmorbac--X.Y.Z.sql # 3. Tag in git git tag v1.0.1 git push --tags @@ -237,13 +237,13 @@ git push --tags ## Support - Read the [documentation](docs/DOCUMENTATION.md) -- Report bugs via [GitHub Issues](https://github.com/yourusername/pg_morbac/issues) -- Ask questions in [Discussions](https://github.com/yourusername/pg_morbac/discussions) +- Report bugs via [GitHub Issues](https://github.com/yourusername/pgmorbac/issues) +- Ask questions in [Discussions](https://github.com/yourusername/pgmorbac/discussions) - Security issues: see [SECURITY.md](SECURITY.md) ## Comparison with Traditional RBAC -| Feature | Traditional RBAC | Traditional OrBAC | pg_morbac (Multi-OrBAC) | +| Feature | Traditional RBAC | Traditional OrBAC | pgmorbac (Multi-OrBAC) | |---------|-----------------|-------------------|-------------------------| | Multi-tenancy | No | Single organization | Multi-organization | | Prohibitions | No | Yes | Yes | diff --git a/SECURITY.md b/SECURITY.md index 17b779f..a023bd4 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,7 +8,7 @@ ## Security Model -pg_morbac implements the Multi-OrBAC access control model with the following security principles: +pgmorbac implements the Multi-OrBAC access control model with the following security principles: ### Default Deny - No permission = access denied @@ -36,7 +36,7 @@ pg_morbac implements the Multi-OrBAC access control model with the following sec ## Reporting a Vulnerability -If you discover a security vulnerability in pg_morbac, please report it responsibly: +If you discover a security vulnerability in pgmorbac, please report it responsibly: ### DO NOT - Open a public GitHub issue for security vulnerabilities @@ -67,7 +67,7 @@ If you discover a security vulnerability in pg_morbac, please report it responsi ## Security Best Practices -When using pg_morbac: +When using pgmorbac: ### 1. Protect Authorization Headers ```sql @@ -80,7 +80,7 @@ When using pg_morbac: -- Always enable RLS on application tables ALTER TABLE app.documents ENABLE ROW LEVEL SECURITY; --- Use pg_morbac for authorization +-- Use pgmorbac for authorization CREATE POLICY doc_access ON app.documents FOR ALL USING (morbac.rls_check('read', 'documents')); ``` @@ -120,7 +120,7 @@ LIMIT 100; ### 5. Regular Updates - Keep PostgreSQL updated -- Monitor for pg_morbac security advisories +- Monitor for pgmorbac security advisories - Review and test policies regularly ### 6. Principle of Least Privilege @@ -138,4 +138,4 @@ LIMIT 100; ## Acknowledgments -We appreciate responsible disclosure and will acknowledge security researchers who help improve pg_morbac security. +We appreciate responsible disclosure and will acknowledge security researchers who help improve pgmorbac security. diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index f6fef70..9e8d425 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -3,21 +3,21 @@ ## Project Structure ``` -pg_morbac/ +pgmorbac/ ├── src/ # Modular SQL source files ├── tests/ # Test files ├── tools/ # Build and test scripts ├── docs/ # Documentation -├── pg_morbac.control # Version source of truth -├── pg_morbac.sql # Generated (git-ignored) +├── pgmorbac.control # Version source of truth +├── pgmorbac.sql # Generated (git-ignored) └── Makefile # Build automation ``` ## Version Management -Version is defined in `pg_morbac.control` under `default_version`. +Version is defined in `pgmorbac.control` under `default_version`. -Edit source files in `src/` and commit them. Never edit or commit `pg_morbac.sql` (generated by build script). +Edit source files in `src/` and commit them. Never edit or commit `pgmorbac.sql` (generated by build script). ## Development Workflow @@ -49,14 +49,14 @@ The build script concatenates `src/` files in dependency order (header first, fo ```bash make build createdb mytest -psql -d mytest -f pg_morbac.sql +psql -d mytest -f pgmorbac.sql psql -d mytest dropdb mytest ``` ## Release Process -1. Update version in `pg_morbac.control` +1. Update version in `pgmorbac.control` 2. Update `CHANGELOG.md` 3. Run `make build` and `make test` 4. Commit and tag: diff --git a/docs/DOCUMENTATION.md b/docs/DOCUMENTATION.md index 92bce53..b22f283 100644 --- a/docs/DOCUMENTATION.md +++ b/docs/DOCUMENTATION.md @@ -1,4 +1,4 @@ -# pg_morbac Documentation +# pgmorbac Documentation Complete technical documentation for the Multi-OrBAC PostgreSQL extension. @@ -17,7 +17,7 @@ Complete technical documentation for the Multi-OrBAC PostgreSQL extension. ### Design Principles -pg_morbac is built on these principles: +pgmorbac is built on these principles: 1. **Pure PostgreSQL**: No external dependencies 2. **Schema Isolation**: All objects in `morbac` schema @@ -834,7 +834,7 @@ SELECT EXISTS( ### Comparison: Multi-OrBAC vs Traditional RBAC -| Aspect | Traditional RBAC | Multi-OrBAC (pg_morbac) | +| Aspect | Traditional RBAC | Multi-OrBAC (pgmorbac) | |--------|-----------------|-------------------------| | **Multi-tenancy** | Single tenant or complex workarounds | Native multi-organization | | **Prohibition** | No standard support | First-class, always wins | diff --git a/docs/PERFORMANCE.md b/docs/PERFORMANCE.md index 52e3e0a..14d07d8 100644 --- a/docs/PERFORMANCE.md +++ b/docs/PERFORMANCE.md @@ -1,10 +1,10 @@ # Performance Optimization Guide -This guide explains the performance optimizations built into pg_morbac and how to use them effectively. +This guide explains the performance optimizations built into pgmorbac and how to use them effectively. ## Performance Architecture -pg_morbac includes several layers of optimization: +pgmorbac includes several layers of optimization: 1. **Materialized Views**: Precomputed hierarchy transitive closures 2. **Authorization Cache**: Configurable TTL cache for authorization decisions (default: 5 minutes) @@ -414,7 +414,7 @@ $$; ## Conclusion -With these optimizations, pg_morbac can handle: +With these optimizations, pgmorbac can handle: - **>1000 authorization checks/second** (cached) - **>100 authorization checks/second** (uncached) - **Complex hierarchies** (10+ levels deep) diff --git a/pg_morbac.control b/pgmorbac.control similarity index 85% rename from pg_morbac.control rename to pgmorbac.control index 5da4ce7..e2a6f74 100644 --- a/pg_morbac.control +++ b/pgmorbac.control @@ -2,6 +2,6 @@ # Multi-OrBAC access control model for PostgreSQL comment = 'Multi-OrBAC: Organization-Based Access Control with multi-organization support' default_version = '1.0.0' -module_pathname = '$libdir/pg_morbac' +module_pathname = '$libdir/pgmorbac' relocatable = false schema = morbac diff --git a/src/audit.sql b/src/audit.sql index 35e9593..85d9ced 100644 --- a/src/audit.sql +++ b/src/audit.sql @@ -15,7 +15,7 @@ CREATE TABLE morbac.audit_log ( old_data JSONB, new_data JSONB, changed_fields TEXT[], - session_user TEXT DEFAULT SESSION_USER, + session_username TEXT DEFAULT SESSION_USER, client_addr INET DEFAULT INET_CLIENT_ADDR(), application_name TEXT DEFAULT CURRENT_SETTING('application_name', true), metadata JSONB DEFAULT '{}'::jsonb diff --git a/src/config.sql b/src/config.sql index 1c29afc..1aebae7 100644 --- a/src/config.sql +++ b/src/config.sql @@ -1,7 +1,7 @@ -- ============================================================================= -- CONFIGURATION -- ============================================================================= --- Centralized configuration for pg_morbac extension +-- Centralized configuration for pgmorbac extension -- Edit these values to customize behavior CREATE TABLE morbac.config ( diff --git a/src/header.sql b/src/header.sql index a5f25fb..5a61fad 100644 --- a/src/header.sql +++ b/src/header.sql @@ -1,5 +1,5 @@ -- ============================================================================= --- pg_morbac Extension +-- pgmorbac Extension -- ============================================================================= -- Multi-OrBAC: Organization-Based Access Control with Multi-Organization Support -- Based on the CNRS research paper on Multi-OrBAC model @@ -14,4 +14,4 @@ -- ============================================================================= -- Create the morbac schema -CREATE SCHEMA IF NOT EXISTS morbac; +CREATE SCHEMA morbac; diff --git a/tests/00_setup.sql b/tests/00_setup.sql index 673a05c..567c124 100644 --- a/tests/00_setup.sql +++ b/tests/00_setup.sql @@ -6,11 +6,11 @@ -- ============================================================================= -- Clean up any previous test -DROP EXTENSION IF EXISTS pg_morbac CASCADE; +DROP EXTENSION IF EXISTS pgmorbac CASCADE; DROP SCHEMA IF EXISTS morbac CASCADE; -- Install the extension -CREATE EXTENSION pg_morbac; +CREATE EXTENSION pgmorbac; -- Verify schema and tables exist \echo '=== Schema and Tables Created ===' diff --git a/tools/build.sh b/tools/build.sh index a691445..3eaedee 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -6,7 +6,7 @@ set -e # Exit immediately if a command exits with a non-zero status SRC_DIR="${1:-src}" -OUTPUT="${2:-pg_morbac.sql}" +OUTPUT="${2:-pgmorbac.sql}" if [ ! -d "$SRC_DIR" ]; then echo "Error: source directory not found: $SRC_DIR" >&2 diff --git a/tools/docker_install.sh b/tools/docker_install.sh index 94d22b3..dbb6a31 100755 --- a/tools/docker_install.sh +++ b/tools/docker_install.sh @@ -6,7 +6,7 @@ set -e # Exit immediately if a command exits with a non-zero status CONTAINER="${1:-postgres}" -PROJECT_FILENAME="${2:-pg_morbac}" +PROJECT_FILENAME="${2:-pgmorbac}" PROJECT_VERSION="${3}" if [ -z "$PROJECT_VERSION" ]; then @@ -38,15 +38,15 @@ if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then exit 1 fi -docker exec "$CONTAINER" mkdir -p /tmp/pg_morbac -docker cp "$CONTROL_FILE" "$CONTAINER:/tmp/pg_morbac/" -docker cp "$SQL_FILE" "$CONTAINER:/tmp/pg_morbac/" +docker exec "$CONTAINER" mkdir -p /tmp/pgmorbac +docker cp "$CONTROL_FILE" "$CONTAINER:/tmp/pgmorbac/" +docker cp "$SQL_FILE" "$CONTAINER:/tmp/pgmorbac/" docker exec "$CONTAINER" sh -c " EXTDIR=\$(pg_config --sharedir)/extension - cp /tmp/pg_morbac/${CONTROL_FILE} \$EXTDIR/ - cp /tmp/pg_morbac/${SQL_FILE} \$EXTDIR/ - rm -rf /tmp/pg_morbac + cp /tmp/pgmorbac/${CONTROL_FILE} \$EXTDIR/ + cp /tmp/pgmorbac/${SQL_FILE} \$EXTDIR/ + rm -rf /tmp/pgmorbac " echo "Installed ${PROJECT_FILENAME} v${PROJECT_VERSION} to container ${CONTAINER}" diff --git a/tools/docker_test.sh b/tools/docker_test.sh index 19c978f..ddd1cdf 100755 --- a/tools/docker_test.sh +++ b/tools/docker_test.sh @@ -32,13 +32,13 @@ docker exec "$CONTAINER" psql -U "$PG_USER" -c "DROP DATABASE IF EXISTS $DB" -q docker exec "$CONTAINER" psql -U "$PG_USER" -c "CREATE DATABASE $DB" -q echo "Copying test files to container..." -docker exec "$CONTAINER" mkdir -p /tmp/pg_morbac_test/tools -docker cp "$PROJECT_DIR/tests" "$CONTAINER:/tmp/pg_morbac_test/" -docker cp "$SCRIPT_DIR/test.sh" "$CONTAINER:/tmp/pg_morbac_test/tools/" +docker exec "$CONTAINER" mkdir -p /tmp/pgmorbac_test/tools +docker cp "$PROJECT_DIR/tests" "$CONTAINER:/tmp/pgmorbac_test/" +docker cp "$SCRIPT_DIR/test.sh" "$CONTAINER:/tmp/pgmorbac_test/tools/" echo "Running tests..." -docker exec -w /tmp/pg_morbac_test "$CONTAINER" bash tools/test.sh "$DB" "$PG_USER" +docker exec -w /tmp/pgmorbac_test "$CONTAINER" bash tools/test.sh "$DB" "$PG_USER" # Cleanup docker exec "$CONTAINER" psql -U "$PG_USER" -c "DROP DATABASE $DB" -q -docker exec "$CONTAINER" rm -rf /tmp/pg_morbac_test +docker exec "$CONTAINER" rm -rf /tmp/pgmorbac_test diff --git a/tools/docker_uninstall.sh b/tools/docker_uninstall.sh index 5cd63d3..43ccc8d 100755 --- a/tools/docker_uninstall.sh +++ b/tools/docker_uninstall.sh @@ -6,7 +6,7 @@ set -e # Exit immediately if a command exits with a non-zero status CONTAINER="${1:-postgres}" -PROJECT_FILENAME="${2:-pg_morbac}" +PROJECT_FILENAME="${2:-pgmorbac}" if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then echo "Error: Docker container not running: $CONTAINER" >&2 diff --git a/tools/get_version.sh b/tools/get_version.sh index 12b1073..8e844fc 100755 --- a/tools/get_version.sh +++ b/tools/get_version.sh @@ -5,7 +5,7 @@ set -e # Exit immediately if a command exits with a non-zero status -CONTROL_FILE="${1:-pg_morbac.control}" +CONTROL_FILE="${1:-pgmorbac.control}" if [ ! -f "$CONTROL_FILE" ]; then echo "Error: control file not found: $CONTROL_FILE" >&2 diff --git a/tools/install.sh b/tools/install.sh index 83224a5..896c6bf 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -5,7 +5,7 @@ set -e # Exit immediately if a command exits with a non-zero status -PROJECT_FILENAME="${1:-pg_morbac}" +PROJECT_FILENAME="${1:-pgmorbac}" PROJECT_VERSION="${2}" if ! command -v pg_config &> /dev/null; then diff --git a/tools/uninstall.sh b/tools/uninstall.sh index e1b563f..3268f75 100755 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -5,7 +5,7 @@ set -e # Exit immediately if a command exits with a non-zero status -PROJECT_FILENAME="${1:-pg_morbac}" +PROJECT_FILENAME="${1:-pgmorbac}" if ! command -v pg_config &> /dev/null; then echo "Error: pg_config not found" >&2