Skip to content

Instantly share code, notes, and snippets.

@DavidWittman
Last active December 21, 2015 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWittman/6275601 to your computer and use it in GitHub Desktop.
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
#!/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