Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F27206470
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/bin/getcredentials b/bin/getcredentials
index 6126a9b..955762a 100755
--- a/bin/getcredentials
+++ b/bin/getcredentials
@@ -1,72 +1,72 @@
#!/bin/sh
#
# Gets credentials information from Phabricator Passphrase application
#
# Usage: getcredentials <id> [data]
#
# - id: an integer matching the credential ID on Passphrase
# e.g. 17 for K17
# - data: the property to retrieve
# password, username, token or title
# If omitted, the password will be retrieved
#
# This script requires:
# - arc to communicate with Phabricator through the conduit API
# - jq to parse JSON
#
# Arc is expected to be configured. It generally means there is an ~/.arcrc file
# with a conduit certificate and the Phabricator instance URL. Please note the
# relevant user must have access to the credentials. The easiest way to achieve
# that is to create a dedicated bot/script user, a group, and add both user and
# credentials to this group.
#
#
# Configuration
#
# The maximal credential ID
MAX_ID=2037
#
# Checks arguments
#
if [ $# -lt 1 ]
then
- echo "Usage: getcredentials <id> [password|username|title]"
+ >&2 echo "Usage: getcredentials <id> [password|username|title]"
exit 1
fi
if echo $1 | egrep -q '^[0-9]+$'; then
ID=$1
else
- echo "A positive integer id is expected."
+ >&2 echo "A positive integer id is expected."
exit 2
fi
if [ "${#ID}" -gt "${#MAX_ID}" ] || [ "$ID" -gt "$MAX_ID" ]
then
- echo "The id must be equal or lesser than $MAX_ID."
+ >&2 echo "The id must be equal or lesser than $MAX_ID."
exit 4
fi
if [ $# -gt 1 ]
then
case "$2" in
title) PROPERTY="name" ;;
username) PROPERTY="username" ;;
password) PROPERTY="material.password?" ;;
token) PROPERTY="material.token" ;;
*) echo "Unknown property" ; exit 8 ;;
esac
else
PROPERTY="material.password?"
fi
#
# Queries DevCentral
#
echo "{\"ids\": [$ID], \"needPublicKeys\": true, \"needSecrets\": true}" | arc call-conduit passphrase.query | jq --raw-output ".response.data[].$PROPERTY"
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, May 3, 04:26 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3672630
Default Alt Text
(2 KB)
Attached To
Mode
rZR Zemke-Rhyne
Attached
Detach File
Event Timeline
Log In to Comment