Files
aitbc/scripts/utils/generate-api-keys.py
aitbc1 bfe6f94b75
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.11) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.12) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-cli-level1 (3.13) (push) Has been cancelled
AITBC CLI Level 1 Commands Test / test-summary (push) Has been cancelled
chore: remove outdated documentation and reference files
- Remove debugging service documentation (DEBUgging_SERVICES.md)
- Remove development logs policy and quick reference guides
- Remove E2E test creation summary
- Remove gift certificate example file
- Remove GitHub pull summary documentation
2026-03-25 12:56:07 +01:00

110 lines
3.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
API Key Generation Script for AITBC CLI
Generates cryptographically secure API keys for testing CLI commands
"""
import secrets
import json
import sys
from datetime import datetime, timedelta
def generate_api_key(length=32):
"""Generate a cryptographically secure API key"""
return secrets.token_urlsafe(length)
def create_api_key_entry(name, permissions="client", environment="default"):
"""Create an API key entry with metadata"""
api_key = generate_api_key()
entry = {
"name": name,
"api_key": api_key,
"permissions": permissions.split(",") if isinstance(permissions, str) else permissions,
"environment": environment,
"created_at": datetime.utcnow().isoformat(),
"expires_at": (datetime.utcnow() + timedelta(days=365)).isoformat(),
"status": "active"
}
return entry
def main():
"""Main function to generate API keys"""
print("🔑 AITBC API Key Generator")
print("=" * 50)
# Generate different types of API keys
keys = []
# Client API key (for job submission, agent operations)
client_key = create_api_key_entry(
name="client-test-key",
permissions="client",
environment="default"
)
keys.append(client_key)
# Admin API key (for system administration)
admin_key = create_api_key_entry(
name="admin-test-key",
permissions="client,admin",
environment="default"
)
keys.append(admin_key)
# Miner API key (for mining operations)
miner_key = create_api_key_entry(
name="miner-test-key",
permissions="client,miner",
environment="default"
)
keys.append(miner_key)
# Full access API key (for testing)
full_key = create_api_key_entry(
name="full-test-key",
permissions="client,admin,miner",
environment="default"
)
keys.append(full_key)
# Display generated keys
print(f"\n📋 Generated {len(keys)} API Keys:\n")
for i, key in enumerate(keys, 1):
print(f"{i}. {key['name']}")
print(f" API Key: {key['api_key']}")
print(f" Permissions: {', '.join(key['permissions'])}")
print(f" Environment: {key['environment']}")
print(f" Created: {key['created_at']}")
print()
# Save to file
output_file = "/tmp/aitbc-api-keys.json"
with open(output_file, 'w') as f:
json.dump(keys, f, indent=2)
print(f"💾 API keys saved to: {output_file}")
# Show usage instructions
print("\n🚀 Usage Instructions:")
print("=" * 50)
for key in keys:
if 'client' in key['permissions']:
print(f"# For {key['name']}:")
print(f"aitbc auth login {key['api_key']} --environment {key['environment']}")
print()
print("# Test commands that require authentication:")
print("aitbc client submit --prompt 'What is AITBC?' --model gemma3:1b")
print("aitbc agent create --name test-agent --description 'Test agent'")
print("aitbc marketplace gpu list")
print("\n✅ API keys generated successfully!")
if __name__ == "__main__":
main()