Skip to content

Commit d6411e1

Browse files
committed
feat: initial Python SDK enterprise example with FastAPI, pytest, and agent identity
1 parent 483ebfb commit d6411e1

23 files changed

Lines changed: 753 additions & 201 deletions

.auths/allowed_signers

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Auths allowed signers file
2+
# Format: <email> ssh-ed25519 <public-key>
3+
4+
alice@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyAliceReplaceMeWithRealKey000000000
5+
bob@example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyBobReplaceMeWithARealKey00000000000
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Verify Commits
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
verify:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: auths-dev/auths-verify-github-action@v1
20+
with:
21+
allowed-signers-path: .auths/allowed_signers
22+
fail-on-unsigned: true
23+
post-pr-comment: 'true'
24+
github-token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3.12-slim AS builder
2+
3+
WORKDIR /app
4+
COPY pyproject.toml .
5+
RUN pip install --no-cache-dir --target=/deps .
6+
7+
FROM python:3.12-slim
8+
9+
WORKDIR /app
10+
COPY --from=builder /deps /usr/local/lib/python3.12/site-packages
11+
COPY app/ app/
12+
13+
RUN useradd --create-home appuser
14+
USER appuser
15+
16+
EXPOSE 8000
17+
18+
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)