Skip to content

Commit

Permalink
Added TOTP OAuth Token Generator plugin (#875)
Browse files Browse the repository at this point in the history
* Added TOTP OAuth Token Generator plugin

* Updating the oathtool path to /usr/local/bin/oathtool so it's more likely to work on newer versions of oathtool

* Updting the variable name vpnsecrets to totp_secrets
  • Loading branch information
Gunasekaran Namachivayam authored and tresni committed Oct 6, 2017
1 parent a1b3528 commit 5f7dcb8
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Dev/TOTPOpenAuth/totp.20s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# <bitbar.title>Authenticator</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Gunasekaran Namachivayam</bitbar.author>
# <bitbar.author.github>gunasekar</bitbar.author.github>
# <bitbar.desc>This plugin will generate the TOTP tokens and allows to copy them to clipboard</bitbar.desc>

# Hack for language not being set properly and unicode support
export LANG="${LANG:-en_US.UTF-8}"

# update the key value pairs as per your requirement
# Key - for your reference to identify a TOTP Account
# Value - base32 secret key corresponding to the TOTP Account
totp_secrets=( "OpenVPN:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"BitBucket:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"GitHub:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"Okta:2b2drladcdoxtpheuom6t4zjsr6tq7ix"
"GrabTaxi:2b2drladcdoxtpheuom6t4zjsr6tq7ix" )

# oath-toolkit needs to be installed. Use 'brew install oath-toolkit'
# update the appropriate path of oathtool binary below
oathtool="/usr/local/bin/oathtool"

function get-totp {
$oathtool --totp -b "$1"
}

if [[ "$1" == "copy" ]]; then
echo -n "$(echo -n "$2")" | pbcopy
exit
fi

echo ""
echo '---'
echo "Clear Clipboard | bash='$0' param1=copy param2=' ' terminal=false"
echo "---"

for secret in "${totp_secrets[@]}" ; do
KEY="${secret%%:*}"
VALUE="${secret##*:}"
token=$( get-totp "$VALUE" )
echo "$KEY | bash='$0' param1=copy param2='$token' terminal=false"
done

0 comments on commit 5f7dcb8

Please sign in to comment.