Created
June 25, 2018 13:43
-
-
Save jvanderhoof/29c41b888f4836742b39d3318f0272be to your computer and use it in GitHub Desktop.
Example authenticating with Conjur, setting, and retrieving a variable.
This file contains 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
#!/bin/bash -e | |
function authentication_token { | |
api_key="$(curl -k --user admin:secret https://localhost/authn/cucumber/login)" | |
raw_token="$(curl -k -X POST -d "$api_key" https://localhost/authn/cucumber/admin/authenticate)" | |
token=$(echo -n $raw_token | base64 | tr -d '\r\n') | |
echo "$token" | |
} | |
auth_token=$(authentication_token) | |
secret="production/myapp/database/username" | |
encoded_secret="production%2Fmyapp%2Fdatabase%2Fusername" | |
resp=$(curl -k \ | |
-X POST \ | |
-H "Authorization: Token token=\"$auth_token\"" \ | |
--data "foo-bar" \ | |
"https://localhost/secrets/cucumber/variable/$encoded_secret") | |
resp=$(curl -k \ | |
-H "Authorization: Token token=\"$auth_token\"" \ | |
"https://localhost/secrets/cucumber/variable/$encoded_secret") | |
echo "$resp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment