[gopass] Add password revealing to rofi-gopass

When an individual entry is opened the hidden password can now be
revealed, using `Alt+s` by default.
This commit is contained in:
Marty Oehme 2020-06-17 11:40:30 +02:00
parent 589211ed3a
commit 7456bb14ab
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
3 changed files with 29 additions and 15 deletions

View file

@ -3,7 +3,7 @@ root:
autoclip: true
autoprint: false
autoimport: true
autosync: true
autosync: false
check_recipient_hash: false
cliptimeout: 45
concurrency: 1

View file

@ -61,6 +61,7 @@ set_defaults() {
KEY_CLIP_PASS="${RGP_KEY_CLIP_PASS:-$(get_config KEY_CLIP_PASS Ctrl+Alt+p)}"
KEY_ENTRYMENU_FILL="${RGP_KEY_ENTRYMENU_FILL:-$(get_config KEY_ENTRYMENU_FILL Return)}"
KEY_ENTRYMENU_CLIP="${RGP_KEY_ENTRYMENU_CLIP:-$(get_config KEY_ENTRYMENU_CLIP Alt+Return)}"
KEY_ENTRYMENU_SHOWFIELD="${KEY_ENTRYMENU_SHOWFIELD:-$(get_config KEY_ENTRYMENU_SHOWFIELD Alt+s)}"
KEY_ENTRYMENU_QUIT="${RGP_KEY_ENTRYMENU_QUIT:-$(get_config KEY_ENTRYMENU_QUIT Alt+BackSpace)}"
AUTOFILL_BACKEND="${RGP_BACKEND:-$(get_config AUTOFILL_BACKEND xdotool)}"
@ -162,21 +163,29 @@ autofill() {
# opens a menu for the specified gopass entry, containing its individual fields
entrymenu() {
local entry="$1"
local deobfuscate="$2"
local k_entrymenu_fill="${KEY_ENTRYMENU_FILL}"
local k_entrymenu_clip="${KEY_ENTRYMENU_CLIP}"
local k_entrymenu_showfield="${KEY_ENTRYMENU_SHOWFIELD}"
local k_entrymenu_quit="${KEY_ENTRYMENU_QUIT}"
local pass_obfuscation="(hidden)"
local pass
if [ "$deobfuscate" = "true" ]; then
pass="$(show_password "$entry")"
else
pass="(hidden)"
fi
local field
field=$(
printf "password: %s\n%s" "$pass_obfuscation" "$(list_fields "$entry")" |
printf "password: %s\n%s" "$pass" "$(list_fields "$entry")" |
_rofi \
-kb-accept-entry "" \
-kb-custom-1 "$k_entrymenu_fill" \
-kb-custom-2 "$k_entrymenu_clip" \
-kb-custom-3 "$k_entrymenu_quit" \
-mesg " ᐊ $k_entrymenu_quit ᐊ | $k_entrymenu_fill: fill selection | $k_entrymenu_clip: clip selection |"
-kb-custom-4 "$k_entrymenu_showfield" \
-mesg " ᐊ $k_entrymenu_quit ᐊ | $k_entrymenu_fill: fill selection | $k_entrymenu_clip: clip selection | $k_entrymenu_showfield: reveal password"
)
exit_value=$?
exit_check "$exit_value"
@ -203,6 +212,9 @@ entrymenu() {
"12")
main
;;
"13")
entrymenu "$entry" "true"
;;
esac
}

View file

@ -14,17 +14,19 @@ To make accessing secrets easy, it uses the `rofi-gopass` script, which creates
There are several keybindings available, to either fill or copy to clipboard the username, password, or open the full view to an individual entry. For every send to clipboard action, the clipboard will be automatically cleared after the time specified in your gopass settings. For auto-filling to work correctly, the username field will (by default) have to be highlighted.
| keybinding | function | setting name |
| -------- | -------- | ---------- |
| Return | Auto-fill username & password | KEY_AUTOFILL |
| Alt+Return | Open individual entry | KEY_OPEN_ENTRY |
| Alt+u | Auto-fill username | KEY_FILL_USER |
| Alt+p | Auto-fill password | KEY_FILL_PASS |
| Ctrl+Alt+u | Send username to clipboard | KEY_CLIP_USER |
| Ctrl+Alt+p | Send password to clipboard | KEY_CLIP_PASS |
| Return | Auto-fill selected field (from opened entry) | KEY_ENTRYMENU_FILL |
| Alt+Return | Send selected field to clipboard (from opened entry) | KEY_ENTRYMENU_CLIP |
| Alt+BackSpace | Close individual entry, return to overview | KEY_ENTRYMENU_QUIT |
| keybinding | function | setting name |
| -------- | -------- | ---------- |
| Return | Auto-fill username & password | KEY_AUTOFILL |
| Alt+Return | Open individual entry | KEY_OPEN_ENTRY |
| Alt+u | Auto-fill username | KEY_FILL_USER |
| Alt+p | Auto-fill password | KEY_FILL_PASS |
| Ctrl+Alt+u | Send username to clipboard | KEY_CLIP_USER |
| Ctrl+Alt+p | Send password to clipboard | KEY_CLIP_PASS |
| From opened entry: | | |
| Return | Auto-fill selected field | KEY_ENTRYMENU_FILL |
| Alt+Return | Send selected field to clipboard | KEY_ENTRYMENU_CLIP |
| Alt+s | Reveal contents of the password field | KEY_ENTRYMENU_SHOWFIELD |
| Alt+BackSpace | Close individual entry, return to overview | KEY_ENTRYMENU_QUIT |
These keys, as well as the additional configuration can be changed by setting the corresponding environment variable, through a configuration file, or at the top of the script file itself. The script tries to follow xdg-specification, meaning it looks for a configuration file in the following directories (in descending order):