Fixes 2fa to only use the secret-tool
This commit is contained in:
parent
3761169203
commit
a71e755ac6
3 changed files with 22 additions and 11 deletions
|
|
@ -1,14 +1,28 @@
|
|||
#!/bin/env sh
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPTPATH="$(
|
||||
cd -- "$(dirname "$0")" >/dev/null 2>&1
|
||||
pwd -P
|
||||
)"
|
||||
TOKEN=$(cat "$SCRIPTPATH/.auth-token")
|
||||
set -o pipefail
|
||||
|
||||
KEYRING_NAME="2fauth"
|
||||
KEYRING_VALUE="token"
|
||||
DOMAIN="https://auth.iedsoftworks.com"
|
||||
|
||||
list=$(curl --oauth2-bearer "$TOKEN" "$DOMAIN/api/v1/twofaccounts" | jq 'map({"\(.service) - \(.account)": .id}) | add' -r)
|
||||
getApiToken() {
|
||||
token=$(secret-tool lookup "$KEYRING_NAME" "$KEYRING_VALUE")
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
token=$(zenity --forms --add-multiline-entry="API Key" --text="Provide a valid API key")
|
||||
if [[ $token == "" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$token" | secret-tool store --label "2FAuth API Key" "$KEYRING_NAME" "$KEYRING_VALUE"
|
||||
}
|
||||
|
||||
getApiToken
|
||||
|
||||
list=$(curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts" | jq 'map({"\(.service) - \(.account)": .id}) | add' -r)
|
||||
selection=$(echo "$list" | jq 'keys | map("\(.)\n") | add' -r | anyrun --plugins libstdin.so)
|
||||
|
||||
if [[ $selection == "" ]]; then
|
||||
|
|
@ -17,7 +31,7 @@ fi
|
|||
|
||||
id=$(echo $list | jq ".[\"${selection}\"]")
|
||||
|
||||
curl --oauth2-bearer "$TOKEN" "$DOMAIN/api/v1/twofaccounts/$id/otp" |
|
||||
curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts/$id/otp" |
|
||||
jq ".password" -r |
|
||||
wl-copy
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
.ssh/*.key
|
||||
|
||||
.local/share/kwalletd/*
|
||||
|
||||
.config/scripts/anyrun/.auth-token
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue