add oathtool functionality
This commit is contained in:
parent
b2972cfd4d
commit
15bdc74b45
2 changed files with 25 additions and 1 deletions
|
@ -31,6 +31,22 @@ copy_to_clipboard() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Funktion zum Erzeugen eines TOTP aus otpauth URL
|
||||||
|
totp_from_otpauth() {
|
||||||
|
local url="$1"
|
||||||
|
if [[ "$url" =~ ^otpauth://totp/.*secret= ]]; then
|
||||||
|
local secret=$(echo "$url" | grep -oP 'secret=\K[^&]*')
|
||||||
|
if [[ -z "$secret" ]]; then
|
||||||
|
echo "Kein Secret im OTPAUTH-URL gefunden."
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
oathtool -b --totp "$secret"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Liste mit Name+User kombinieren und formatieren
|
# Liste mit Name+User kombinieren und formatieren
|
||||||
entries=$(rbw list --fields name,user | awk -F'\t' '{print $1 " | " $2}')
|
entries=$(rbw list --fields name,user | awk -F'\t' '{print $1 " | " $2}')
|
||||||
|
|
||||||
|
@ -55,6 +71,14 @@ if [[ -n "$selected" ]]; then
|
||||||
|
|
||||||
if [[ -n "$selected_detail" ]]; then
|
if [[ -n "$selected_detail" ]]; then
|
||||||
cleaned_text=$(clean_text "$selected_detail")
|
cleaned_text=$(clean_text "$selected_detail")
|
||||||
|
|
||||||
|
# Wenn cleaned_text ein otpauth:// URL ist, versuche TOTP Code zu generieren
|
||||||
|
totp_code=$(totp_from_otpauth "$cleaned_text")
|
||||||
|
if [[ $? -eq 0 && -n "$totp_code" ]]; then
|
||||||
|
cleaned_text="$totp_code"
|
||||||
|
echo "TOTP-Code generiert: $cleaned_text"
|
||||||
|
fi
|
||||||
|
|
||||||
copy_to_clipboard "$cleaned_text"
|
copy_to_clipboard "$cleaned_text"
|
||||||
echo "In Zwischenablage kopiert: ${cleaned_text:0:20}..."
|
echo "In Zwischenablage kopiert: ${cleaned_text:0:20}..."
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ sudo dnf update
|
||||||
sudo dnf install -y \
|
sudo dnf install -y \
|
||||||
fzf zsh-autosuggestions zsh-syntax-highlighting \
|
fzf zsh-autosuggestions zsh-syntax-highlighting \
|
||||||
rg htop ncdu pwgen pass-otp gopass gopass-jsonapi \
|
rg htop ncdu pwgen pass-otp gopass gopass-jsonapi \
|
||||||
tmux-powerline lolcat socat
|
tmux-powerline lolcat socat oathtool
|
||||||
|
|
||||||
## GUI & Desktop
|
## GUI & Desktop
|
||||||
sudo dnf install -y \
|
sudo dnf install -y \
|
||||||
|
|
Loading…
Add table
Reference in a new issue