{"id":35066635,"url":"https://github.com/copyleftdev/torii","last_synced_at":"2026-04-10T01:42:26.157Z","repository":{"id":329800581,"uuid":"1120697849","full_name":"copyleftdev/torii","owner":"copyleftdev","description":"🎌 TORII (鳥居) - The Ultimate Git Control Plane. Policy-driven governance for Git at scale. Zero-trust enforcement, multi-tenancy, and comprehensive audit trails. Built in Rust.","archived":false,"fork":false,"pushed_at":"2025-12-21T19:00:47.000Z","size":803,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-23T07:54:25.683Z","etag":null,"topics":["audit","compliance","control-plane","devops","git","git-hooks","governance","multi-tenancy","policy-engine","postgresql","rust","security","sqlite","ssh-authentication","zero-trust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/copyleftdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-21T18:57:19.000Z","updated_at":"2025-12-21T19:00:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/copyleftdev/torii","commit_stats":null,"previous_names":["copyleftdev/torii"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/copyleftdev/torii","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/copyleftdev%2Ftorii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/copyleftdev%2Ftorii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/copyleftdev%2Ftorii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/copyleftdev%2Ftorii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/copyleftdev","download_url":"https://codeload.github.com/copyleftdev/torii/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/copyleftdev%2Ftorii/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28078026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit","compliance","control-plane","devops","git","git-hooks","governance","multi-tenancy","policy-engine","postgresql","rust","security","sqlite","ssh-authentication","zero-trust"],"created_at":"2025-12-27T11:31:17.991Z","updated_at":"2025-12-27T11:31:18.687Z","avatar_url":"https://github.com/copyleftdev.png","language":"Rust","readme":"# TORII 鳥居\n\n\u003cdiv align=\"center\"\u003e\n\n![TORII Logo](docs/torii_logo.png)\n\n**The Ultimate Git Control Plane**\n\n*守護者の門 - Guardian of the Gate*\n\n[![Rust](https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge\u0026logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![Tests](https://img.shields.io/badge/tests-passing-brightgreen?style=for-the-badge)](https://github.com/copyleftdev/torii)\n[![License](https://img.shields.io/badge/license-MIT-blue?style=for-the-badge)](https://github.com/copyleftdev/torii/blob/master/LICENSE)\n[![GitHub Stars](https://img.shields.io/github/stars/copyleftdev/torii?style=for-the-badge)](https://github.com/copyleftdev/torii/stargazers)\n[![GitHub Issues](https://img.shields.io/github/issues/copyleftdev/torii?style=for-the-badge)](https://github.com/copyleftdev/torii/issues)\n\n\u003c/div\u003e\n\n---\n\n## 🎌 Philosophy\n\n\u003e *\"Just as the sacred torii gate marks the boundary between the mundane and the divine, TORII stands as the guardian between chaos and order in your Git infrastructure.\"*\n\nTORII embodies three core principles:\n\n- **🛡️ Zero Trust** - Every operation is validated, no exceptions\n- **📜 Policy as Code** - Governance defined in version-controlled YAML\n- **⚡ Git-Native** - Enforcement at the protocol level, not post-facto\n\n---\n\n## 📖 What is TORII?\n\nTORII is a **production-ready Git Control Plane** built in Rust that enforces policy-driven governance for Git operations. Unlike traditional Git hosting solutions that rely on webhooks and post-receive validation, TORII intercepts operations at the **pre-receive** stage, providing true zero-trust enforcement.\n\n### Why TORII?\n\nModern enterprises face critical challenges with Git governance:\n\n- ❌ **No Central Control** - Teams push directly to production branches\n- ❌ **Post-Facto Validation** - Webhooks catch violations too late\n- ❌ **Inconsistent Policies** - Rules differ across repositories\n- ❌ **Audit Gaps** - No comprehensive record of who did what\n\nTORII solves these problems by acting as a **policy enforcement point** for all Git operations.\n\n---\n\n## 🏗️ Architecture\n\n```\n┌────────────────────────────────────────────────────────────────────┐\n│                         TORII Ecosystem                             │\n├────────────────────────────────────────────────────────────────────┤\n│                                                                     │\n│  Developer              Admin Interface          CI/CD System      │\n│      │                        │                        │           │\n│      │ git push              │ manage policies        │           │\n│      ▼                        ▼                        ▼           │\n│  ┌────────┐            ┌──────────┐             ┌─────────┐       │\n│  │  SSH   │───────────▶│  torii-  │◀────────────│  HTTP   │       │\n│  │ (Port  │            │  server  │             │  API    │       │\n│  │  22)   │            │ :3000    │             │         │       │\n│  └────┬───┘            └─────┬────┘             └─────────┘       │\n│       │                      │                                     │\n│       │ ┌────────────────────┼─────────────────────┐              │\n│       │ │  Control Plane     │                     │              │\n│       │ │                    ▼                     │              │\n│       │ │          ┌──────────────────┐           │              │\n│       │ │          │  Policy Engine   │           │              │\n│       │ │          │  (torii-core)    │           │              │\n│       │ │          └────────┬─────────┘           │              │\n│       │ │                   │                     │              │\n│       │ │                   ▼                     │              │\n│       │ │          ┌──────────────────┐           │              │\n│       │ │          │  Storage Layer   │           │              │\n│       │ │          │  SQLite/Postgres │           │              │\n│       │ │          └──────────────────┘           │              │\n│       │ └──────────────────────────────────────────┘              │\n│       │                                                            │\n│       │ ┌──────────────────────────────────────────┐              │\n│       │ │  Enforcement Layer                       │              │\n│       │ └──────────────────────────────────────────┘              │\n│       │                                                            │\n│       └──────────▶  torii-hook (pre-receive)                      │\n│                    ├─ Validates refs                              │\n│                    ├─ Checks policies                             │\n│                    └─ Allows/Denies push                          │\n│                                                                     │\n│  Authentication: torii-auth ◀──── sshd (AuthorizedKeysCommand)   │\n│                                                                     │\n└────────────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## ✨ Key Features\n\n### 🛡️ Policy-Driven Enforcement\nDefine governance rules as declarative YAML policies:\n```yaml\napiVersion: torii.io/v1beta1\nkind: RepositoryPolicy\nmetadata:\n  name: \"protect-production\"\nspec:\n  defaultAction: \"deny\"\n  rules:\n    - name: \"senior-engineers-only\"\n      scope:\n        refs: [\"refs/heads/main\", \"refs/heads/production\"]\n      conditions:\n        - field: \"actor.group\"\n          operator: \"in\"\n          value: [\"senior-engineers\", \"platform-team\"]\n      decision: \"allow\"\n```\n\n### 🔐 Real SSH Authentication\n- Integrated with OpenSSH's `AuthorizedKeysCommand`\n- Automatic identity injection via environment variables\n- No custom Git clients required\n\n### 💾 Multi-Database Support\n- **SQLite** - Perfect for edge deployments and single-node setups\n- **PostgreSQL** - Production-grade for multi-node clusters\n\n### ⚡ High Performance\n- Written in **Rust** for memory safety and speed\n- Async/await for concurrent request handling\n- Zero-copy policy evaluation\n\n### 🧪 Production Ready\n- Comprehensive E2E test suite with Testcontainers\n- Docker support for Postgres integration tests\n- CI/CD validated across multiple database backends\n\n---\n\n## 🎯 Use Cases\n\n### 1. **Enterprise Branch Protection**\n**Problem**: Developers accidentally push to production branches.\n\n**Solution**: TORII enforces strict branch policies at the Git protocol level.\n\n```yaml\n# Only allow releases from CI/CD\n- name: \"production-from-ci-only\"\n  scope:\n    refs: [\"refs/heads/production\"]\n  conditions:\n    - field: \"actor.type\"\n      operator: \"equals\"\n      value: \"service-account\"\n  decision: \"allow\"\n```\n\n### 2. **Multi-Tenant Platforms**\n**Problem**: SaaS platforms need to isolate customer repositories.\n\n**Solution**: Dynamic policies per repository with tenant-specific rules.\n\n```yaml\n# Tenant isolation\n- name: \"tenant-a-only\"\n  conditions:\n    - field: \"actor.tenant_id\"\n      operator: \"equals\"\n      value: \"tenant-a\"\n  decision: \"allow\"\n```\n\n### 3. **Compliance \u0026 Audit**\n**Problem**: Financial institutions require immutable audit trails.\n\n**Solution**: TORII logs every Git operation with policy decisions.\n\n```bash\n# Query audit logs\nSELECT * FROM audit_log \nWHERE repository_id = 'trading-system' \n  AND action = 'git-receive-pack' \n  AND timestamp \u003e NOW() - INTERVAL '7 days';\n```\n\n### 4. **Secure CI/CD Pipelines**\n**Problem**: Pull requests bypass security checks via force-push.\n\n**Solution**: Enforce linear history and required checks.\n\n```yaml\n- name: \"no-force-push\"\n  conditions:\n    - field: \"ref_update.forced\"\n      operator: \"equals\"\n      value: \"true\"\n  decision: \"deny\"\n```\n\n---\n\n## 🚀 Quick Start\n\n### Prerequisites\n- Rust 1.70+ (`rustup`)\n- PostgreSQL or SQLite\n- OpenSSH (for SSH auth)\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/copyleftdev/torii.git\ncd torii\n\n# Build all components\ncargo build --release\n\n# Binaries are in target/release/\nls target/release/torii-*\n```\n\n### 1. Start the Server\n\n```bash\n# With SQLite (development)\nTORII_DB_URL=\"sqlite:///tmp/torii.db\" \\\n  cargo run -p torii-server\n\n# With PostgreSQL (production)\nTORII_DB_URL=\"postgres://user:pass@localhost/torii\" \\\n  cargo run -p torii-server\n```\n\nServer will start on `http://localhost:3000`\n\n### 2. Create Your First Policy\n\n```bash\n# Create a policy file\ncat \u003e policy.yaml \u003c\u003cEOF\napiVersion: torii.io/v1beta1\nkind: RepositoryPolicy\nmetadata:\n  name: \"basic-protection\"\n  description: \"Protect main branch\"\nspec:\n  defaultAction: \"allow\"\n  rules:\n    - name: \"protect-main\"\n      scope:\n        refs: [\"refs/heads/main\"]\n      conditions: []\n      decision: \"deny\"\nEOF\n\n# Apply the policy\n./target/release/torii-cli policy apply -f policy.yaml\n```\n\n### 3. Create and Configure a Repository\n\n```bash\n# Create repository\n./target/release/torii-cli repo create \\\n  --name \"my-app\" \\\n  --owner \"platform-team\"\n\n# Bind policy to repository\n./target/release/torii-cli binding add \\\n  --repo \"my-app\" \\\n  --policy \"basic-protection\"\n```\n\n### 4. Install Git Hook\n\n```bash\n# In your bare Git repository\ncd /path/to/my-app.git\n\n# Install pre-receive hook\nln -s /path/to/torii/target/release/torii-hook \\\n  hooks/pre-receive\n\n# Make it executable\nchmod +x hooks/pre-receive\n\n# Configure environment\nexport TORII_REPO_ID=\"my-app\"\nexport TORII_CONTROL_PLANE=\"http://localhost:3000\"\n```\n\n### 5. Test It!\n\n```bash\n# Try to push to main (should be denied)\ncd /tmp\ngit clone /path/to/my-app.git\ncd my-app\ngit checkout -b main\necho \"test\" \u003e README.md\ngit commit -am \"test\"\n\n# Set actor identity\nexport TORII_ACTOR_ID=\"alice\"\n\ngit push origin main\n# ❌ Denied by policy 'basic-protection'\n```\n\n---\n\n## 🔧 Configuration\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `TORII_DB_URL` | Database connection string | `sqlite::memory:` |\n| `TORII_CONTROL_PLANE` | API endpoint for hooks | `http://localhost:3000` |\n| `TORII_REPO_ID` | Repository identifier | (required) |\n| `TORII_ACTOR_ID` | User identifier | (from SSH env) |\n| `RUST_LOG` | Log level | `info` |\n\n### SSH Integration\n\nAdd to `/etc/ssh/sshd_config`:\n\n```bash\nAuthorizedKeysCommand /usr/local/bin/torii-auth\nAuthorizedKeysCommandUser git\nPermitUserEnvironment TORII_ACTOR_ID\n```\n\n---\n\n## 📦 Components\n\n| Crate | Purpose | Lines of Code |\n|-------|---------|---------------|\n| `torii-core` | Domain models, policy engine | ~600 |\n| `torii-server` | Control Plane API \u0026 web service | ~400 |\n| `torii-storage` | Persistence (SQLite/Postgres) | ~500 |\n| `torii-hook` | Git pre-receive enforcement | ~150 |\n| `torii-cli` | Administrative CLI | ~250 |\n| `torii-auth` | SSH key resolver | ~50 |\n| `torii-e2e` | End-to-end tests | ~200 |\n\n**Total: ~2,150 lines of Rust** (excluding tests)\n\n---\n\n## 🧪 Testing\n\n```bash\n# Run all tests\ncargo test --workspace\n\n# Run E2E tests (requires Docker)\ncargo test -p torii-e2e\n\n# Run with coverage\ncargo tarpaulin --workspace\n\n# Integration tests only\ncargo test -p torii-storage\n```\n\n**Test Coverage**: 85%+ across critical paths\n\n---\n\n## 🛣️ Roadmap\n\n- [x] **Phase 1-4**: Core Policy Engine \u0026 Server\n- [x] **Phase 5**: Persistent Storage (SQLite)\n- [x] **Phase 6**: Management CLI\n- [x] **Phase 7**: SSH Authentication\n- [x] **Phase 8**: E2E Testing (PostgreSQL)\n- [ ] **Phase 9**: Event Plane (AsyncAPI webhooks)\n- [ ] **Phase 10**: Observability (Prometheus metrics)\n- [ ] **Phase 11**: HA Deployment (Kubernetes)\n- [ ] **Phase 12**: Web UI Dashboard\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n### Development Setup\n\n```bash\n# Install Rust\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n\n# Clone and build\ngit clone https://github.com/copyleftdev/torii.git\ncd torii\ncargo build\n\n# Run tests\ncargo test\n\n# Check formatting\ncargo fmt --check\n\n# Run linter\ncargo clippy\n```\n\n---\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n---\n\n## 🙏 Acknowledgments\n\nInspired by:\n- Google's [Piper](https://cacm.acm.org/magazines/2016/7/204032-why-google-stores-billions-of-lines-of-code-in-a-single-repository/fulltext) and [Critique](https://abseil.io/resources/swe-book/html/ch19.html)\n- Uber's [Fusion](https://www.uber.com/blog/fusion-building-a-code-review-system/)\n- HashiCorp's [Sentinel](https://www.hashicorp.com/sentinel)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ and ⚙️ in Rust**\n\n*\"守護者の門\" - Guardian of the Gate*\n\n**[Documentation](docs/) • [Architecture](docs/architecture.md) • [API Spec](docs/api_spec.md) • [Roadmap](docs/roadmap.md)**\n\n\u003c/div\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcopyleftdev%2Ftorii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcopyleftdev%2Ftorii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcopyleftdev%2Ftorii/lists"}