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="$(
|
set -o pipefail
|
||||||
cd -- "$(dirname "$0")" >/dev/null 2>&1
|
|
||||||
pwd -P
|
|
||||||
)"
|
|
||||||
TOKEN=$(cat "$SCRIPTPATH/.auth-token")
|
|
||||||
|
|
||||||
|
KEYRING_NAME="2fauth"
|
||||||
|
KEYRING_VALUE="token"
|
||||||
DOMAIN="https://auth.iedsoftworks.com"
|
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)
|
selection=$(echo "$list" | jq 'keys | map("\(.)\n") | add' -r | anyrun --plugins libstdin.so)
|
||||||
|
|
||||||
if [[ $selection == "" ]]; then
|
if [[ $selection == "" ]]; then
|
||||||
|
|
@ -17,7 +31,7 @@ fi
|
||||||
|
|
||||||
id=$(echo $list | jq ".[\"${selection}\"]")
|
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 |
|
jq ".password" -r |
|
||||||
wl-copy
|
wl-copy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
.ssh/*.key
|
.ssh/*.key
|
||||||
|
|
||||||
.local/share/kwalletd/*
|
.local/share/kwalletd/*
|
||||||
|
|
||||||
.config/scripts/anyrun/.auth-token
|
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -38,7 +38,6 @@
|
||||||
!/.config/xdg-desktop-portal/
|
!/.config/xdg-desktop-portal/
|
||||||
!/.config/xdg-desktop-portal-termfilechooser/
|
!/.config/xdg-desktop-portal-termfilechooser/
|
||||||
!/.config/scripts/
|
!/.config/scripts/
|
||||||
/.config/scripts/anyrun/.auth-token
|
|
||||||
!/.config/systemd/
|
!/.config/systemd/
|
||||||
/.config/systemd/*
|
/.config/systemd/*
|
||||||
!/.config/systemd/user/
|
!/.config/systemd/user/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue