Last active
December 21, 2015 08:08
-
-
Save DavidWittman/6275601 to your computer and use it in GitHub Desktop.
Allows a non-admin OpenStack user to update their password using Keystone's User CRUD extensions
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
#!/usr/bin/env bash | |
# | |
# Allows a non-admin OpenStack user to update their password using | |
# Keystone's User CRUD extensions | |
# | |
# Usage: keystone-update-password.sh <new password> | |
# | |
# Requires curl, python-keystoneclient to fetch the auth tokens, | |
# and expects the user's OS_* environment variables to be exported | |
# in the current environment. | |
set -e | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: ${0} <new password>" | |
exit 1 | |
fi | |
AUTH_TOKEN=$(keystone token-get | awk '/ id / { print $4 }') | |
USER_ID=$(keystone token-get | awk '/user_id/ { print $4 }') | |
NEW_PASSWORD="$1" | |
curl -X PATCH ${OS_AUTH_URL}OS-KSCRUD/users/${USER_ID} \ | |
-H "Content-Type: application/json" -H "X-Auth-Token: ${AUTH_TOKEN}"\ | |
-d '{"user": {"password": "'"${NEW_PASSWORD}"'", "original_password": "'"${OS_PASSWORD}"'"}}' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment