用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/AJBcoding/claude-skill-eval --skill moai-security-secrets命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Enterprise database architecture specialist with PostgreSQL 17, MySQL 8.4 LTS, MongoDB 8.0, Redis 7.4 expertise. Master connection pooling, query optimization, caching strategies, and database DevOps automation. Build scalable, resilient database systems with comprehensive monitoring and disaster recovery.
Enterprise Frontend Development with AI-powered modern architecture, Context7 integration, and intelligent component orchestration for scalable user interfaces
Enterprise-grade security expertise with production-ready patterns for OWASP Top 10 2021, zero-trust architecture, threat modeling (STRIDE, PASTA), secure SDLC, DevSecOps automation, cloud security, cryptography, identity & access management, and compliance frameworks (SOC 2, ISO 27001, GDPR, CCPA).
基于 SOC 职业分类
正在显示 SKILL.md
| name | moai-security-secrets |
| version | 4.0.0 |
| status | stable |
| description | Enterprise Skill for advanced development |
| allowed-tools | Read, Bash, WebSearch, WebFetch |
Secure Credential Storage, Rotation & Distribution
Trust Score: 9.9/10 | Version: 4.0.0 | Enterprise Mode | Last Updated: 2025-11-12
Secret management is critical infrastructure: API keys, database passwords, and encryption keys must be stored securely, rotated regularly, and distributed safely. This Skill covers HashiCorp Vault, .env security, and secrets rotation patterns.
When to use this Skill:
SECRET TYPES:
├─ Credentials (passwords, API keys, tokens)
├─ Cryptographic Keys (encryption, signing)
├─ Connection Strings (database, message queues)
├─ Certificates (TLS, client auth)
└─ OAuth Tokens (access tokens, refresh tokens)
STORAGE HIERARCHY:
1. Vault System (HashiCorp Vault, AWS Secrets Manager)
2. Environment Variables (via secret injection)
3. Configuration Files (.env - local dev only)
4. Memory (never disk, clear after use)
5. NEVER: Hardcoded, version control, logs
Generate → Distribute → Rotate → Revoke → Destroy
↓ ↓ ↓ ↓ ↓
Secure Encrypted Schedule Immediate Wipe
Token Channel (30-90d) (breach) Keys
| Type | Frequency | Grace Period | Method |
|---|---|---|---|
| API Keys | 90 days | 24 hours | Generate new, deprecate old |
| Database Passwords | 30 days | 48 hours | New password, app restart |
| TLS Certificates | 30 days before expiry | N/A | Automated renewal |
| Session Secrets | 24 hours | Immediate | Rotate all sessions |
| Encryption Keys | On breach | N/A | Re-encrypt all data |
Vault Server Setup:
# Installation
wget https://releases.hashicorp.com/vault/1.18.0/vault_1.18.0_linux_amd64.zip
unzip vault_1.18.0_linux_amd64.zip
# Start Vault
vault server -config=/etc/vault/config.hcl
# Initialize & unseal
vault operator init
vault operator unseal [key1] [key2] [key3]
# Enable secret engine
vault secrets enable -path=app kv-v2
vault secrets enable database
Node.js Vault Client:
const vault = require('@hashicorp/vault-client');
const client = new vault.ApiClient({
endpoint: process.env.VAULT_ADDR,
token: process.env.VAULT_TOKEN
});
// 1. Read secret
async function getSecret(path) {
try {
const response = await client.read(`secret/data/${path}`);
return response.data.data;
} catch (err) {
console.error('Vault error:', err);
throw err;
}
}
// 2. Store secret
async function setSecret(path, data) {
await client.write(`secret/data/${path}`, {
data: data
});
}
// 3. Generate dynamic database password
async function generateDBPassword(role) {
const cred = await client.read(`database/creds/${role}`);
{
: cred..,
: cred..,
: cred.
};
}
() {
newKey = crypto.().();
(, { : newKey });
(appName, newKey);
(, {
: ,
: ()
});
}
() {
response = client...({
: process..,
: process..
});
response..;
}
NEVER commit secrets to version control:
# .gitignore
.env
.env.local
.env.*.local
.env.prod
.env.backup
secrets/
keys/
Environment Variable Validation:
// config/env.js
const z = require('zod');
const envSchema = z.object({
NODE_ENV: z.enum(['development', 'production']).default('development'),
DATABASE_URL: z.string().url(),
DATABASE_PASSWORD: z.string().min(16),
API_KEY: z.string().min(32),
ENCRYPTION_KEY: z.string().length(64),
JWT_SECRET: z.string().min(32),
OAUTH_CLIENT_ID: z.string(),
OAUTH_CLIENT_SECRET: z.string(),
VAULT_ADDR: z.string().url().optional(),
VAULT_TOKEN: z.string().optional()
});
// Validate on startup
export const env = envSchema.parse(process.env);
// Ensure no secrets in logs
Object.keys(env).( {
(key.() || key.() || key.()) {
.(env, key, {
() {
;
}
});
}
});
// jobs/secrets-rotation.js
const cron = require('node-cron');
const vault = require('@hashicorp/vault-client');
class SecretsRotationJob {
constructor(vaultClient) {
this.vault = vaultClient;
this.rotationSchedules = [
{ path: 'app/database-password', schedule: '0 2 * * 0', ttl: '30d' },
{ path: 'app/api-keys', schedule: '0 3 * * SUN', ttl: '90d' },
{ path: 'app/session-secret', schedule: '0 * * * *', ttl: '24h' }
];
}
// Start rotation scheduler
start() {
this.rotationSchedules.forEach(({ path, schedule }) => {
cron.schedule(schedule, () => {
this.rotateSecret(path).catch(err => {
console.error(`Rotation failed for :`, err);
.(path, err);
});
});
});
}
() {
.();
newSecret = .(path);
..(, newSecret);
..(, {
: ,
:
});
.(path, );
.(path, );
( () => {
..();
}, );
}
() {
.();
..(, { : });
emergency = .(path);
..(, emergency);
.(path, );
.(path, );
.(path);
}
() {
(path.()) {
{
: ().().(),
: (),
: (.() + * * * )
};
}
(path.()) {
{
: ,
: ()
};
}
{};
}
() {
services = .(path);
( service services) {
..(, {
path,
version,
: ()
}, { : service });
}
}
() {
maxRetries = ;
retries = ;
(retries < maxRetries) {
adopted = .(path, version);
(adopted === ) {
.();
;
}
.();
( (r, ));
retries++;
}
}
() {
..({
: ,
: ,
: error.,
:
});
}
}
rotationJob = (vaultClient);
rotationJob.();
# Install Sealed Secrets controller
kubectl apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.23.1/controller.yaml
# Create secret
kubectl create secret generic my-secret \
--from-literal=password=mypassword \
--dry-run=client -o yaml > secret.yaml
# Seal the secret
kubeseal -f secret.yaml -w sealed-secret.yaml
# Deploy sealed secret (safe to commit to git)
kubectl apply -f sealed-secret.yaml
# Sealed secret auto-decrypts in cluster
# Use in pod
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: my-app:latest
env:
- name: PASSWORD
valueFrom:
secretKeyRef:
name:
// Zero-knowledge password verification
class ZKAuth {
// Registration: Client commits to password without server knowing
async register(email, password) {
// Client-side only
const salt = crypto.randomBytes(16);
const commitment = hash(hash(password) + salt);
// Send only commitment
await fetch('/auth/register', {
method: 'POST',
body: JSON.stringify({ email, commitment, salt })
});
}
// Authentication: Prove knowledge without revealing password
async login(email, password) {
const challenge = await fetch(`/auth/challenge?email=${email}`);
// Client-side proof generation
const response = hmac(sha256(password), challenge);
// Send only proof (no password)
const result = await fetch('/auth/login', {
method: 'POST',
body: JSON.stringify({ email, response })
});
result.();
}
}
Version: 4.0.0 Enterprise
Skill Category: Security (Secret Management)
Complexity: Advanced
Time to Implement: 4-6 hours
Prerequisites: DevOps, Kubernetes basics, cryptography concepts