Files
JC Beasley 6d2105d206 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
2026-07-19 08:57:13 -07:00

35 lines
901 B
Bash
Executable File

#!/bin/bash
# vault_grist_api.sh - Grist API wrapper using vault cache
# Now uses local vault cache for faster access
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/vault-env.sh"
GRIST_URL="https://grist.beawit.net"
GRIST_TOKEN=$(vault_grist_token)
if [ -z "$GRIST_TOKEN" ]; then
echo "Error: Could not retrieve Grist token from vault cache"
exit 1
fi
# Function to make Grist API calls
grist_api() {
local method="${1:-GET}"
local endpoint="$2"
local payload="${3:-}"
local curl_cmd="curl -sk -H 'Authorization: Bearer ${GRIST_TOKEN}' -H 'Content-Type: application/json'"
if [ "$method" != "GET" ] && [ -n "$payload" ]; then
curl_cmd="${curl_cmd} -X ${method} -d '${payload}'"
fi
eval "${curl_cmd} '${GRIST_URL}${endpoint}'"
}
# Export functions
export -f grist_api
export GRIST_URL
export GRIST_TOKEN