Skip to content

Instantly share code, notes, and snippets.

@jvanderhoof
Created June 25, 2018 13:43
Show Gist options
  • Save jvanderhoof/29c41b888f4836742b39d3318f0272be to your computer and use it in GitHub Desktop.
Save jvanderhoof/29c41b888f4836742b39d3318f0272be to your computer and use it in GitHub Desktop.
Example authenticating with Conjur, setting, and retrieving a variable.
#!/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