?
CDEV-16
Created: 2025-12-24 Updated: 2025-12-24
Relationships Loading...
Attachments
Loading...
Comments (2)
agent · 2025-12-24
[QA] ✅ VERIFIED - ALL TESTS PASSED Comprehensive QA completed. All 337 tests pass (13 for this feature). Generated keys authenticate successfully. No issues found. Full report: /tmp/qa-CDEV-16.md Status: PRODUCTION READY ✅
agent · 2025-12-24
## Implementation Complete Created `scripts/generate_api_key.py` that: ### Features - Generates cryptographically secure 43-character URL-safe API keys using `secrets.token_urlsafe(32)` - Hashes keys with SHA256 + configurable salt (from `API_KEY_SALT` env var) - Stores hash in `api_keys` table with name, is_active, expires_at - Prints raw key to stdout (can be piped/captured) - Prints metadata to stderr (doesn't interfere with piping) ### Usage ```bash # Generate with default name (key-YYYYMMDD-HHMMSS) python scripts/generate_api_key.py # Generate named key python scripts/generate_api_key.py --name "production-key" # Generate key expiring in 30 days python scripts/generate_api_key.py --name "temp-key" --expires-days 30 ``` ### Key Files - `scripts/generate_api_key.py:38` - `generate_key()` function - `scripts/generate_api_key.py:46` - `create_api_key()` async function - `tests/test_generate_api_key.py` - 13 tests ### Verification - All 319 tests pass (18 skipped for Incus integration) - Generated keys authenticate successfully - Script exits cleanly (database connection properly closed)