refacto: morbac_pg -> pg_morbac

This commit is contained in:
2026-02-20 10:36:19 +01:00
parent 5b4095677e
commit 2d5f4ca669
18 changed files with 73 additions and 73 deletions
Vendored
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -1,6 +1,6 @@
# Generated files # Generated files
morbac_pg.sql pg_morbac.sql
morbac_pg--*.sql pg_morbac--*.sql
# Test database dumps # Test database dumps
*.dump *.dump
+1 -1
View File
@@ -41,4 +41,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Complete documentation - Complete documentation
- Build and installation automation (Makefile, install.sh) - Build and installation automation (Makefile, install.sh)
[1.0.0]: https://github.com/yourusername/morbac_pg/releases/tag/v1.0.0 [1.0.0]: https://github.com/yourusername/pg_morbac/releases/tag/v1.0.0
+4 -4
View File
@@ -1,6 +1,6 @@
# Contributing to morbac_pg # Contributing to pg_morbac
Thank you for your interest in contributing to morbac_pg! Thank you for your interest in contributing to pg_morbac!
## How to Contribute ## How to Contribute
@@ -62,8 +62,8 @@ brew install postgresql # macOS
# or use your package manager # or use your package manager
# Clone your fork # Clone your fork
git clone https://github.com/your-username/morbac_pg.git git clone https://github.com/your-username/pg_morbac.git
cd morbac_pg cd pg_morbac
# Install the extension # Install the extension
make install make install
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2026 morbac_pg contributors Copyright (c) 2026 pg_morbac contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+7 -7
View File
@@ -1,7 +1,7 @@
# Makefile for morbac_pg PostgreSQL Extension # Makefile for pg_morbac PostgreSQL Extension
# Multi-OrBAC: Organization-Based Access Control # Multi-OrBAC: Organization-Based Access Control
EXTENSION = morbac_pg EXTENSION = pg_morbac
# Read version from control file # Read version from control file
EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed "s/default_version = '\(.*\)'/\1/") EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed "s/default_version = '\(.*\)'/\1/")
@@ -35,7 +35,7 @@ build:
# Install extension in PostgreSQL (creates versioned file if needed) # Install extension in PostgreSQL (creates versioned file if needed)
.PHONY: install .PHONY: install
install: build install: build
@echo "Installing morbac_pg extension..." @echo "Installing pg_morbac extension..."
$(MAKE) -f Makefile install $(MAKE) -f Makefile install
# Run tests with development file in temporary database # Run tests with development file in temporary database
@@ -51,18 +51,18 @@ test: build
# Uninstall extension # Uninstall extension
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
@echo "Uninstalling morbac_pg extension..." @echo "Uninstalling pg_morbac extension..."
$(MAKE) -f Makefile uninstall $(MAKE) -f Makefile uninstall
# Show help # Show help
.PHONY: help .PHONY: help
help: help:
@echo "morbac_pg Makefile targets:" @echo "pg_morbac Makefile targets:"
@echo "" @echo ""
@echo "Development:" @echo "Development:"
@echo " Edit source files in src/ directory" @echo " Edit source files in src/ directory"
@echo "" @echo ""
@echo " make build - Build versioned morbac_pg--X.Y.Z.sql from src/" @echo " make build - Build versioned pg_morbac--X.Y.Z.sql from src/"
@echo " make test - Build and run test suite" @echo " make test - Build and run test suite"
@echo " make install - Build and install extension to PostgreSQL" @echo " make install - Build and install extension to PostgreSQL"
@echo " make uninstall - Uninstall extension from PostgreSQL" @echo " make uninstall - Uninstall extension from PostgreSQL"
@@ -71,7 +71,7 @@ help:
@echo "Workflow:" @echo "Workflow:"
@echo " 1. Edit source files in src/" @echo " 1. Edit source files in src/"
@echo " 2. make test (build and test changes)" @echo " 2. make test (build and test changes)"
@echo " 3. Update version in morbac_pg.control" @echo " 3. Update version in pg_morbac.control"
@echo " 4. make build (builds versioned SQL)" @echo " 4. make build (builds versioned SQL)"
@echo " 5. git tag vX.Y.Z && git push --tags" @echo " 5. git tag vX.Y.Z && git push --tags"
@echo "" @echo ""
+17 -17
View File
@@ -1,4 +1,4 @@
# morbac_pg # pg_morbac
**Multi-Organization Based Access Control for PostgreSQL** **Multi-Organization Based Access Control for PostgreSQL**
@@ -34,15 +34,15 @@ A PostgreSQL extension implementing the Multi-OrBAC access control model - enabl
```bash ```bash
# Clone repository # Clone repository
git clone https://github.com/yourusername/morbac_pg.git git clone https://github.com/yourusername/pg_morbac.git
cd morbac_pg cd pg_morbac
# Build and install extension # Build and install extension
make build # Build versioned file from src/ make build # Build versioned file from src/
sudo make install # Install to PostgreSQL sudo make install # Install to PostgreSQL
# Enable in your database # Enable in your database
psql -d mydb -c "CREATE EXTENSION morbac_pg;" psql -d mydb -c "CREATE EXTENSION pg_morbac;"
``` ```
### Alternative: Using install script ### Alternative: Using install script
@@ -59,14 +59,14 @@ sudo ./tools/install.sh
```bash ```bash
# Build versioned file from source # Build versioned file from source
make build # Concatenates src/ files into morbac_pg--1.0.0.sql make build # Concatenates src/ files into pg_morbac--1.0.0.sql
# Copy files to PostgreSQL extension directory # Copy files to PostgreSQL extension directory
sudo cp morbac_pg.control $(pg_config --sharedir)/extension/ sudo cp pg_morbac.control $(pg_config --sharedir)/extension/
sudo cp morbac_pg--1.0.0.sql $(pg_config --sharedir)/extension/ sudo cp pg_morbac--1.0.0.sql $(pg_config --sharedir)/extension/
# Enable in PostgreSQL # Enable in PostgreSQL
psql -d mydb -c "CREATE EXTENSION morbac_pg;" psql -d mydb -c "CREATE EXTENSION pg_morbac;"
``` ```
## Quick Start ## Quick Start
@@ -170,13 +170,13 @@ LIMIT 10;
# Development workflow # Development workflow
# 1. Edit source files in src/ directory # 1. Edit source files in src/ directory
# 2. Build and test # 2. Build and test
make build # Build versioned morbac_pg--X.Y.Z.sql from src/ make build # Build versioned pg_morbac--X.Y.Z.sql from src/
make test # Build and run test suite make test # Build and run test suite
# Manual testing # Manual testing
make build make build
createdb morbac_test createdb morbac_test
psql -d morbac_test -f morbac_pg.sql psql -d morbac_test -f pg_morbac.sql
# ... test manually ... # ... test manually ...
dropdb morbac_test dropdb morbac_test
``` ```
@@ -219,8 +219,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines. See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.
```bash ```bash
git clone https://github.com/yourusername/morbac_pg.git git clone https://github.com/yourusername/pg_morbac.git
cd morbac_pg cd pg_morbac
# Edit source files in src/ # Edit source files in src/
vim src/authorization.sql vim src/authorization.sql
@@ -229,9 +229,9 @@ vim src/authorization.sql
make test # Run test suite make test # Run test suite
# When ready to release # When ready to release
# 1. Update version in morbac_pg.control # 1. Update version in pg_morbac.control
# 2. Build versioned file # 2. Build versioned file
make build # Creates morbac_pg--X.Y.Z.sql make build # Creates pg_morbac--X.Y.Z.sql
# 3. Tag in git # 3. Tag in git
git tag v1.0.1 git tag v1.0.1
git push --tags git push --tags
@@ -240,13 +240,13 @@ git push --tags
## Support ## Support
- Read the [documentation](docs/DOCUMENTATION.md) - Read the [documentation](docs/DOCUMENTATION.md)
- Report bugs via [GitHub Issues](https://github.com/yourusername/morbac_pg/issues) - Report bugs via [GitHub Issues](https://github.com/yourusername/pg_morbac/issues)
- Ask questions in [Discussions](https://github.com/yourusername/morbac_pg/discussions) - Ask questions in [Discussions](https://github.com/yourusername/pg_morbac/discussions)
- Security issues: see [SECURITY.md](docs/SECURITY.md) - Security issues: see [SECURITY.md](docs/SECURITY.md)
## Comparison with Traditional RBAC ## Comparison with Traditional RBAC
| Feature | Traditional RBAC | morbac_pg | | Feature | Traditional RBAC | pg_morbac |
|---------|-----------------|-----------| |---------|-----------------|-----------|
| Multi-tenancy | No | Yes | | Multi-tenancy | No | Yes |
| Prohibitions | No | Yes | | Prohibitions | No | Yes |
+6 -6
View File
@@ -8,7 +8,7 @@
## Security Model ## Security Model
morbac_pg implements the Multi-OrBAC access control model with the following security principles: pg_morbac implements the Multi-OrBAC access control model with the following security principles:
### Default Deny ### Default Deny
- No permission = access denied - No permission = access denied
@@ -36,7 +36,7 @@ morbac_pg implements the Multi-OrBAC access control model with the following sec
## Reporting a Vulnerability ## Reporting a Vulnerability
If you discover a security vulnerability in morbac_pg, please report it responsibly: If you discover a security vulnerability in pg_morbac, please report it responsibly:
### DO NOT ### DO NOT
- Open a public GitHub issue for security vulnerabilities - Open a public GitHub issue for security vulnerabilities
@@ -67,7 +67,7 @@ If you discover a security vulnerability in morbac_pg, please report it responsi
## Security Best Practices ## Security Best Practices
When using morbac_pg: When using pg_morbac:
### 1. Protect Authorization Headers ### 1. Protect Authorization Headers
```sql ```sql
@@ -80,7 +80,7 @@ When using morbac_pg:
-- Always enable RLS on application tables -- Always enable RLS on application tables
ALTER TABLE app.documents ENABLE ROW LEVEL SECURITY; ALTER TABLE app.documents ENABLE ROW LEVEL SECURITY;
-- Use morbac_pg for authorization -- Use pg_morbac for authorization
CREATE POLICY doc_access ON app.documents CREATE POLICY doc_access ON app.documents
FOR ALL USING (morbac.rls_check('read', 'documents')); FOR ALL USING (morbac.rls_check('read', 'documents'));
``` ```
@@ -120,7 +120,7 @@ LIMIT 100;
### 5. Regular Updates ### 5. Regular Updates
- Keep PostgreSQL updated - Keep PostgreSQL updated
- Monitor for morbac_pg security advisories - Monitor for pg_morbac security advisories
- Review and test policies regularly - Review and test policies regularly
### 6. Principle of Least Privilege ### 6. Principle of Least Privilege
@@ -138,4 +138,4 @@ LIMIT 100;
## Acknowledgments ## Acknowledgments
We appreciate responsible disclosure and will acknowledge security researchers who help improve morbac_pg security. We appreciate responsible disclosure and will acknowledge security researchers who help improve pg_morbac security.
+9 -9
View File
@@ -4,34 +4,34 @@
This extension uses a single-source version approach: This extension uses a single-source version approach:
- **Version source of truth**: `morbac_pg.control` (the `default_version` field) - **Version source of truth**: `pg_morbac.control` (the `default_version` field)
- **Development file**: `morbac_pg.sql` (unversioned, for daily work) - **Development file**: `pg_morbac.sql` (unversioned, for daily work)
- **Release files**: `morbac_pg--X.Y.Z.sql` (generated, git-ignored) - **Release files**: `pg_morbac--X.Y.Z.sql` (generated, git-ignored)
## Daily Development ## Daily Development
1. **Edit**: Work on `morbac_pg.sql` (no version numbers in the file) 1. **Edit**: Work on `pg_morbac.sql` (no version numbers in the file)
2. **Test**: Run `make test` to test changes in a temporary database 2. **Test**: Run `make test` to test changes in a temporary database
3. **Commit**: Commit `morbac_pg.sql` to git regularly 3. **Commit**: Commit `pg_morbac.sql` to git regularly
## Release Process ## Release Process
When ready to release a new version: When ready to release a new version:
1. **Update version**: Edit `morbac_pg.control` and change `default_version` 1. **Update version**: Edit `pg_morbac.control` and change `default_version`
``` ```
default_version = '1.1.0' default_version = '1.1.0'
``` ```
2. **Create release**: Run `make release` 2. **Create release**: Run `make release`
- Reads version from `.control` file - Reads version from `.control` file
- Copies `morbac_pg.sql` → `morbac_pg--X.Y.Z.sql` - Copies `pg_morbac.sql` → `pg_morbac--X.Y.Z.sql`
3. **Test**: Run `make test` with the versioned file 3. **Test**: Run `make test` with the versioned file
4. **Tag in git**: 4. **Tag in git**:
```bash ```bash
git add morbac_pg.control morbac_pg--X.Y.Z.sql git add pg_morbac.control pg_morbac--X.Y.Z.sql
git commit -m "Release vX.Y.Z" git commit -m "Release vX.Y.Z"
git tag vX.Y.Z git tag vX.Y.Z
git push origin main --tags git push origin main --tags
@@ -42,7 +42,7 @@ When ready to release a new version:
For version migrations, create upgrade scripts: For version migrations, create upgrade scripts:
```bash ```bash
# Example: upgrade from 1.0.0 to 1.1.0 # Example: upgrade from 1.0.0 to 1.1.0
touch morbac_pg--1.0.0--1.1.0.sql touch pg_morbac--1.0.0--1.1.0.sql
``` ```
These contain only the ALTER/ADD statements needed for the upgrade. These contain only the ALTER/ADD statements needed for the upgrade.
+3 -3
View File
@@ -1,4 +1,4 @@
# morbac_pg Documentation # pg_morbac Documentation
Complete technical documentation for the Multi-OrBAC PostgreSQL extension. Complete technical documentation for the Multi-OrBAC PostgreSQL extension.
@@ -17,7 +17,7 @@ Complete technical documentation for the Multi-OrBAC PostgreSQL extension.
### Design Principles ### Design Principles
morbac_pg is built on these principles: pg_morbac is built on these principles:
1. **Pure PostgreSQL** - No external dependencies (except pgcrypto) 1. **Pure PostgreSQL** - No external dependencies (except pgcrypto)
2. **Schema Isolation** - All objects in `morbac` schema 2. **Schema Isolation** - All objects in `morbac` schema
@@ -889,7 +889,7 @@ CREATE TABLE app.delegation_audit (
### Comparison: Multi-OrBAC vs Traditional RBAC ### Comparison: Multi-OrBAC vs Traditional RBAC
| Aspect | Traditional RBAC | Multi-OrBAC (morbac_pg) | | Aspect | Traditional RBAC | Multi-OrBAC (pg_morbac) |
|--------|-----------------|-------------------------| |--------|-----------------|-------------------------|
| **Multi-tenancy** | Single tenant or complex workarounds | Native multi-organization | | **Multi-tenancy** | Single tenant or complex workarounds | Native multi-organization |
| **Prohibition** | No standard support | First-class, always wins | | **Prohibition** | No standard support | First-class, always wins |
+3 -3
View File
@@ -1,10 +1,10 @@
# Performance Optimization Guide # Performance Optimization Guide
This guide explains the performance optimizations built into morbac_pg and how to use them effectively. This guide explains the performance optimizations built into pg_morbac and how to use them effectively.
## Performance Architecture ## Performance Architecture
morbac_pg includes several layers of optimization: pg_morbac includes several layers of optimization:
1. **Materialized Views** - Precomputed hierarchy transitive closures 1. **Materialized Views** - Precomputed hierarchy transitive closures
2. **Authorization Cache** - Configurable TTL cache for authorization decisions (default: 5 minutes) 2. **Authorization Cache** - Configurable TTL cache for authorization decisions (default: 5 minutes)
@@ -414,7 +414,7 @@ $$;
## Conclusion ## Conclusion
With these optimizations, morbac_pg can handle: With these optimizations, pg_morbac can handle:
- **>1000 authorization checks/second** (cached) - **>1000 authorization checks/second** (cached)
- **>100 authorization checks/second** (uncached) - **>100 authorization checks/second** (uncached)
- **Complex hierarchies** (10+ levels deep) - **Complex hierarchies** (10+ levels deep)
+2 -2
View File
@@ -1,8 +1,8 @@
# morbac_pg extension # pg_morbac extension
# Multi-OrBAC access control model for PostgreSQL # Multi-OrBAC access control model for PostgreSQL
comment = 'Multi-OrBAC: Organization-Based Access Control with multi-organization support' comment = 'Multi-OrBAC: Organization-Based Access Control with multi-organization support'
default_version = '1.0.0' default_version = '1.0.0'
module_pathname = '$libdir/morbac_pg' module_pathname = '$libdir/pg_morbac'
relocatable = false relocatable = false
schema = morbac schema = morbac
requires = 'pgcrypto' requires = 'pgcrypto'
+1 -1
View File
@@ -1,7 +1,7 @@
-- ============================================================================= -- =============================================================================
-- CONFIGURATION -- CONFIGURATION
-- ============================================================================= -- =============================================================================
-- Centralized configuration for morbac_pg extension -- Centralized configuration for pg_morbac extension
-- Edit these values to customize behavior -- Edit these values to customize behavior
CREATE TABLE morbac.config ( CREATE TABLE morbac.config (
+1 -1
View File
@@ -1,5 +1,5 @@
-- ============================================================================= -- =============================================================================
-- morbac_pg Extension -- pg_morbac Extension
-- ============================================================================= -- =============================================================================
-- Multi-OrBAC: Organization-Based Access Control with Multi-Organization Support -- Multi-OrBAC: Organization-Based Access Control with Multi-Organization Support
-- Based on the CNRS research paper on Multi-OrBAC model -- Based on the CNRS research paper on Multi-OrBAC model
+2 -2
View File
@@ -6,11 +6,11 @@
-- ============================================================================= -- =============================================================================
-- Clean up any previous test -- Clean up any previous test
DROP EXTENSION IF EXISTS morbac_pg CASCADE; DROP EXTENSION IF EXISTS pg_morbac CASCADE;
DROP SCHEMA IF EXISTS morbac CASCADE; DROP SCHEMA IF EXISTS morbac CASCADE;
-- Install the extension -- Install the extension
CREATE EXTENSION morbac_pg; CREATE EXTENSION pg_morbac;
-- Verify schema and tables exist -- Verify schema and tables exist
\echo '=== Schema and Tables Created ===' \echo '=== Schema and Tables Created ==='
+4 -4
View File
@@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
# ============================================================================= # =============================================================================
# Build Script for morbac_pg Extension # Build Script for pg_morbac Extension
# ============================================================================= # =============================================================================
# Concatenates SQL source files in src/ into a single morbac_pg.sql file # Concatenates SQL source files in src/ into a single pg_morbac.sql file
# Order: header first, then specific order for dependencies, footer last # Order: header first, then specific order for dependencies, footer last
# ============================================================================= # =============================================================================
set -e set -e
SRC_DIR="src" SRC_DIR="src"
OUTPUT="morbac_pg.sql" OUTPUT="pg_morbac.sql"
echo "Building morbac_pg.sql from source files..." echo "Building pg_morbac.sql from source files..."
# Check if src directory exists # Check if src directory exists
if [ ! -d "$SRC_DIR" ]; then if [ ! -d "$SRC_DIR" ]; then
+7 -7
View File
@@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
# Installation script for morbac_pg extension # Installation script for pg_morbac extension
set -e set -e
echo "==================================" echo "=================================="
echo "morbac_pg Extension Installer" echo "pg_morbac Extension Installer"
echo "==================================" echo "=================================="
echo "" echo ""
@@ -40,10 +40,10 @@ if [ ! -d "$EXTDIR" ]; then
fi fi
# Detect version from control file # Detect version from control file
CONTROL_FILE="morbac_pg.control" CONTROL_FILE="pg_morbac.control"
if [ ! -f "$CONTROL_FILE" ]; then if [ ! -f "$CONTROL_FILE" ]; then
echo "Error: $CONTROL_FILE not found" echo "Error: $CONTROL_FILE not found"
echo "Please run this script from the morbac_pg directory" echo "Please run this script from the pg_morbac directory"
exit 1 exit 1
fi fi
@@ -53,7 +53,7 @@ if [ -z "$VERSION" ]; then
exit 1 exit 1
fi fi
SQL_FILE="morbac_pg--${VERSION}.sql" SQL_FILE="pg_morbac--${VERSION}.sql"
echo "Detected version: $VERSION" echo "Detected version: $VERSION"
echo "" echo ""
@@ -67,7 +67,7 @@ fi
# Copy extension files # Copy extension files
echo "Installing extension files..." echo "Installing extension files..."
cp -v morbac_pg.control "$EXTDIR/" cp -v pg_morbac.control "$EXTDIR/"
cp -v "$SQL_FILE" "$EXTDIR/" cp -v "$SQL_FILE" "$EXTDIR/"
echo "" echo ""
@@ -77,7 +77,7 @@ echo "=================================="
echo "" echo ""
echo "To use the extension in your database:" echo "To use the extension in your database:"
echo "" echo ""
echo " psql -d your_database -c 'CREATE EXTENSION morbac_pg;'" echo " psql -d your_database -c 'CREATE EXTENSION pg_morbac;'"
echo "" echo ""
echo "To run tests:" echo "To run tests:"
echo "" echo ""
+3 -3
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# ============================================================================= # =============================================================================
# Test Runner for morbac_pg Extension # Test Runner for pg_morbac Extension
# ============================================================================= # =============================================================================
# Runs all tests in order, loading setup data and executing each test file. # Runs all tests in order, loading setup data and executing each test file.
# Usage: ./tools/test.sh [database_name] # Usage: ./tools/test.sh [database_name]
@@ -15,14 +15,14 @@ PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
TEST_DIR="$PROJECT_DIR/tests" TEST_DIR="$PROJECT_DIR/tests"
echo "======================================" echo "======================================"
echo "morbac_pg Extension Test Suite" echo "pg_morbac Extension Test Suite"
echo "======================================" echo "======================================"
echo "Database: $DB" echo "Database: $DB"
echo "" echo ""
# Install extension # Install extension
echo "=== Installing Extension ===" echo "=== Installing Extension ==="
psql -d "$DB" -f "$PROJECT_DIR/morbac_pg.sql" psql -d "$DB" -f "$PROJECT_DIR/pg_morbac.sql"
# Load common setup # Load common setup
echo "" echo ""