diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..dbcb073 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1 / 2018-12-03 + + * initial version diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b8f1def --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Martin Hoefling + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..47d205d --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +release: + zip -r ../gopass.alfredworkflow * diff --git a/README.md b/README.md new file mode 100644 index 0000000..70d74d9 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Gopass-Alfred + +Workflow to interact with gopass from Alfred 3. +Currently querying entries and copying username or password to clipboard is supported. +## Screenshot + +![gopass alfred screenshot](./screenshot.png) + +## Installation + +Download the latest package from github or build zip file via `make release` in checked out repository. + + diff --git a/get_password.py b/get_password.py new file mode 100755 index 0000000..96bf9de --- /dev/null +++ b/get_password.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import subprocess +import sys +import json +import os +import struct + +query = { + "type": "getLogin", + "entry": sys.argv[1] +} + +querystr = json.dumps(query) + +my_env = os.environ.copy() +my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH']) + +process = subprocess.Popen(['/usr/local/bin/gopass', 'jsonapi', 'listen'], stdout=subprocess.PIPE, env=my_env, stdin=subprocess.PIPE) +stdout, stderr = process.communicate(input=struct.pack('I', len(querystr))+querystr) +print(json.loads(stdout[4:].strip())[sys.argv[2]]) diff --git a/gopass_filter.py b/gopass_filter.py new file mode 100755 index 0000000..b9f0b6b --- /dev/null +++ b/gopass_filter.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import os +import sys +import logging +import subprocess +import json +import re + +logging.basicConfig(filename='/tmp/gopassalfred.log', level=logging.DEBUG) +logging.debug('Debug log started, called with {}'.format(sys.argv)) + +my_env = os.environ.copy() +my_env['PATH'] = '/usr/local/bin:{}'.format(my_env['PATH']) + +process = subprocess.Popen(['/usr/local/bin/gopass', 'list', '-f'], stdout=subprocess.PIPE, env=my_env) +stdout, stderr = process.communicate() + +outlist = [ + { + "uid": result, + "title": result.split('/')[-1], + "subtitle": '/'.join(result.split('/')[:-1]), + "arg": result, + "match": " ".join(set(re.split('[. /\-]', result))) + ' ' + result, + "autocomplete": result + } for result in stdout.decode('ascii').splitlines() +] + +print(json.dumps({'items': outlist})) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..c886a1a Binary files /dev/null and b/icon.png differ diff --git a/info.plist b/info.plist new file mode 100644 index 0000000..16403ca --- /dev/null +++ b/info.plist @@ -0,0 +1,190 @@ + + + + + bundleid + pw.gopass.alfred + category + Productivity + connections + + 0D5132AE-3620-4D5F-BA72-EFD481455463 + + + destinationuid + DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F + modifiers + 0 + modifiersubtext + + vitoclose + + + + destinationuid + B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7 + modifiers + 131072 + modifiersubtext + copy username + vitoclose + + + + B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7 + + + createdby + Martin Hoefling + description + Gopass password access + disabled + + name + gopass + objects + + + config + + concurrently + + escaping + 68 + script + export PATH=/usr/local/bin:$PATH + +if [ -f ~/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then + source ~/.gpg-agent-info + export GPG_AGENT_INFO +else + eval $(gpg-agent --daemon) +fi + +export GPG_TTY="$(tty)" + +/usr/local/bin/gopass -c "{query}" + +RESULT=$? + +osascript -e 'display notification "Copied password for {query} to clipboard" with title "Gopass"' + +exit $RESULT + scriptargtype + 0 + scriptfile + + type + 0 + + type + alfred.workflow.action.script + uid + DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 2 + argumenttrimmode + 0 + argumenttype + 0 + escaping + 70 + keyword + gp + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + loading gopass secrets + script + /usr/local/bin/gopass list -f > /tmp/all + + scriptargtype + 1 + scriptfile + gopass_filter.py + subtext + secret + title + Passwords from gopass + type + 8 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 0D5132AE-3620-4D5F-BA72-EFD481455463 + version + 2 + + + config + + concurrently + + escaping + 68 + script + USER=$(./get_password.py {query} username) +osascript -e 'display notification "Copied username '$USER'" with title "Gopass"' +echo $USER | pbcopy + scriptargtype + 0 + scriptfile + + type + 0 + + type + alfred.workflow.action.script + uid + B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7 + version + 2 + + + readme + + uidata + + 0D5132AE-3620-4D5F-BA72-EFD481455463 + + xpos + 80 + ypos + 20 + + B1FF35DC-433E-4CCC-9CB3-7C8E1BC532F7 + + xpos + 250 + ypos + 160 + + DB6BF0F4-4C45-43AF-9889-5E5E6CD8048F + + xpos + 250 + ypos + 20 + + + webaddress + https://www.gopass.pw + + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..9f9333d Binary files /dev/null and b/screenshot.png differ