Update admin UI with real API integration and secret management
This commit is contained in:
65
examples/generate_keypairs.rs
Normal file
65
examples/generate_keypairs.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
/// Generate test secp256k1 keypairs for supervisor authentication testing
|
||||
///
|
||||
/// Run with: cargo run --example generate_keypairs
|
||||
|
||||
use secp256k1::{Secp256k1, SecretKey, PublicKey};
|
||||
use hex;
|
||||
|
||||
fn main() {
|
||||
let secp = Secp256k1::new();
|
||||
|
||||
println!("# Test Keypairs for Supervisor Auth\n");
|
||||
println!("These are secp256k1 keypairs for testing the supervisor authentication system.\n");
|
||||
println!("⚠️ WARNING: These are TEST keypairs only! Never use these in production!\n");
|
||||
|
||||
// Generate 5 keypairs with simple private keys for testing
|
||||
let test_keys = vec![
|
||||
("Alice (Admin)", "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"),
|
||||
("Bob (User)", "fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321"),
|
||||
("Charlie (Register)", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
|
||||
("Dave (Test)", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"),
|
||||
("Eve (Test)", "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"),
|
||||
];
|
||||
|
||||
for (i, (name, privkey_hex)) in test_keys.iter().enumerate() {
|
||||
println!("## Keypair {} ({})", i + 1, name);
|
||||
println!("```");
|
||||
|
||||
// Parse private key
|
||||
let privkey_bytes = hex::decode(privkey_hex).expect("Invalid hex");
|
||||
let secret_key = SecretKey::from_slice(&privkey_bytes).expect("Invalid private key");
|
||||
|
||||
// Derive public key
|
||||
let public_key = PublicKey::from_secret_key(&secp, &secret_key);
|
||||
|
||||
// Serialize keys
|
||||
let pubkey_hex = hex::encode(public_key.serialize_uncompressed());
|
||||
|
||||
println!("Private Key: 0x{}", privkey_hex);
|
||||
println!("Public Key: 0x{}", pubkey_hex);
|
||||
println!("```\n");
|
||||
}
|
||||
|
||||
println!("\n## Usage Examples\n");
|
||||
println!("### Using with OpenRPC Client\n");
|
||||
println!("```rust");
|
||||
println!("use secp256k1::{{Secp256k1, SecretKey}};");
|
||||
println!("use hex;");
|
||||
println!();
|
||||
println!("// Alice's private key");
|
||||
println!("let alice_privkey = SecretKey::from_slice(");
|
||||
println!(" &hex::decode(\"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\").unwrap()");
|
||||
println!(").unwrap();");
|
||||
println!();
|
||||
println!("// Create client with signature");
|
||||
println!("let client = WasmSupervisorClient::new_with_keypair(");
|
||||
println!(" \"http://127.0.0.1:3030\",");
|
||||
println!(" alice_privkey");
|
||||
println!(");");
|
||||
println!("```\n");
|
||||
|
||||
println!("### Testing Different Scopes\n");
|
||||
println!("1. **Admin Scope** - Use Alice's keypair for full admin access");
|
||||
println!("2. **User Scope** - Use Bob's keypair for limited user access");
|
||||
println!("3. **Register Scope** - Use Charlie's keypair for runner registration only\n");
|
||||
}
|
||||
Reference in New Issue
Block a user