browserpass / browserpass-legacy

Legacy Browserpass repo, development is now happening at:
https://github.com/browserpass/browserpass-extension
MIT License
1k stars 80 forks source link

Add "Copy OTP" button to search result items #256

Closed myelsukov closed 6 years ago

myelsukov commented 6 years ago

General information

The extension is great! One small and very simple addition will make it even better: "Copy OTP" button/icon in the search results. For different reasons, I do not follow the proposed naming scheme. I do not mind a couple of key presses to get to the desired secret. Practically I am using your beautiful extension as a shell to pass when I am in the browser. Functionality is seriously crippled without a possibility to copy an OTP.

BTW, the addition of fuzzy search was one great enhancement! I really appreciate it.

maximbaz commented 6 years ago

This makes sense.

Just want to let you know, we are currently rewriting browserpass which will be released as a new major version, and I don't think we will be implementing any new features for v2 - but we will definitely consider this request for v3.

myelsukov commented 6 years ago

At least you gave me a hope :) Until then I will have to use the hacked version of your extension. It's easy in the Chrome, but a pain in the neck in Firefox. I have to use nightly version :(

erayd commented 6 years ago

@myelsukov

Until then I will have to use the hacked version of your extension. It's easy in the Chrome, but a pain in the neck in Firefox. I have to use nightly version :(

You shouldn't need to do this; the current OTP functionality works with Firefox - it displays the OTP code in a small overlay at the top-right of the page. For example, in Firefox v52.7.3 ESR: scr-20180418-091425

When you try to use OTP in Firefox, what happens instead?

maximbaz commented 6 years ago

I think they don't want to submit the form at all, and "hacked version" means a version with the requested new button 🙂

@myelsukov if I'm right and you have a code ready, consider submitting a PR.


On a different note, if you haven't tried rofi, I recommend you to look into it. It's an application launcher, but can be easily extended with any shell script.

I use it personally with passmenu (comes with pass), it allows me to quickly find a pass entry and put the password into the clipboard. You can make a one-liner script to integrate it with pass-otp for the same purpose.

If you want to explore this, relevant bits from the history of my own dotfiles:

~/.config/rofi/config:

rofi.modi: otp:rofi-pass-otp

rofi-pass-otp (anywhere in your $PATH):

#!/usr/bin/env bash

if [[ -z $* ]]; then
  store="$HOME/.password-store/"
  find "$store" -name '*.gpg' | sed -e "s|^$store||" | sed -e 's|\.gpg$||'
else
  pass otp "$1" | xclip -selection clipboard > /dev/null
fi

And assign rofi -show otp to any shortcut so you can easily start it.

myelsukov commented 6 years ago

I know about that nice feature. Unfortunately, it works for the matching sites only. As I mentioned, I have my reasons not to follow the naming scheme.

And this is my wrapper (I call it fass): It can be used with read or fzf

#!/usr/bin/env bash
PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
PREFIX="${PREFIX%/}"
PREFIX_LEN=${#PREFIX}
USE_FZF=1
declare -a found

function _get_script_name() {
    arg=$1
    if [[ ${arg} =~ ^(/|.|~).+$ ]]
    then
        arg0=${arg}
        withpath=1
    else
        arg0=$(which ${arg})
    fi
    arg0=$(readlink -f ${arg0})
    scriptname=$(basename ${arg0})
    scriptdir=$(dirname ${arg0})

    if [[ ${withpath} == 1 ]]
    then
        displayscriptname=${arg0}
    else
        displayscriptname=${scriptname}
    fi
    echo ${scriptname}
}

SCRIPTNAME=$(basename $0)
SEARCH=$1
shift

if [[ ${USE_FZF} != 0 ]]; then
   name=$(find "$PREFIX" -type f ! -regex "${PREFIX}/\..*" | sed -e "s:^${PREFIX}/::" -e "s/\.gpg$//" | fzf --header="Choose password entry" +m --cycle -1 -0 -q \'${SEARCH})
else
    while read -r ; do
        found[${#found[@]}]=${REPLY}
    done < <(find "$PREFIX" -type f ! -regex "^${PREFIX}/\..*" -iname "*${SEARCH}*" | sed -e "s:${PREFIX}/::" -e "s/\.gpg$//")

    if [[ ${#found[@]} = 1 ]]; then
        name=${found[0]}
    elif [[ ${#found[@]} -gt 1 ]]; then
        echo Ambiguous name: ${SEARCH}
        select name in "${found[@]}"; do
            [[ " ${found[*]} " == *" $name "* ]] && break
        done
    else
        echo "Not found: ${SEARCH}"
        exit 1
    fi
fi
if [[ -n ${name} ]]; then
    # echo ${name}
    if [[ ${SCRIPTNAME} == "fassc" ]]; then
        TOCLIP=-c
    fi
    if [[ "$@" == "" || $1 == *-* ]]; then
        cmd=show
    else
        cmd=$1
        shift
    fi
    pass $cmd "${name}" ${TOCLIP} "${@}"
fi
myelsukov commented 6 years ago

My hack is forked off the older version (January?). I'll try to prepare a PR tonight. Note: I am very lazy, so instead of adding new special icon I reused the main icon of your extension :)