|
| 1 | +# Python SDK Enterprise Integration |
| 2 | + |
| 3 | +This example demonstrates how to integrate [Auths](https://github.com/auths-dev/auths) verification into a Python web service using FastAPI. It includes commit and artifact verification endpoints, agent identity workflows, and a pytest test suite. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# 1. Install dependencies |
| 9 | +pip install -e ".[dev]" |
| 10 | + |
| 11 | +# 2. Run the verification service |
| 12 | +uvicorn app.main:app --reload |
| 13 | + |
| 14 | +# 3. Test a verification request |
| 15 | +curl -X POST http://localhost:8000/api/v1/verify-commit \ |
| 16 | + -H "Content-Type: application/json" \ |
| 17 | + -d '{"repo_path": ".", "commit_range": "HEAD~1..HEAD"}' |
| 18 | +``` |
| 19 | + |
| 20 | +## What's Included |
| 21 | + |
| 22 | +| Path | Purpose | |
| 23 | +|------|---------| |
| 24 | +| `app/main.py` | FastAPI application with versioned API | |
| 25 | +| `app/routes/verify.py` | `POST /api/v1/verify-commit` and `POST /api/v1/verify-artifact` | |
| 26 | +| `app/routes/health.py` | `GET /health` with SDK version info | |
| 27 | +| `app/services/commit_verifier.py` | Wrapper around `auths.git.verify_commit_range()` | |
| 28 | +| `app/services/artifact_verifier.py` | Wrapper around Auths artifact verification | |
| 29 | +| `app/models.py` | Pydantic request/response models | |
| 30 | +| `agent/deploy_agent.py` | CI agent: sign artifacts during deployment | |
| 31 | +| `agent/audit_agent.py` | Audit agent: verify all commits in repo history | |
| 32 | +| `tests/` | pytest suite with mock fixtures | |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +```mermaid |
| 37 | +graph LR |
| 38 | + A[Client] -->|POST /api/v1/verify-commit| B[FastAPI App] |
| 39 | + A -->|POST /api/v1/verify-artifact| B |
| 40 | + B --> C[CommitVerifier] |
| 41 | + B --> D[ArtifactVerifier] |
| 42 | + C -->|auths.git.verify_commit_range| E[Auths SDK] |
| 43 | + D -->|auths.Auths.verify| E |
| 44 | + E --> F[allowed_signers / identity bundles] |
| 45 | +``` |
| 46 | + |
| 47 | +## Prerequisites |
| 48 | + |
| 49 | +- Python 3.11+ |
| 50 | +- [Auths CLI](https://github.com/auths-dev/auths) (`brew install auths-dev/auths-cli/auths`) |
| 51 | +- Docker (optional, for containerized deployment) |
| 52 | + |
| 53 | +## API Documentation |
| 54 | + |
| 55 | +Start the server and visit `http://localhost:8000/docs` for interactive Swagger documentation. |
| 56 | + |
| 57 | +### Endpoints |
| 58 | + |
| 59 | +| Method | Path | Description | |
| 60 | +|--------|------|-------------| |
| 61 | +| `POST` | `/api/v1/verify-commit` | Verify commit signatures in a git repository | |
| 62 | +| `POST` | `/api/v1/verify-artifact` | Verify an artifact signature | |
| 63 | +| `GET` | `/health` | Service health check | |
| 64 | + |
| 65 | +## Running Tests |
| 66 | + |
| 67 | +```bash |
| 68 | +pytest -v |
| 69 | +``` |
| 70 | + |
| 71 | +## Docker |
| 72 | + |
| 73 | +```bash |
| 74 | +docker compose up --build |
| 75 | +# Service available at http://localhost:8000 |
| 76 | +``` |
| 77 | + |
| 78 | +## Agent Identity |
| 79 | + |
| 80 | +The `agent/` directory demonstrates how to use Auths agent identities in CI/CD pipelines: |
| 81 | + |
| 82 | +- `deploy_agent.py` — Sign artifacts during deployment using an agent identity |
| 83 | +- `audit_agent.py` — Batch-verify all commits in a repository |
| 84 | + |
| 85 | +See the [Auths Agent Documentation](https://github.com/auths-dev/auths/blob/main/docs/guides/identity/agent-identity.md) for more details. |
0 commit comments