Designs, generates, stores, and rotates API keys: high-entropy generation with openssl, hashed storage, and Vault-backed issuance.
Agentic Workflow: Read -> Reason -> Act (api-key)
You are Api Key (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for api-key
- Domain: Designs, generates, stores, and rotates API keys: high-entropy generation with openssl, hashed storage, and Vault-backed issuance.
- key-generation: Generate strong API keys and inspect their entropy. —
openssl rand -hex 32
- vault-issuance: Store, retrieve, and rotate API keys in HashiCorp Vault KV. —
vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)
- Check
knowledge and prerequisites: node, openssl, uuidgen, vault
2. Reason — think for api-key
- For
key-generation: Generate strong API keys and inspect their entropy. — decide which checks to run
- For
vault-issuance: Store, retrieve, and rotate API keys in HashiCorp Vault KV. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-key tools
- Tools:
Glob, Grep, Read, Openssl, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-key:64825289
API Keys
What this skill does
End-to-end API key management: generating high-entropy keys with openssl/node crypto, storing them in Vault KV, hashing keys at rest, and rotating keys with dual-write grace windows.
When to use
- Adding key-based auth to an API
- Responding to a leaked key incident (rotation)
- Centralizing key storage instead of .env pasting
Real commands
# Generate a 256-bit key
openssl rand -hex 32
openssl rand -base64 32
# Store in Vault
vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)
# Retrieve
vault kv get -field=key secret/api-keys/prod
# List / delete
vault kv list secret/api-keys
vault kv delete secret/api-keys/expired
Storage best practice
Store only a SHA-256 hash of the key in the application database:
KEY=$(openssl rand -hex 32)
echo -n "$KEY" | sha256sum
Show the raw key exactly once, then hash it.
Rotation checklist
- Generate new key and store as v2 in Vault
- Deploy dual-read (accept old + new) for a grace window
- Cut over writers to the new key
- Revoke the old key with vault kv delete
Testing
- Confirm the old key stops working after revocation
- Verify Vault ACLs: a service can only read its own path
Best practices
- Never log keys; redact Authorization in access logs
- Rate-limit by key and monitor anomalous usage
- Use X-API-Key header or Bearer tokens consistently
Capabilities
key-generation
Generate strong API keys and inspect their entropy.
Parameters:
bytes (number): Number of random bytes (32 = 256 bits)
encoding (string): hex, base64, or base64url
Commands:
openssl rand -hex 32
openssl rand -base64 32
node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"
uuidgen
openssl rand -base64 32 | sha256sum
Examples:
- KEY=$(openssl rand -hex 32) && echo $KEY
- openssl rand -base64 48 | tr '+/' '-_' | tr -d '='
- node -e "console.log(require('crypto').randomBytes(24).toString('hex'))"
vault-issuance
Store, retrieve, and rotate API keys in HashiCorp Vault KV.
Parameters:
path (string): Vault KV path, e.g. secret/api-keys/prod
field (string): Single field to read from the secret
Commands:
vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)
vault kv get secret/api-keys/prod
vault kv list secret/api-keys
vault kv delete secret/api-keys/expired
vault kv patch secret/api-keys/prod rotated_at=$(date -u +%FT%TZ)
Examples:
- vault kv put secret/api-keys/prod service=payments key=$(openssl rand -hex 32)
- vault kv get -field=key secret/api-keys/prod
- vault kv metadata get secret/api-keys/prod
References
1---2name: "api-key"3description: "Designs, generates, stores, and rotates API keys: high-entropy generation with openssl, hashed storage, and Vault-backed issuance. Use when working with key generation, vault issuance, api or when the user mentions key generation, vault issuance, api."4license: "MIT"5compatibility: "Requires node, openssl, uuidgen, vault."6metadata:7 source: https://skillmd.com/skills/opknock/api-key8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(node:*) Bash(openssl:*) Bash(uuidgen:*) Bash(vault:*)"12---1314Designs, generates, stores, and rotates API keys: high-entropy generation with openssl, hashed storage, and Vault-backed issuance.1516## Agentic Workflow: Read -> Reason -> Act (api-key)1718You are **Api Key** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `api-key`21- Domain: Designs, generates, stores, and rotates API keys: high-entropy generation with openssl, hashed storage, and Vault-backed issuance.22- **key-generation**: Generate strong API keys and inspect their entropy. — `openssl rand -hex 32`23- **vault-issuance**: Store, retrieve, and rotate API keys in HashiCorp Vault KV. — `vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)`24- Check `knowledge` and `prerequisites: node, openssl, uuidgen, vault`2526### 2. Reason — think for `api-key`27- For `key-generation`: Generate strong API keys and inspect their entropy. — decide which checks to run28- For `vault-issuance`: Store, retrieve, and rotate API keys in HashiCorp Vault KV. — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-key` tools32- Tools: `Glob`, `Grep`, `Read`, `Openssl`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-key:64825289`3536# API Keys3738## What this skill does3940End-to-end API key management: generating high-entropy keys with openssl/node crypto, storing them in Vault KV, hashing keys at rest, and rotating keys with dual-write grace windows.4142## When to use4344- Adding key-based auth to an API45- Responding to a leaked key incident (rotation)46- Centralizing key storage instead of .env pasting4748## Real commands4950```bash51# Generate a 256-bit key52openssl rand -hex 3253openssl rand -base64 325455# Store in Vault56vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)5758# Retrieve59vault kv get -field=key secret/api-keys/prod6061# List / delete62vault kv list secret/api-keys63vault kv delete secret/api-keys/expired64```6566## Storage best practice6768Store only a SHA-256 hash of the key in the application database:6970```bash71KEY=$(openssl rand -hex 32)72echo -n "$KEY" | sha256sum73```7475Show the raw key exactly once, then hash it.7677## Rotation checklist78791. Generate new key and store as v2 in Vault802. Deploy dual-read (accept old + new) for a grace window813. Cut over writers to the new key824. Revoke the old key with vault kv delete8384## Testing8586- Confirm the old key stops working after revocation87- Verify Vault ACLs: a service can only read its own path8889## Best practices9091- Never log keys; redact Authorization in access logs92- Rate-limit by key and monitor anomalous usage93- Use X-API-Key header or Bearer tokens consistently9495## Capabilities9697### key-generation98Generate strong API keys and inspect their entropy.99100**Parameters:**101- `bytes` (number): Number of random bytes (32 = 256 bits)102- `encoding` (string): hex, base64, or base64url103104**Commands:**105- `openssl rand -hex 32`106- `openssl rand -base64 32`107- `node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"`108- `uuidgen`109- `openssl rand -base64 32 | sha256sum`110111**Examples:**112- KEY=$(openssl rand -hex 32) && echo $KEY113- openssl rand -base64 48 | tr '+/' '-_' | tr -d '='114- node -e "console.log(require('crypto').randomBytes(24).toString('hex'))"115116### vault-issuance117Store, retrieve, and rotate API keys in HashiCorp Vault KV.118119**Parameters:**120- `path` (string): Vault KV path, e.g. secret/api-keys/prod121- `field` (string): Single field to read from the secret122123**Commands:**124- `vault kv put secret/api-keys/prod key=$(openssl rand -hex 32)`125- `vault kv get secret/api-keys/prod`126- `vault kv list secret/api-keys`127- `vault kv delete secret/api-keys/expired`128- `vault kv patch secret/api-keys/prod rotated_at=$(date -u +%FT%TZ)`129130**Examples:**131- vault kv put secret/api-keys/prod service=payments key=$(openssl rand -hex 32)132- vault kv get -field=key secret/api-keys/prod133- vault kv metadata get secret/api-keys/prod134135## References136- [Vault KV v2](https://developer.hashicorp.com/vault/docs/secrets/kv/kv-v2)137- [OWASP API Key Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/API_Key_Security_Cheat_Sheet.html)138- [RFC 9110 Authorization](https://www.rfc-editor.org/rfc/rfc9110#name-authorization)