Repository navigation
Development #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #6
Changes from all commits
1200d1b
e55ccc4
ab3b32c
a43db59
685574c
67f9f00
f40a3df
ad416a4
83be2ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Normalize line endings: treat everything as text and let Git handle EOL, | ||
| # but pin source and config files to LF so formatting stays stable across OSes. | ||
| * text=auto eol=lf | ||
|
|
||
| # Source | ||
| *.rs text eol=lf | ||
| *.py text eol=lf | ||
| *.pyi text eol=lf | ||
|
|
||
| # Config / data / docs | ||
| *.toml text eol=lf | ||
| *.json text eol=lf | ||
| *.yml text eol=lf | ||
| *.yaml text eol=lf | ||
| *.md text eol=lf | ||
| *.lock text eol=lf | ||
| *.cfg text eol=lf | ||
| *.ini text eol=lf | ||
| *.sh text eol=lf | ||
| .gitattributes text eol=lf | ||
| .gitignore text eol=lf | ||
|
|
||
| # Compiled extension artifacts (belt-and-suspenders; also gitignored) | ||
| *.pdb binary | ||
| *.pyd binary | ||
| *.so binary | ||
| *.whl binary | ||
| *.gz binary |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,51 @@ | ||
| --- | ||
| inclusion: always | ||
| --- | ||
|
|
||
| # Product Overview | ||
|
|
||
| fast-paseto is a high-performance PASETO library: Rust core with Python bindings via PyO3. | ||
|
|
||
| ## What This Library Does | ||
| fast-paseto is a high-performance [PASETO](https://paseto.io/) (Platform-Agnostic Security Tokens) library: a Rust core exposed to Python via PyO3. It aims to be significantly faster than pure-Python alternatives (benchmarked against `pyseto`) while keeping a clean, type-hinted Python API. | ||
|
|
||
| | Token Type | Crypto | Use Case | | ||
| |------------|--------|----------| | ||
| | `local` (symmetric) | XChaCha20-Poly1305 | Encrypted confidential data | | ||
| | `public` (asymmetric) | Ed25519 | Signed verifiable data (not encrypted) | | ||
| ## Token Types | ||
|
|
||
| Supported versions: v4 (default), v3 (NIST), v2 (legacy) | ||
| | Type | Crypto (v4) | Use Case | | ||
| |------|-------------|----------| | ||
| | `local` (symmetric) | XChaCha20-Poly1305 | Encrypted, confidential data | | ||
| | `public` (asymmetric) | Ed25519 signatures | Signed, verifiable data (NOT encrypted) | | ||
|
|
||
| ## API Patterns | ||
| ## Supported Versions | ||
|
|
||
| Two usage styles exist: | ||
| | Version | Local (encryption) | Public (signatures) | | ||
| |---------|--------------------|----------------------| | ||
| | v4 (default) | XChaCha20-Poly1305 | Ed25519 | | ||
| | v3 (NIST) | AES-256-CTR + HMAC-SHA384 | ECDSA P-384 | | ||
| | v2 (legacy) | XChaCha20-Poly1305 | Ed25519 | | ||
|
|
||
| 1. **Module functions** — `encode()`, `decode()` for one-off operations | ||
| 2. **Paseto class** — Configurable instance with defaults (expiration, serializer, etc.) | ||
| ## API Surface | ||
|
|
||
| Key behaviors: | ||
| - Auto-injects `exp` and `iat` claims when configured | ||
| - JSON serialization by default; custom serializers via Protocol | ||
| - Returns immutable `Token` objects from decode operations | ||
| Two usage styles: | ||
|
|
||
| ## Code Generation Rules | ||
| 1. **Module functions** — `encode()`, `decode()`, `generate_symmetric_key()`, `generate_keypair()` for one-off operations. | ||
| 2. **`Paseto` class** — Configurable instance with defaults: `default_exp`, `include_iat`, `leeway`. | ||
|
|
||
| When generating code for this library: | ||
|
|
||
| | Do | Don't | | ||
| |----|-------| | ||
| | Use `generate_symmetric_key()` for local tokens | Hardcode or generate keys manually | | ||
| | Use `generate_asymmetric_keypair()` for public tokens | Implement any crypto in Python | | ||
| | Default to v4 unless user specifies otherwise | Mix key types across token purposes | | ||
| | Validate key lengths (32B symmetric, 64B secret, 32B public) | Put sensitive data in public tokens | | ||
| | Use type stubs from `fast_paseto.pyi` for signatures | Add Python runtime dependencies | | ||
| Additional capabilities: | ||
| - **PASERK** — key serialization (`to_paserk_local/secret/public`, `from_paserk`), key IDs (`generate_lid/sid/pid`), key wrapping (`local_wrap/unwrap`, `secret_wrap/unwrap`), password protection with Argon2id (`local_pw_encrypt/decrypt`, `secret_pw_encrypt/decrypt`). | ||
| - **PEM loading** — `ed25519_from_pem`, `ed25519_public_from_pem`. | ||
| - **Footers & implicit assertions** — supported on encode/decode. | ||
| - **Custom serialization** — JSON by default; pass an object implementing the `Serializer`/`Deserializer` protocol. | ||
| - Auto-injects `exp`/`iat` claims when configured on a `Paseto` instance. | ||
| - `decode()` returns an immutable `Token` (supports attribute access, `[]`, `in`, `to_dict()`). | ||
|
|
||
| ## Key Lengths | ||
|
|
||
| | Key Type | Length | Token Type | | ||
| |----------|--------|------------| | ||
| | Symmetric | 32 bytes | local | | ||
| | Secret (private) | 64 bytes | public | | ||
| | Public | 32 bytes | public | | ||
| | Ed25519 secret | 64 bytes | public (signing) | | ||
| | Ed25519 public | 32 bytes | public (verification) | | ||
|
|
||
| ## Common Mistakes to Prevent | ||
| ## Code Generation Rules | ||
|
|
||
| - Using public tokens for confidential data (they're signed, not encrypted) | ||
| - Reusing keys between local and public token operations | ||
| - Implementing cryptographic operations outside Rust | ||
| - Using PASETO for long-lived session storage (prefer short expiration) | ||
| - Forgetting to rebuild with `maturin develop` after Rust changes | ||
| | Do | Don't | | ||
| |----|-------| | ||
| | Use `generate_symmetric_key()` for local tokens | Hardcode or hand-roll keys | | ||
| | Use `generate_keypair()` for public tokens | Implement any crypto in Python | | ||
| | Default to v4 unless the user specifies otherwise | Mix key types across purposes | | ||
| | Validate key lengths (32B symmetric, 64B secret, 32B public) | Put confidential data in public tokens (signed, not encrypted) | | ||
| | Match signatures to `python/fast_paseto/_fast_paseto.pyi` | Use PASETO for long-lived session storage (prefer short exp) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Harden the checkout and caching steps.
zizmorreports two items on this new job:actions/checkout@v4keeps the credential in.git/config. Setpersist-credentials: false, because this job runscargo,maturin, andpyteston repository code.Swatinem/rust-cache@v2andastral-sh/setup-uv@v5enable caching by default. This workflow also runs on tag refs and publishes to PyPI, so restrict caching to non-tag runs.🔒 Proposed hardening
🧰 Tools
🪛 zizmor (1.29.0)
[warning] 26-26: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 32-32: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default
(cache-poisoning)
[error] 34-34: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default
(cache-poisoning)
🤖 Prompt for AI Agents
Source: Linters/SAST tools