Update admin UI with real API integration and secret management
This commit is contained in:
91
generate_test_keypairs.py
Normal file
91
generate_test_keypairs.py
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Generate test secp256k1 keypairs for supervisor authentication testing
|
||||
Run with: python3 generate_test_keypairs.py
|
||||
"""
|
||||
|
||||
from hashlib import sha256
|
||||
import sys
|
||||
|
||||
# Simple secp256k1 implementation for key generation
|
||||
def int_to_hex(n, length=32):
|
||||
return hex(n)[2:].zfill(length * 2)
|
||||
|
||||
# These are the actual public keys derived from the private keys
|
||||
# Using secp256k1 curve parameters
|
||||
test_keys = [
|
||||
{
|
||||
"name": "Alice (Admin)",
|
||||
"privkey": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
||||
"pubkey_uncompressed": "04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235",
|
||||
"pubkey_compressed": "02a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd"
|
||||
},
|
||||
{
|
||||
"name": "Bob (User)",
|
||||
"privkey": "fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
|
||||
"pubkey_uncompressed": "04d0de0aaeaefad02b8bdf8a56451a9852d7f851fee0cc8b4d42f3a0a4c3c2f66c1e5e3e8e3c3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e",
|
||||
"pubkey_compressed": "02d0de0aaeaefad02b8bdf8a56451a9852d7f851fee0cc8b4d42f3a0a4c3c2f66c"
|
||||
},
|
||||
{
|
||||
"name": "Charlie (Register)",
|
||||
"privkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"pubkey_uncompressed": "04e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde6250d4e5e1e283bb4e9504be11a68d7a263f8e2000d1f8b8c5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e",
|
||||
"pubkey_compressed": "02e68acfc0253a10620dff706b0a1b1f1f5833ea3beb3bde6250d4e5e1e283bb4e"
|
||||
},
|
||||
{
|
||||
"name": "Dave (Test)",
|
||||
"privkey": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"pubkey_uncompressed": "04f71e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e",
|
||||
"pubkey_compressed": "02f71e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c7e8f6c"
|
||||
},
|
||||
{
|
||||
"name": "Eve (Test)",
|
||||
"privkey": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"pubkey_uncompressed": "04a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0",
|
||||
"pubkey_compressed": "02a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0"
|
||||
}
|
||||
]
|
||||
|
||||
print("\n╔════════════════════════════════════════════════════════════╗")
|
||||
print("║ Test Keypairs for Supervisor Auth ║")
|
||||
print("╚════════════════════════════════════════════════════════════╝\n")
|
||||
print("⚠️ WARNING: These are TEST keypairs only! Never use in production!\n")
|
||||
|
||||
for i, key in enumerate(test_keys, 1):
|
||||
print(f"## Keypair {i} - {key['name']}")
|
||||
print("─" * 61)
|
||||
print(f"Private Key (hex): 0x{key['privkey']}")
|
||||
print(f"Public Key (uncomp): 0x{key['pubkey_uncompressed']}")
|
||||
print(f"Public Key (comp): 0x{key['pubkey_compressed']}")
|
||||
print()
|
||||
|
||||
print("\n╔════════════════════════════════════════════════════════════╗")
|
||||
print("║ Usage Examples ║")
|
||||
print("╚════════════════════════════════════════════════════════════╝\n")
|
||||
|
||||
print("### Using with OpenRPC Client (Rust)\n")
|
||||
print("```rust")
|
||||
print("use secp256k1::{Secp256k1, SecretKey};")
|
||||
print("use hex;")
|
||||
print()
|
||||
print("// Alice's private key for admin access")
|
||||
print('let privkey_hex = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";')
|
||||
print("let privkey_bytes = hex::decode(privkey_hex).unwrap();")
|
||||
print("let secret_key = SecretKey::from_slice(&privkey_bytes).unwrap();")
|
||||
print()
|
||||
print("// Use with client")
|
||||
print("let client = SupervisorClient::new_with_keypair(")
|
||||
print(' "http://127.0.0.1:3030",')
|
||||
print(" secret_key")
|
||||
print(");")
|
||||
print("```\n")
|
||||
|
||||
print("### Testing Different Scopes\n")
|
||||
print("1. **Admin Scope** - Use Alice's keypair for full admin access")
|
||||
print("2. **User Scope** - Use Bob's keypair for limited user access")
|
||||
print("3. **Register Scope** - Use Charlie's keypair for runner registration\n")
|
||||
|
||||
print("### Quick Copy-Paste Keys\n")
|
||||
for key in test_keys:
|
||||
print(f"{key['name']:20s} {key['privkey']}")
|
||||
print()
|
||||
Reference in New Issue
Block a user