Skip to content

Instantly share code, notes, and snippets.

@rogmanster
Created September 5, 2019 23:55
Show Gist options
  • Save rogmanster/931b6ae938d1ff6928aeb150fc704496 to your computer and use it in GitHub Desktop.
Save rogmanster/931b6ae938d1ff6928aeb150fc704496 to your computer and use it in GitHub Desktop.
Vault JWT Auth Method - API
{
"oidc_discovery_url":"https://dev-2sqiyoyv.auth0.com/",
"bound_issuer":"https://dev-2sqiyoyv.auth0.com/",
"default_role":"demo"
}
{
"role_type":"jwt",
"bound_audiences":"https://vault.com",
"user_claim":"sub",
"policies":"my-policy",
"ttl":"1h"
}
{
"data": {
"username": "milli",
"password": "vanilli"
}
}
{
"policy": "path \"secret/metadata\" { capabilities = [\"list\"]} \npath \"secret/data/mycred\" { capabilities = [\"read\"]}"
}
#configure kv secret
curl \
--header "X-Vault-Token: ${VAULT_TOKEN}" \
--request POST \
--data @mycred.json \
http://localhost:8200/v1/secret/data/mycred | jq
#enable jwt auth
curl \
--header "X-Vault-Token: $VAULT_TOKEN" \
--request POST \
--data '{"type": "jwt"}' \
http://127.0.0.1:8200/v1/sys/auth/jwt
#configure jwt auth method
curl \
--header "X-Vault-Token: ${VAULT_TOKEN}" \
--request POST \
--data @jwt_config.json \
http://localhost:8200/v1/auth/jwt/config | jq
#configure jwt role
curl \
--header "X-Vault-Token: ${VAULT_TOKEN}" \
--request POST \
--data @jwt_role.json \
http://localhost:8200/v1/auth/jwt/role/demo | jq
#apply policy
curl \
--request POST \
--header "X-Vault-Token: ${VAULT_TOKEN}" \
--data @policy.json \
http://localhost:8200/v1/sys/policy/my-policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment