-
Notifications
You must be signed in to change notification settings - Fork 180
Add Secrets CRUD #1308
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
Open
Code42Cate
wants to merge
29
commits into
main
Choose a base branch
from
secrets-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Secrets CRUD #1308
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b56c296
vault client in api
Code42Cate 088df33
add secrets crud
Code42Cate 0ab3763
log, metadata
Code42Cate 7171969
revert naming
Code42Cate 5f1ac9f
fix range
Code42Cate ee51725
Merge branch 'main' into secrets-api
Code42Cate 7e8890c
make linter happy
Code42Cate 6dacd9b
fix assert.Error
Code42Cate 4155a75
ci: vault in integration tests
Code42Cate 34d5440
fix vault
Code42Cate 99a8ce4
fix: try to explicity load .env
Code42Cate e105562
fix env
Code42Cate 908d0d5
fix useless init
Code42Cate 1531b5e
fix renewal context
Code42Cate bce8156
fix context
Code42Cate 5b0b2c0
make secrets vault optional
Code42Cate 22159ec
use cfg for vault env
Code42Cate 2ba429b
throw error if vault not configured on api requests
Code42Cate afc195f
consistency in client
Code42Cate 39f1cb7
simplify vault client
Code42Cate 7b703e9
fix fmt
Code42Cate c423de0
fix .env.template
Code42Cate 7b72a63
revert naming change
Code42Cate 62870be
fix interface
Code42Cate e481639
add interface comment
Code42Cate fea1b54
ternary for vault approle
Code42Cate 0b003f0
move vault start to extra script
Code42Cate d5f9364
improve vault renewal
Code42Cate 027e290
reduce log to info
Code42Cate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Starting Vault in dev mode..." | ||
docker run -d --name vault \ | ||
--cap-add=IPC_LOCK \ | ||
-e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' \ | ||
-e 'VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200' \ | ||
-p 8200:8200 \ | ||
hashicorp/vault:1.20.3 | ||
|
||
echo "Waiting for Vault to be ready..." | ||
for i in {1..30}; do | ||
if curl -s http://localhost:8200/v1/sys/health | grep -q "initialized"; then | ||
echo "Vault is ready!" | ||
break | ||
fi | ||
echo "Waiting for Vault... ($i/30)" | ||
sleep 1 | ||
done | ||
|
||
# Configure Vault | ||
export VAULT_ADDR='http://localhost:8200' | ||
export VAULT_TOKEN='myroot' | ||
|
||
echo "Enabling AppRole auth..." | ||
docker exec -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN=$VAULT_TOKEN vault \ | ||
vault auth enable approle || true | ||
|
||
echo "Creating Vault policy..." | ||
cat > /tmp/vault-policy.hcl <<'POLICY' | ||
path "secret/data/*" { | ||
capabilities = ["create", "read", "update", "delete"] | ||
} | ||
path "secret/metadata/*" { | ||
capabilities = ["create", "read", "update", "delete"] | ||
} | ||
POLICY | ||
|
||
docker cp /tmp/vault-policy.hcl vault:/tmp/vault-policy.hcl | ||
docker exec -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN=$VAULT_TOKEN vault \ | ||
vault policy write test-policy /tmp/vault-policy.hcl | ||
|
||
echo "Creating AppRole..." | ||
docker exec -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN=$VAULT_TOKEN vault \ | ||
vault write auth/approle/role/test-role \ | ||
token_policies="test-policy" \ | ||
token_ttl=1h \ | ||
token_max_ttl=4h | ||
|
||
echo "Getting role-id and secret-id..." | ||
ROLE_ID=$(docker exec -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN=$VAULT_TOKEN vault \ | ||
vault read -field=role_id auth/approle/role/test-role/role-id) | ||
SECRET_ID=$(docker exec -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN=$VAULT_TOKEN vault \ | ||
vault write -field=secret_id -f auth/approle/role/test-role/secret-id) | ||
|
||
echo "Exporting Vault configuration..." | ||
if [ -n "$GITHUB_ENV" ]; then | ||
echo "VAULT_ADDR=http://localhost:8200" >> $GITHUB_ENV | ||
echo "VAULT_APPROLE_ROLE_ID=${ROLE_ID}" >> $GITHUB_ENV | ||
echo "VAULT_APPROLE_SECRET_ID=${SECRET_ID}" >> $GITHUB_ENV | ||
else | ||
echo "VAULT_ADDR=http://localhost:8200" | ||
echo "VAULT_APPROLE_ROLE_ID=${ROLE_ID}" | ||
echo "VAULT_APPROLE_SECRET_ID=${SECRET_ID}" | ||
fi | ||
|
||
echo "Vault setup complete!" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.