Skip to content

Instantly share code, notes, and snippets.

@QuittyMR
Created July 17, 2020 09:29
Show Gist options
  • Save QuittyMR/ca626852ac7c59ea2bb16c4cbdd7f547 to your computer and use it in GitHub Desktop.
Save QuittyMR/ca626852ac7c59ea2bb16c4cbdd7f547 to your computer and use it in GitHub Desktop.
Provisioning script for LastPass's terrible enterprise API
#!/usr/bin/env bash
# Make sure both LASTPASS_ env vars are set
set -e
. /home/tomer/Scripts/f.sh
USER=${1?'Usage: recipient name group username password [URL]'}
NAME=${2?Please provide name for the entry}
GROUP=${3?Please provide folder for the entry}
USERNAME=${4?Please provide username for the entry}
PASSWORD=${5?Please provide password for the entry}
URL=${6:-${NAME}}
PAYLOAD='{
"cid": "${LASTPASS_CID}",
"provhash": "{LASTPASS_API_KEY}",
"cmd": "pushsitestousers",
"data": {
"users":"'${USER}'",
"persistent": "0",
"url": "'${URL}'",
"name": "'${NAME}'",
"group": "'${GROUP}'",
"usernametype": "custom",
"username": "'${USERNAME}'",
"password": "'${PASSWORD}'",
"notes": "",
"fav": "",
"decryptid": "0"
}
}'
message "Sharing LastPass entry for ${NAME} with ${USER}"
curl -XPOST -H'content-type:application/json' -d"${PAYLOAD}" https://lastpass.com/enterpriseapi.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment