Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decentralized secret templates #1621

Merged
merged 4 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"report-coverage": "yarn run lerna run test-coverage",
"test:watch": "node node_modules/jest/bin/jest.js --watch",
"postinstall": "yarn run lerna run postinstall && patch-package && yarn keys:decrypt",
"preinstall": "bash scripts/create_key_templates.sh",
Copy link
Contributor

@martinvol martinvol Nov 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if this is a good practice, but the reason this is in the preinstall is in case some dependency needs this for yarning or build. In case what I just said doesn't make any sense, then just 🚢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It totally makes sense and I was also concerned by this when I made the change.
I think it's ok for now and we can revisit if it causes an issue later.

"keys:decrypt": "bash scripts/key_placer.sh decrypt",
"keys:encrypt": "bash scripts/key_placer.sh encrypt",
"check:packages": "node ./scripts/check-packages.js"
Expand Down
3 changes: 1 addition & 2 deletions packages/blockchain-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"build": "tsc -p .",
"clean": "rm -rf dist coverage",
"gcp-build": "npm run build",
"deploy": "./deploy.sh",
"postinstall": "test -f src/secrets.json || echo \"{}\" > src/secrets.json"
"deploy": "./deploy.sh"
},
"dependencies": {
"@celo/contractkit": "0.1.6",
Expand Down
20 changes: 20 additions & 0 deletions packages/blockchain-api/src/secrets.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"local": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
},
"integration": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
},
"alfajores": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
},
"alfajoresstaging": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
},
"pilot": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
},
"pilotstaging": {
"EXCHANGE_RATES_API_ACCESS_KEY": "CHANGE_ME"
}
}
32 changes: 0 additions & 32 deletions scripts/create_key_templates.sh

This file was deleted.

22 changes: 17 additions & 5 deletions scripts/key_placer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,29 @@ elif [[ $1 != "encrypt" ]] && [[ $1 != "decrypt" ]]; then
exit 1
fi

# this is to allow the script to be called from anywhere
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
cd ..

# place templates to be used (if they exist) in case the environment
# doesn't have access to decryption keys
if [[ $1 == "decrypt" ]]; then
for file_path in "${files[@]}"; do
template_file_path="$file_path.template"

if test -f "$template_file_path" && ! test -f "$file_path"; then
cp "$template_file_path" "$file_path"
fi
done
fi

command -v gcloud > /dev/null 2>&1
if [[ $? -eq 1 ]]; then
echo "gcloud is not installed - skipping ${1}ion"
exit 0
fi

# this is to allow the script to be called from anywhere
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
cd ..

for file_path in "${files[@]}"; do
encrypted_file_path="$file_path.enc"

Expand Down