Skip to content

Commit

Permalink
feat(db-sync): Vault's database secrets engine
Browse files Browse the repository at this point in the history
Adds support to retrieve credentials dynamically from Vault's database
secrets engine, assuming the user has enabled and configured it.
  • Loading branch information
nrdxp committed Feb 28, 2023
1 parent 367c839 commit 4d90695
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nix/cardano/entrypoints.nix
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,18 @@ in {
)
local json
json=$("''${cmd[@]}" | jq '.data.data') 2>/dev/null
PGUSER=$(echo "$json"|jq -e -r '."pgUser"')
PGPASS=$(echo "$json"|jq -e -r '."pgPass"')
if [[ $VAULT_KV_PATH =~ .*/creds/.* ]]; then
local qdata quser qpass
qdata=".data"
quser=".username"
qpass=".password"
fi
json=$("''${cmd[@]}" | jq "''${qdata:-.data.data}") 2>/dev/null
PGUSER=$(echo "$json"|jq -e -r "''${quser:-.pgUser}")
PGPASS=$(echo "$json"|jq -e -r "''${qpass:-.pgPass}")
echo -n "$PSQL_ADDR0:$DB_NAME:$PGUSER:$PGPASS" > "$PGPASSFILE"
test -z "''${PGPASSFILE:-}" || chmod 0600 "$PGPASSFILE"
}
Expand Down

0 comments on commit 4d90695

Please sign in to comment.