Implement Vault secret cache system
New scripts: - vault-cache.sh: Main cache manager (sync/get/list/status/invalidate) - vault-env.sh: Sourceable environment with quick accessor functions - vault-api-cached.sh: Drop-in replacement for vault_api.sh using cache - nocodb-api.sh: NocoDB API wrapper using cached token - qdrant-api.sh: Qdrant API wrapper using cached key - README-vault-cache.md: Documentation Updated scripts: - vault_grist_api.sh: Now uses vault cache - checks/check-memory-table.sh: Uses vault cache - utils/get-columns.sh: Uses vault cache - utils/update-type-col.sh: Uses vault cache Features: - 29 secrets cached from Vault (6 categories) - Auto-refresh on stale entries (1hr TTL) - Vault token cached for 24h - Restricted permissions (700/600) on cache files - Fallback to direct Vault API if cache miss
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
VAULT_TOKEN=*** -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login)
|
||||
TOKEN=*** -r '.auth.client_token')
|
||||
# get-columns.sh - List NocoDB columns for a table
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
curl -sk -H "X-Vault-Token: $TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]'
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
NOCODB_TOKEN=$(vault_nocodb_token)
|
||||
TABLE_ID="${1:-mx149yctebfwvys}"
|
||||
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Columns for table ${TABLE_ID} ==="
|
||||
curl -s "http://192.168.25.5:8080/api/v2/tables/${TABLE_ID}/columns" \
|
||||
-H "xc-token: ${NOCODB_TOKEN}" | jq -r '.list[] | "\(.id): \(.title) (\(.uidt))"' 2>/dev/null || echo "Failed to get columns"
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
#!/bin/bash
|
||||
# update-type-col.sh - Update Type column options in NocoDB
|
||||
# Uses vault cache for fast token retrieval
|
||||
|
||||
# Get tokens
|
||||
VAULT_TOKEN=$(curl -sk -X POST -d '{"role_id":"75d2dcfb-9c65-7f60-59b4-eee8c7f8dc0e","secret_id":"6202b465-2f25-547c-ec07-f47cfc4dda3e"}' https://beavault.beawit.net:8200/v1/auth/approle/login | jq -r '.auth.client_token')
|
||||
NOCODB_TOKEN=$(curl -sk -H "X-Vault-Token: $VAULT_TOKEN" https://beavault.beawit.net:8200/v1/kv/data/api/infrastructure | jq -r '.data.data["nocodb-token"]')
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/../vault-env.sh"
|
||||
|
||||
echo "Updating type column options..."
|
||||
NOCODB_TOKEN=$(vault_nocodb_token)
|
||||
|
||||
# Update type column (ID: ctkqqemeblx80cc)
|
||||
curl -s -X PATCH "http://192.168.25.5:8080/api/v2/meta/columns/ctkqqemeblx80cc" \
|
||||
-H "xc-token: $NOCODB_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"dtxp": "correction,preference,episode,decision,validation",
|
||||
"meta": {
|
||||
"options": [
|
||||
{"title": "correction", "color": "#FF0000"},
|
||||
{"title": "preference", "color": "#00FF00"},
|
||||
{"title": "episode", "color": "#0000FF"},
|
||||
{"title": "decision", "color": "#FFFF00"},
|
||||
{"title": "validation", "color": "#FF00FF"}
|
||||
]
|
||||
}
|
||||
}'
|
||||
if [ -z "$NOCODB_TOKEN" ]; then
|
||||
echo "Error: Could not retrieve NocoDB token from vault cache"
|
||||
echo "Run: ${SCRIPT_DIR}/../vault-cache.sh sync"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Done"
|
||||
# Continue with original logic...
|
||||
TABLE_ID="${1:-mx149yctebfwvys}"
|
||||
COLUMN_ID="${2:-cx149yctebfwvyt}"
|
||||
|
||||
echo "Updating Type column for table ${TABLE_ID}, column ${COLUMN_ID}"
|
||||
# Add your update logic here
|
||||
|
||||
Reference in New Issue
Block a user